Table of Contents

MediaPlaylist

This object allows you to play media files.

Functions

MediaPlaylist

Constructor function.

Syntax

var myObject = new MediaPlaylist();

Methods

setPlaybackRate

Sets the playback rate.

Syntax

myObject.setPlaybackRate(rate);

Arguments

  1. rate - (float) the playback rate

Returns

setVolume

Sets the volume.

Syntax

myObject.setVolume(volume);

Arguments

  1. volume - (float) the volume

Returns

setPosition

Sets the position of the current playing item.

Syntax

myObject.setPosition(position);

Arguments

  1. position - (integer) the position in milliseconds

Returns

setMuted

Mutes or unmutes the current playing media.

Syntax

myObject.setMuted(muted);

Arguments

  1. muted - (boolean) the media's muted status

Returns

duration

Returns the duration of the current media.

Syntax

myObject.duration();

Returns

hasAudio

Returns true if the current media has audio.

Syntax

myObject.hasAudio();

Returns

hasVideo

Returns true if the current media has video.

Syntax

myObject.hasVideo();

Returns

playbackRate

Returns the current playback rate.

Syntax

myObject.playbackRate();

Returns

volume

Returns the current volume.

Syntax

myObject.volume();

Returns

position

Returns the current position.

Syntax

myObject.position();

Returns

isMuted

Returns true if the current media is muted.

Syntax

myObject.isMuted();

Returns

isSeekable

Returns true if the current media is seekable. Seekable means that you can seek to a specific position to play.

Syntax

myObject.isSeekable();

Returns

bufferStatus

Returns the percentage of filled buffer.

Syntax

myObject.bufferStatus();

Returns

play

Begins playing the playlist.

Syntax

myObject.play();

Returns

pause

Pauses the playing.

Syntax

myObject.pause();

Returns

stop

Stops the playing.

Syntax

myObject.stop();

Returns

addLocalMedia

Adds a local media to the playlist.

Syntax

myObject.addLocalMedia(path);

Arguments

  1. path - (string) the local media to add

Returns

Exceptions

addDistantMedia

Adds a distant media to the playlist.

Syntax

myObject.addDistantMedia(url);

Arguments

  1. url - (string) the distant media to add

Returns

Exceptions

insertLocalMedia

Inserts a local media to the playlist.

Syntax

myObject.insertLocalMedia(position, path);

Arguments

  1. position - (integer) the position where to insert the media
  2. path - (string) the local media to insert

Returns

Exceptions

insertDistantMedia

Inserts a distant media to the playlist.

Syntax

myObject.insertDistantMedia(position, path);

Arguments

  1. position - (integer) the position where to insert the media
  2. path - (string) the distant media to insert

Returns

Exceptions

clear

Clears the playlist contents.

Syntax

myObject.clear();

Returns

Exceptions

next

Plays the next playlist item.

Syntax

myObject.next();

Returns

previous

Plays the previous playlist item.

Syntax

myObject.previous();

Returns

setCurrentMedia

Sets the current media to play.

Syntax

myObject.setCurrentMedia(mediaIndex);

Arguments

  1. mediaIndex - (integer) the media index

Returns

shuffle

Shuffles randomly the playlist.

Syntax

myObject.shuffle();

Returns

setPlaybackMode

Sets the playback mode.

Syntax

myObject.setPlaybackMode(playbackMode);

Arguments

  1. playbackMode - (PlaybackMode) the playback mode

Returns

removeMedia

Removes a media from the list.

Syntax

myObject.removeMedia(mediaIndex);

Arguments

  1. mediaIndex - (integer) the media index

Returns

Exceptions

currentMedia

Returns the current playing media index.

Syntax

myObject.currentMedia();

Returns

isEmpty

Returns true if the playlist is empty.

Syntax

myObject.isEmpty();

Returns

mediaCount

Returns the playlist size.

Syntax

myObject.mediaCount();

Returns

nextMedia

Returns the next media index.

Syntax

myObject.nextMedia();

Returns

previousMedia

Returns the previous media index.

Syntax

myObject.previousMedia();

Returns

playbackMode

Returns the playback mode.

Syntax

myObject.playbackMode();

Returns

Attributes

playbackRate

The playback rate. (float)

volume

The volume. (float)

position

The position in milliseconds. (integer)

muted

If the media is muted. (boolean)

currentMedia

The current media index. (integer)

playbackMode

The playback mode. (PlaybackMode)

Enumerations

PlaybackMode

The playback mode.

Values

  1. CurrentItemOnce: the current item is played only one
  2. CurrentItemInLoop: the current item is played in the loop
  3. Sequential: playback starts from the first to the last items and stops
  4. Loop: playback restarts at the first item after the last has finished playing
  5. Random: plays items in random order