Flash Plugins API Reference

This page provides a reference of the Flash plugin API, intended for ActionScript plugin developers.

Introduction

At large, JavaScript and Flash plugins have the same structure and features. Two overall areas in which Flash differs are event listening and class definitions.

Listeners

A big general difference between JavaScript and Flash is that the latter uses a formal event dispatcher model to send out events. Listening to an event generally works like this:

private function volumeListener(event:MediaEvent) {
    var newVolume:Number = event.volume;
}
player.addEventListener(MediaEvent.JWPLAYER_MEDIA_VOLUME, volumeListener);

JW6 defines four types of events:

MediaEvent
This event is dispatched for all media playback changes (like time ticks or volume updates).
PlayerEvent
This event is only dispatched on page load, when the player is set up and ready to play.
PlaylistEvent
This event dispatched on playlist updates, e.g. loading of a list or completion of playback.
PlayerStateEvent
This event is only dispatched when the player state changes between IDLE, BUFFERING, PLAYING and PAUSED.
ViewEvent
This event is dispatched when the display is clicked or the controls are enabled/disabled.

The Mapping section below includes the event type for all API calls.

Classes

Since ActionScript is a strongly typed language, plugins must import all JW6 classes they use. Here is a list of all packages plugins can import and the classes they contain:

com.longtailvideo.jwplayer.plugins.IPlugin6
This class defines the interface of a JW6 plugin. Every plugin must import and implement it.
com.longtailvideo.jwplayer.player.IPlayer
This class defines the JW Player API. Since it's a property of the required initPlugin() API call, every plugin must import it.
com.longtailvideo.jwplayer.player.PlayerState
This class defines the four player states (IDLE, BUFFERING, PLAYING and PAUSED). Use it when implementing logic around player states (e.g. doing something when the player pauses).
com.longtailvideo.jwplayer.events.*
This package contains the media, player, playlist, state and view event definitions (see above sub-section). Include it when listening to any type of player event in your plugin.

For compiling, this JW6 plugin SDK includes the jwplayer6.swc library, containing all class definitions. See Building Flash Plugins for more info.

Mapping

Flash plugins leverage the same API calls as JavaScript plugins or standalone scripts. Due to ActionScript/JavaScript differences and backward compatibility concerns, the APIs do not 100% translate though. Therefore, this section lists all JW6 API calls, mapping how they differ between JavaScript and Flash.

Ready API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getRenderingMode-The mode is always flash in Flash ;)
onReadyPlayerEvent.JWPLAYER_READY-

Playlist API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getPlaylistplaylistThis is a getter that returns the playlist
getPlaylistItemplaylist.currentItem
playlist.getItemAt
Separate calls upon the playlist object.
loadload-
playlistItemplaylistIndex-
onPlaylistPlaylistEvent.JWPLAYER_PLAYLIST_LOADED-
onPlaylistItemPlaylistEvent.JWPLAYER_PLAYLIST_ITEM-
onCompleteMediaEvent.JWPLAYER_MEDIA_COMPLETE-
onPlaylistCompletePlaylistEvent.JWPLAYER_PLAYLIST_COMPLETE-

Buffer API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getBuffer-Only available through the event
onBufferChangeMediaEvent.JWPLAYER_MEDIA_BUFFER-

Playback API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getStateconfig.stateThis is a getter on the player config
play play-
pausepause-
stopstop-
onBeforePlayMediaEvent.JWPLAYER_MEDIA_BEFOREPLAY-
onPlayPlayerStateEvent.JWPLAYER_PLAYER_STATEThere's a newstate event property
onPausePlayerStateEvent.JWPLAYER_PLAYER_STATEThere's a newstate event property
onBufferPlayerStateEvent.JWPLAYER_PLAYER_STATEThere's a newstate event property
onIdlePlayerStateEvent.JWPLAYER_PLAYER_STATEThere's a newstate event property

Seek API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getPosition-Only available through the event
getDuration-Only available through the event
seekseek-
onSeekMediaEvent.JWPLAYER_MEDIA_SEEK-
onTimeMediaEvent.JWPLAYER_MEDIA_TIME-

Volume API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getMuteconfig.muteThis is a getter on the player config
getVolumeconfig.volumeThis is a getter on the player config
mutemute-
volumevolume-
onMuteMediaEvent.JWPLAYER_MEDIA_MUTE-
onVolumeMediaEvent.JWPLAYER_MEDIA_VOLUME-

Resize API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getWidthconfig.widthThis is a getter on the player config
getHeightconfig.heightThis is a getter on the player config
getFullscreenconfig.fullscreen-
resize-plugins cannot resize player
onFullscreen-plugins have an inline resize()
onResize-plugins have an inline resize()

Quality API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getQualityLevelsgetQualityLevels-
getCurrentQualitygetCurrentQuality-
setCurrentQualitysetCurrentQuality-
onQualityLevelsMediaEvent.JWPLAYER_MEDIA_LEVELS-
onQualityChangeMediaEvent.JWPLAYER_MEDIA_LEVEL_CHANGED-

Button API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
addButtoncontrols.dock.addButtonThis is for compatibility purposes
removeButtoncontrols.dock.removeButtonThis is for compatibility purposes

Controls API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
getControlsgetControls-
getSafeRegiongetSafeRegion-
setControlssetControls-
onControlsViewEvent.JWPLAYER_CONTROLS-
onDisplayClickViewEvent.JWPLAYER_VIEW_CLICK-

Error API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
onErrorMediaEvent.JWPLAYER_MEDIA_ERROR-

Metadata API

See the JavaScript API Reference for details on these API calls.

JavaScriptFlashComments
onMetaMediaEvent.JWPLAYER_MEDIA_META-