Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 2.6 KB

API.md

File metadata and controls

67 lines (46 loc) · 2.6 KB
## Player API

Create an instance:

var player = new Clappr.Player({source: "http://your.video/here.mp4", parentId: "#player"});

player.attachTo(element);

You can use this method to attach the player to a given element. You don't need to do this when you specify it during the player instantiation passing the parentId param.

player.play();

Plays the current source.

player.pause();

Pauses the current source.

player.stop();

Stops the current source.

player.seek(value);

The value should be a number between 0 and 100. For example, player.seek(50) will seek to the middle of the current source.

player.setVolume(value);

The value should be a number between 0 and 100, 0 being mute and 100 the max volume.

player.mute();

Mute the current source.

player.unmute();

Unmute the current source.

player.isPlaying();

Returns true if the current source is playing, otherwise returns false.

player.getPlugin(pluginName);

Returns the plugin instance. Example:

var poster = player.getPlugin('poster');
poster.hidePlayButton();

This search the Core and Container plugins by name, and returns the first one found.

player.getCurrentTime();

Returns the current time(in seconds) of the current source.

player.getDuration();

Returns the duration(in seconds) of the current source.

player.resize(size);

Resizes the current player canvas. The size parameter should be a literal object with height and width. Example:

player.resize({height: 360, width: 640});

player.destroy();

Destroy the current player and removes it from the DOM.

player.load(source);

Loads a new source.