Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Flash Plugin API: Events

This document contains a list of ActionScript Events that the player broadcasts. Plugins may respond to these events by adding event listeners, using the player.addEventListener() method. For more information on building Flash plugins for the JW Player, see the Flash Plugin API Reference

If you're not creating a Flash plugin, you can still interact with the player by using the JavaScript API. Version 4 plugins may continue to use the Version 4 Plugin/JavaScript API.

CONTENTS

Player Events

All of the Player's events inherit from the PlayerEvent class, and so all of them contain the following properties:

PlayerEvent.JWPLAYER_ERROR
Fired when the player experiences an error, such as an error occurring during media playback. Properties set:
  • message (String): The error message
PlayerEvent.JWPLAYER_READY
Fired when the Player has completed its configuration phase, and is ready to begin playback.

Media Events

Media Events are fired as the media is being loaded, buffered and played.

MediaEvent.JWPLAYER_MEDIA_LOADED (jwplayerMediaLoaded)
Fired after the MediaSource has loaded an item into memory

NOTE: This event varies from the LOADED event defined in version 4. The JWPLAYER_MEDIA_LOADED event indicates that media has been loaded. The V4 LOADED event indicates that a portion of the content has been loaded into memory.

MediaEvent.JWPLAYER_MEDIA_BUFFER (jwplayerMediaBuffer)
Fired when a portion of the current media has been loaded into the buffer. Properties set:
  • bufferPercent (Number): Percent buffered, between 0 and 100.
MediaEvent.JWPLAYER_MEDIA_BUFFER_FULL (jwplayerMediaBufferFull)
Fired when a the buffer is full.
MediaEvent.JWPLAYER_MEDIA_TIME (jwplayerMediaTime)
Fired as the media plays. Properties set:
  • position (Number): Number of seconds elapsed since the start of the media playback.
  • duration (Number): Total number of seconds in the currently loaded media.
MediaEvent.JWPLAYER_MEDIA_SEEK (jwplayerMediaSeek)
Fired after a seek has been requested either by scrubbing the controlbar or through the API. Properties set:
  • position (Number): The position of the player before the player seeks (in seconds).
  • offset (Number): The requested position to seek to (in seconds).
MediaEvent.JWPLAYER_MEDIA_COMPLETE (jwplayerMediaComplete)
Fired when the currently playing media has completed playback.
MediaEvent.JWPLAYER_MEDIA_VOLUME (jwplayerMediaVolume)
Fired when the media's volume has changed. Properties set:
  • volume (Number): The new volume, between 0 and 100.
MediaEvent.JWPLAYER_MEDIA_MUTE (jwplayerMediaMute)
Fired when the sound is muted or unmuted. The current mute state is always available through the player.config.mute property. Parameters: Properties set:
  • mute (Boolean): The new mute state, either true or false.
MediaEvent.JWPLAYER_MEDIA_ERROR (jwplayerMediaError)
Fired if an error occurs in the course of media playback. Properties set:
  • message (String): The error message
MediaEvent.JWPLAYER_MEDIA_META (jwplayerMediaMeta)
Fired when metadata is retrieved by the MediaProvider. This can be a wide range of data, e.g. width, height or bitrate, embedded captions and images, RTMP status messages, cuepoints, id3 tags or RTMP bandwidth values. Metadata is sent as it is received from the server, so there are often several metadata events sent for each playback. If several metadata items arrive simultaneously, each is sent as a separate property of a single event.
MediaEvent.JWPLAYER_MEDIA_BEFOREPLAY (jwplayerMediaBeforePlay)
Fired just before the player begins playing. Unlike the PlayerStateEvent.JWPLAYER_PLAYER_STATE event, the player will be in the same state as before onBeforePlay is triggered. This event can be used to prevent playback from occurring by calling the stop() API method.

PlayerState events occur when the current media transitions from one state to another.

PlayerStateEvent.JWPLAYER_PLAYER_STATE (jwplayerPlayerState)
Fired when the media's state has changed from one value to another. Properties set:
  • newstate (String): The new state of the loaded media.
  • oldstate (String): The previous state.
    • Both newstate and oldstate must contain one of the following values:
      • IDLE
      • BUFFERING
      • PLAYING
      • PAUSED
    • (Note: the COMPLETED state that was available in the 4.x version of the player is deprecated. The player's state will now go from PLAYING directly to IDLE. Plugins can now listen for the MediaEvent.JWPLAYER_MEDIA_COMPLETE event instead.)

Playlist Events

The Playlist keeps a record of the loaded playlist items, and notifies listeners to changes in the state of the playlist.

PlaylistEvent.JWPLAYER_PLAYLIST_LOADED (jwplayerPlaylistLoaded)
Sent when a new playlist has been loaded into the player.
PlaylistEvent.JWPLAYER_PLAYLIST_UPDATED (jwplayerPlaylistUpdated)
Sent when a change has been made to the playlist structure, through an added or removed playlist item.
PlaylistEvent.JWPLAYER_PLAYLIST_ITEM (jwplayerPlaylistItem)
Sent when the current playlist item has changed.

View events

Here's an overview of all events the player sends when the user clicks on the player's components.

ViewEvent.JWPLAYER_VIEW_FULLSCREEN (jwplayerViewFullscreen)
Fired when the user wants to enter/leave fullscreen. This only works in actionscript, and only as a direct result of a mouseclick. The current fullscreen state is always available through the player.config.fullscreen property. Parameters:
  • data (Boolean): the new fullscreen state.
ViewEvent. JWPLAYER_VIEW_ITEM (jwplayerViewItem)
Fired when the user wants to play a specific PlaylistItem. The currently playing PlaylistItem is always available through the Player.playlist.currentItem. Parameters:
  • data (Number): the requested playlist index.
ViewEvent.JWPLAYER_VIEW_LOAD (jwplayerViewLoad)
Fired when the user wants to load a new file or playlist. Parameters:
  • data (String): this can be the url of either a single video/song or a playlist. The Controller will auto-detect this and start the file loading.
ViewEvent.JWPLAYER_VIEW_MUTE (jwplayerViewMute)
Fired when the user wants to mute/unmute the player. The current mute state is always available through the player.config.mute property. Parameters:
  • data (Boolean) {optional} : The new mute state. If omitted, the Controller will perform a toggle.
ViewEvent.JWPLAYER_VIEW_NEXT (jwplayerViewNext)
Fired when the user wants to play the next playlistitem. No parameters.
ViewEvent.JWPLAYER_VIEW_PAUSE (jwplayerViewPause)
Fired when the user wants to pause the player.
ViewEvent.JWPLAYER_VIEW_PLAY (jwplayerViewPlay)
Fired when the user wants to resume the player. Properties set:
ViewEvent.JWPLAYER_VIEW_PREV (jwplayerViewPrev)
Fired when the user wants to play the previous playlistitem.
ViewEvent.JWPLAYER_VIEW_REDRAW (jwplayerViewRedraw)
Fired when the user wants to issue a redraw of the canvas (e.g. after a resize or after showing/hiding the playlist).
ViewEvent.JWPLAYER_VIEW_SEEK (jwplayerViewSeek)
Fired when the user wants to seek in the current image/video/sound. Properties set:
  • data (Number): the new position in the file, in seconds. Two and a half minutes correspond to a position of 150.
ViewEvent.JWPLAYER_VIEW_STOP (jwplayerViewStop)
Fired when the user wants to stop loading and playing.
ViewEvent.JWPLAYER_VIEW_VOLUME (jwplayerViewVolume)
Fired when the user wants to change the playback volume. The current volume is always available through the player.config.volume property. Parameters:
  • data (Number): new volume percentage. Can be 0 to 100.

Component Events

Component Events are sent out when the player's components (controlbar, dock and display icons) are shown and hidden.

ComponentEvent.JWPLAYER_COMPONENT_SHOW (jwplayerComponentShow)
Fired when a player component becomes visible. Parameters:
  • component (IPlayerComponent): The player component being shown. Can be one of:
    • Controlbar: (IControlbarComponent),
    • Dock (IDockComponent) or
    • Display icon (IDisplayrComponent)
  • boundingRect (Rectangle): Contains the coordinates of the component, relative to the video display. If the component has been placed outside of the display (for example, if the controlbar is set to "bottom"), then the dimensions will be 0x0.
ComponentEvent.JWPLAYER_COMPONENT_HIDE (jwplayerComponentHide)
Fired when a player component becomes hidden. Parameters:
  • component (IPlayerComponent): The player component being hidden. Can be one of:
    • Controlbar: (IControlbarComponent),
    • Dock (IDockComponent) or
    • Display icon (IDisplayrComponent)
  • displayRect (Rectangle): Contains the coordinates of the component being hidden, relative to the video display. If the component has been placed outside of the display (for example, if the controlbar is set to "bottom"), then the dimensions will be 0x0.