Javascript functions to control the player

The following functions can be used to control the player from javascript.
Before using any of these functions, please add the 'epplayer.js' file to the header of your HTML page:

<script src='js/ep_player.js' type='text/javascript'></script>

Important: If you want to test any of these Javascript functions on your local file system you should add this location to your Flash Player - Global Security Settings.

  • EP_isLoaded
  • EP_play
  • EP_pause
  • EP_stop
  • EP_playPause
  • EP_prev
  • EP_next
  • EP_setShuffle
  • EP_setRepeat
  • EP_setAutoPlay
  • EP_playTrack
  • EP_setVolume
  • EP_loadPlaylist
  • EP_clearPlaylist
  • EP_setPlaylist
  • EP_addTracks
  • EP_removeTracks
  • EP_getCurrentTrackData
  • EP_getTrackData


    EP_isLoaded(player);
    Returns true if the player is loaded and ready.

    parameters:

    player: the id of the player as string

    example:

    if(EP_isLoaded('ep_player1')) {
      // do something
    };


    EP_play(player);
    Tells the player to play.

    parameters:

    player: the id of the player as string

    example:

    EP_play('ep_player1');


    EP_pause(player);
    Tells the player to pause.

    parameters:

    player: the id of the player as string

    example:

    EP_pause('ep_player1');


    EP_stop(player);
    Tells the player to stop.

    parameters:

    player: the id of the player as string

    example:

    EP_stop('ep_player1');


    EP_playPause(player);
    Tells the player to toggle between play and pause.

    parameters:

    player: the id of the player as string

    example:

    EP_playPause('ep_player1');


    EP_prev(player);
    Tells the player to play the previous track in the playlist.

    parameters:

    player: the id of the player as string

    example:

    EP_prev('ep_player1');


    EP_next(player);
    Tells the player to play the next track in the playlist.

    parameters:

    player: the id of the player as string

    example:

    EP_next('ep_player1');


    EP_setShuffle(player, shuffle);
    Sets the shuffle mode.

    parameters:

    player: the id of the player as string
    shuffle: true / false

    example:

    EP_setShuffle('ep_player1', true);


    EP_setRepeat(player, repeat);
    Sets the repeat mode.

    parameters:

    player: the id of the player as string
    repeat: true / false

    example:

    EP_setRepeat('ep_player1', true);


    EP_setAutoPlay(player, autoplay);
    Sets the auto play mode.

    parameters:

    player: the id of the player as string
    autoplay: true / false

    example:

    EP_setAutoPlay('ep_player1', true);


    EP_playTrack(player, track);
    Tells the player to play a specific track from the playlist.

    parameters:

    player: the id of the player as string
    track: the index of the track in the playlist as integer

    example:

    EP_playTrack('ep_player1', 3);


    EP_setVolume(player, volume);
    Sets the volume of the player.

    parameters:

    player: the id of the player as string
    volume: the volume as integer (0..100)

    example:

    EP_setVolume('ep_player1', 75);


    EP_loadPlaylist(player, file);
    Tells the player to load a new playlist file.

    parameters:

    player: the id of the player as string
    file: the path and filename of the playlist file

    example:

    EP_loadPlaylist('ep_player1', 'playlist.xml');


    EP_clearPlaylist(player);
    Removes all tracks from the playlist.

    parameters:

    player: the id of the player as string

    example:

    EP_clearPlaylist('ep_player1');


    EP_setPlaylist(player, xml, play);
    Replaces the current playlist with the playlist that is given as XML string.

    parameters:

    player: the id of the player as string
    xml: playlist XML as string
    play: tells the player to start playing or not

    example:

    var playlist = '';
    playlist += '<track><location>track1.mp3</location><creator>E-Phonic</creator><title>Track 1</title></track>';
    playlist += '<track><location>track2.mp3</location><creator>E-Phonic</creator><title>Track 2</title></track>';

    EP_setPlaylist('ep_player1', playlist, true);


    EP_addTracks(player, xml, index);
    Adds tracks to a specific index in the playlist.

    parameters:

    player: the id of the player as string
    xml: playlist XML as string
    index: the index in the playlist where the new tracks should be inserted

    example:

    var playlist = '';
    playlist += '<track><location>track1.mp3</location><creator>E-Phonic</creator><title>Track 1</title></track>';
    playlist += '<track><location>track2.mp3</location><creator>E-Phonic</creator><title>Track 2</title></track>';

    EP_addTracks('ep_player1', playlist, 2);


    EP_removeTracks(player, indexes);
    Removes tracks from the playlist.

    parameters:

    player: the id of the player as string
    indexes the indexes of the tracks to be removed as array

    example:

    EP_removeTracks('ep_player1', [0, 2, 6]);


    EP_getCurrentTrackData(player);
    Returns an object containing the playlist data of the current track

    parameters:

    player: the id of the player as string

    example:

    var track = EP_getCurrentTrackData('ep_player1');
    alert(track.creator);
    alert(track.title);


    EP_getTrackData(player, index);
    Returns an object containing the playlist data of the specified track

    parameters:

    player: the id of the player as string
    index: the index in the track in the playlist

    example:

    var track = EP_getTrackData('ep_player1', 3);
    alert(track.creator);
    alert(track.title);


    Player event callback functions

    You can use these functions to be notified when certain events happen in the player. All you need to do is add the javascript functions to your HTML and the player will call them on the right events.
    The functions are optional and will only be called if they exist.
    The id of the player will be passed as parameter with every call.

  • EP_onLoad
  • EP_onPlay
  • EP_onPause
  • EP_onStop
  • EP_onPrev
  • EP_onNext


    EP_onLoad(player);
    Will be called by the player when it is loaded.

    parameters:

    player: the id of the player as string

    example:

    function onLoad(player) {
      alert(player + ' loaded');
    };


    EP_onPlay(player);
    Called when the player starts playing.

    parameters:

    player: the id of the player as string

    example:

    function EP_onPlay(player) {
      alert(player + ' playing');
    };


    EP_onPause(player);
    Called when the player is paused.

    parameters:

    player: the id of the player as string

    example:

    function EP_onPause(player) {
      alert(player + ' paused');
    };


    EP_onStop(player);
    Called when the player is stopped.

    parameters:

    player: the id of the player as string

    example:

    function EP_onStop(player) {
      alert(player + ' stopped');
    };


    EP_onPrev(player);
    Called when the player loads the previous item in the playlist.

    parameters:

    player: the id of the player as string

    example:

    function EP_onPrev(player) {
      alert(player + ' previous');
    };


    EP_onNext(player);
    Called when the player loads the next item in the playlist.

    parameters:

    player: the id of the player as string

    example:

    function EP_onNext(player) {
      alert(player + ' next');
    };