VideoStreamPlayer

Kind of class: public class
Package:
Inherits from:
  • Sprite
Version: 20 Mar 2010 Now dispatches UIEvent.PLAYBACK_START
19 Mar 2010 Switched poster and controls objects to public vars. Enlarged controls.
7 Mar 2010
Author: John Polacek, john@johnpolacek.com
Classpath: com.johnpolacek.media.VideoStreamPlayer
File last modified: Thursday, 24 February 2011, 22:09:57
NetStream Video Player
Example
  • import com.johnpolacek.media.VideoStreamPlayer;
    var player:AudioPlayer new VideoStreamPlayer();
    player.playVideo("example.flv");
    player.addController();   // adds default controls to player    
    player.addPoster("poster.jpg");
    player.autoRewind = true;
    player.autoPlay = false;
    addChild(player);
    
Events broadcasted to listeners
  • Event.COMPLETE # When load is complete.
  • UIEvent.PLAYBACK_START # When playback starts.
  • UIEvent.PLAYBACK_FINISH # When playback finishes.

Summary

Constructor
Instance properties
  • buttonColor : uint
    • Color of player buttons.
  • backgroundColor : uint
    • Color of player background.
  • autoPlay : Boolean
    • Default is false.
  • autoRewind : Boolean
    • Default is true.
  • poster : Sprite
    • Optional poster image that displays before video is played.
  • controls : Sprite
    • Video controls sprite.
  • controlsOutside : Boolean
    • Boolean determines if controller is inside or outside the video.
Instance methods
  • loadVideo (url:String, videoAutoPlay:Boolean = false) : void
    • Loads video from url.
  • playVideo (url:String = null) : void
    • Starts playback.
  • pauseVideo () : void
    • Pauses playback.
  • resumeVideo () : void
    • Resumes playback.
  • rewindVideo () : void
    • Returns and pauses playback to start of video.
  • seekVideo (p:Number) : void
    • Sets playhead to a percentage of the video's duration.
  • addPoster (filepath:String) : void
  • addController () : void
  • autoHideController () : void
    • Moves controller inside the video player and hides on MOUSE_OUT
  • destroy () : void

Constructor

VideoStreamPlayer

function VideoStreamPlayer()

Instance properties

autoPlay

autoPlay:Boolean = false(read,write)

Default is false.

autoRewind

autoRewind:Boolean = true(read,write)

Default is true.

backgroundColor

backgroundColor:uint = 0x000000(read,write)

Color of player background. Default is 0x000000

buttonColor

buttonColor:uint = 0xFFFFFF(read,write)

Color of player buttons. Default is 0xFFFFFF

controls

controls:Sprite = new Sprite()(read,write)

Video controls sprite.

controlsOutside

controlsOutside:Boolean = false(read,write)

Boolean determines if controller is inside or outside the video. Default is true.

poster

poster:Sprite = new Sprite()(read,write)

Optional poster image that displays before video is played.

Instance methods

addController

function addController() : void

addPoster

function addPoster(filepath:String) : void

autoHideController

function autoHideController() : void

Moves controller inside the video player and hides on MOUSE_OUT

destroy

function destroy() : void

loadVideo

function loadVideo(url:String, videoAutoPlay:Boolean = false) : void

Loads video from url.

Parameters
 

pauseVideo

function pauseVideo() : void

Pauses playback.

playVideo

function playVideo(url:String = null) : void

Starts playback.

Parameters
url:Video url (only used when no video is loaded)

resumeVideo

function resumeVideo() : void

Resumes playback.

rewindVideo

function rewindVideo() : void

Returns and pauses playback to start of video.

seekVideo

function seekVideo(p:Number) : void

Sets playhead to a percentage of the video's duration.

Parameters
p:Percentage of video duration