The JW Player 5 Beta is considered to be pre-release software.  The documentation below can (and will) change to reflect ongoing development.

JW Player: Events

Internally, the player is split up into three central components; the Controller, the Model and the View. The Controller handles events sent by the user, Media or Playlist, the Model maintains the current state and the View manages all interfaces.

The Model and View contain components that send events, which plugins may respond to by adding event listeners through the player.addEventListener() method, which is part of the API. External scripts and Version 4 plugins may continue to use the Version 4 API. The API also offers the ability to execute Player commands (for example calling player.play() will cause the player to begin playback). The Player itself also broadcasts several events of interest.

Player Events

All of the Player's events inherit from this event type, and so all of them contain the following properties:

  • id (String): ID of the player in the HTML DOM. Used by javascript to reference the player.
  • client (String): A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).
  • version (String): A string representing the major version, minor version and revision number of the player (e.g. 5.0.300).
PlayerEvent.JWPLAYER_PLAYER_READY
Fired when the Player has completed its configuration phase, and is ready to begin playback.

Media Events

Media Events are fired by the currently playing MediaSource component.

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_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_ERROR (jwplayerMediaError)
Fired if an error occurs in the course of media playback. Properties set:
  • message (String): The error message

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_COMPLETED 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.

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

View events

Here's an overview of all events the View sends. Regardless of the event, the View always includes these three parameters:

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 fullscreen flashvar. Set properties:
  • state (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:
  • index (Number): the requested playlist index.
ViewEvent.JWPLAYER_VIEW_LOAD (jwPlayerViewLoad)
Fired when the user wants to load a new file or playlist. Parameters:
  • object (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 mute flashvar.Parameters:
  • state (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:
  • position (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 volume flashvar. Properties set:
  • volume (Number): new volume percentage. Can be 0 to 100.