Created
April 12, 2010 06:44
-
-
Save ghinch/363329 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
import flash.events.*; | |
import org.osmf.media.*; | |
import org.osmf.layout.LayoutMetadata; | |
import org.osmf.containers.MediaContainer; | |
public class MyVideoPlayer extends Sprite | |
{ | |
public function MyVideoPlayer() | |
{ | |
mediaFactory = new DefaultMediaFactory(); | |
mediaPlayer = new MediaPlayer(); | |
mediaContainer = new MediaContainer(); | |
mediaContainer.addEventListener('added', loadMedia); | |
addChild(mediaContainer); | |
} | |
private var mediaFactory:MediaFactory; | |
private var mediaElement:MediaElement; | |
private var mediaPlayer:MediaPlayer; | |
private var mediaContainer:MediaContainer; | |
private var flashVars:Object; | |
private function loadMedia(e:Event):void | |
{ | |
mediaContainer.removeEventListener('added', loadMedia); | |
flashVars = loaderInfo.parameters; | |
mediaElement = mediaFactory.createMediaElement(new URLResource(flashVars.file)); | |
var layout:LayoutMetadata = new LayoutMetadata(); | |
layout.width = Number(flashVars.width); | |
layout.height = Number(flashVars.height); | |
mediaElement.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout); | |
mediaPlayer.media = mediaElement; | |
mediaContainer.addMediaElement(mediaElement); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment