Skip to main content

Media Player - Loading Media

Once you have created a MediaPlayerView instance then you will need to load your media into the player. In the following code player is assumed to be the MediaPlayerView instance you created:

var player:MediaPlayerView = MediaPlayer.service.createPlayerView(
new MediaPlayerOptions()
.setViewport( new Rectangle( 0, 0, 100, 100 ) )
);

Loading media is done with the load() function. This function takes a path parameter.

player.load( path );

The path can either be a path to a local file or a url to a remote file. For example a local video:

var path:String = File.applicationStorageDirectory.resolvePath( "video.mp4" ).nativePath;

Or a remote file:

var path:String = "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4";