Skip to content

kcivey/jquery.jwplayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Name

jQuery.JWPlayer - jQuery plugin for using JW Player

Usage

Constructor

$('#container').jwPlayer(options);

where options is an object containing various properties used in constructing the Flash player. Possible properties include

  • swf: the URL for the JW Player (defaults to "player.swf", so you'll almost certainly want to change it)
  • id: the id for the JW Player object (defaults to "jwPlayer")
  • height: height for JW Player object (treated as pixels if a number; defaults to 240)
  • width: width for JW Player object (treated as pixels if a number; defaults to 320)
  • playerready: function (or name of function) to be called when the player has loaded and is ready
  • flashvars: object containing flashvars for JW Player.

Other properties are used to set up listeners, with a value that can be either a function or the name of a function:

  • bufferlistener: sets up Model listener for BUFFER event
  • errorlistener: sets up Model listener for ERROR event
  • fullscreenlistener: sets up View listener for FULLSCREEN event
  • itemlistener: sets up Controller listener for ITEM event
  • linklistener: sets up View listener for LINK event
  • loadedlistener: sets up Model listener for LOADED event
  • loadlistener: sets up View listener for LOAD event
  • metalistener: sets up Model listener for META event
  • mutelistener: sets up Controller listener for MUTE event
  • nextlistener: sets up View listener for NEXT event
  • playlistener: sets up Controller listener for PLAY event
  • playlistlistener: sets up Controller listener for PLAYLIST event
  • prevlistener: sets up View listener for PREV event
  • redrawlistener: sets up View listener for REDRAW event
  • resizelistener: sets up Controller listener for RESIZE event
  • seeklistener: sets up Controller listener for SEEK event
  • statelistener: sets up Model listener for STATE event
  • stoplistener: sets up Controller listener for STOP event
  • timelistener: sets up Model listener for TIME event
  • volumelistener: sets up Controller listener for VOLUME event

The following will be recognized as flashvars and moved into the flashvars object if they occur directly in options -- so you can write {file: 'video.flv'} instead of {flashvars: {file: 'video.flv'}}:

  • author
  • autostart
  • backcolor
  • bufferlength
  • config
  • controlbar
  • date
  • debug
  • description
  • displaytitle
  • dock
  • duration
  • file
  • frontcolor
  • fullscreen
  • icons
  • image
  • item
  • lightcolor
  • mute
  • playerready
  • playlist
  • playlistfile
  • playlistsize
  • plugins
  • provider
  • repeat
  • screencolor
  • shuffle
  • skin
  • smoothing
  • start
  • streamer
  • stretching
  • tags
  • title
  • volume

Note that height and width are not included, because those are the names of properties for the Flash object. If you want to include height and width flashvars, you must include them in the flashvars sub-object.

get

$('#container').jwPlayer('get', property);

Get value of a property out of the jQuery.jwPlayer object data. Properties include

  • obj: the DOM object corresponding to the Flash object
  • duration: the duration of the media, in seconds
  • item: current playlist item (starting with 0) (may not be necessary, since .jwPlayer('getConfig', 'item') should give the same)
  • state: current playback state ((IDLE, BUFFERING, PLAYING, PAUSED, COMPLETED)
  • position: current position, in seconds
  • volume: current volume level, on scale of 0 to 100 (may not be necessary, since .jwPlayer('getConfig', 'volume') should give the same)

item

$('#container').jwPlayer('item', itemNumber);

Select an item from the playlist, with itemNumber starting from 0.

load

$('#container').jwPlayer('load', filename);

Load a new file or playlist.

mute

$('#container').jwPlayer('mute');

Toggle mute state (probably need to change to mute/unmute/toggleMute).

next

$('#container').jwPlayer('next');

Move to the next playlist item.

pause

$('#container').jwPlayer('pause');

Pause playing.

play

$('#container').jwPlayer('play');

Start playing from current position.

togglePlay

$('#container').jwPlayer('togglePlay');

If paused, start playing from current position. If playing, pause.

prev

$('#container').jwPlayer('prev');

Move to the previous playlist item.

redraw

$('#container').jwPlayer('redraw');

Redraw the player.

seek

$('#container').jwPlayer('seek', position);

Seek to a particular position in seconds. The plugin uses a state listener to handle seek commands sent when the player is not in a state in which it can do seeking.

stop

$('#container').jwPlayer('stop');

Stop playing and set state to IDLE and position to 0.

volume

$('#container').jwPlayer('volume', level);

Set the volume. Level is on a scale of 0 to 100.

getConfig

$('#container').jwPlayer('getConfig');
$('#container').jwPlayer('getConfig', property);

Get the config data (flashvars) -- either all of it as an object (if no argument is passed) or the value of one property (if the property name is passed).

getPlaylist

$('#container').jwPlayer('getPlaylist');
$('#container').jwPlayer('getPlaylist', itemNumber);

Get the playlist data as an array of objects (if no argument is passed) or as an object corresponding to a single playlist item (if itemNumber is passed). The item number is 0-based.

destroy

$('#container').jwPlayer('destroy');

Removes the Flash object from the container, along with the associated data.

Demo

See http://kcivey.github.com/jquery.jwplayer/demo.html.

Author

Keith C. Ivey, keith@iveys.org (written for Smokescreen LLC)

License

Copyright 2010, Smokescreen LLC. Dual licensed under the MIT and GPL licenses:

Releases

No releases published

Packages

No packages published