Flash player

Coub provides the player that can be loaded into an ActionScript application as a MovieClip class extension.

To embed the player with a coub video, you need to set it up, using the Loader class from flash.display package, and write functions that handle its events.

On this link you can find a full example of the loaded Flash player with a coub video (note, that embedded in this way player starts automatically when the page is loaded):



When the player's SWF is loaded you can initialize handlers for several player's playback events.

When the player is loaded:

loader.content.addEventListener("onReady", function (e:Event) {
    trace('on ready');

When the video starts playing:

loader.content.addEventListener("onPlayStarted", function (e:Event) {
    trace('on play started');

When the video is paused:

loader.content.addEventListener("onPlayPaused", function (e:Event) {
    trace('on play paused');

When the video starts playing over again after it is finished:

loader.content.addEventListener("onLoopOccured", function (e:Event) {
    trace('on loop occured');

Also, loaded player's SWF contains dispathers for several player status events, so you can write corresponding listener functions:

  • onPlayerReady — the player is ready to play;
  • onPlayerError — the error occurs in the player;
  • onPlayerStateChange — the player status is changed;
  • onVideoPlaybackQualityChange — the video playback quality is changed.

onPlayerReady function receives Event.data object which contains the current player's API identifier:

public function onPlayerReady(event:Event):void {
    trace("test loader event");

onPlayerError function receives Event.data object which contains the error code:

public function onPlayerError(event:Event):void {
    trace("player error:", Object(event).data);

onPlayerStateChange function receives Event.data object which contains the updated status of the player:

public function onPlayerStateChange(event:Event):void {
    trace("player state:", Object(event).data);

onVideoPlaybackQualityChange function receives Event.data object which contains the updated quality of the coub video:

public function onVideoPlaybackQualityChange(event:Event):void {
    trace("video quality:", Object(event).data);