API

Control player behaviour with JavaScript

Access interface

Simply assign a new "CodoPlayer" instance to a variable.

To access API

<script src="CodoPlayer.js" type="text/javascript"></script>
<script>
    var player = CodoPlayer("video.mp4", {
        onReady: function(player) {
            console.log(player);  // API
        }
    })
    console.log(player); // API
</script>

Player API

Methods to control the player

player.play("video.mp4")
player.pause()
player.resize(400, 225)
player.destroy()

Media API

Methods to control the media and obtain clip information

player.media.play()
player.media.pause()
player.media.toggle()
player.media.isPlaying()
player.media.getCurrentTime()
player.media.setCurrentTime(20)
player.media.getDuration()
player.media.getVolume()
player.media.setVolume(80)
player.media.toggleFullScreen()
player.media.enterFullScreen()
player.media.exitFullScreen()
player.media.getParent()

Playlist API

Methods to control the playlist

player.playlist.set(mediaObj)
player.playlist.next(index)
player.playlist.getCurrentClip()

Event callbacks

Callbacks fired on certain event trigger

player.media.onBeforeLoad(function() {
    console.log("onBeforeLoad");
})
player.media.onLoad(function() {
    console.log("onLoad");
})
player.media.onMetaData(function(metaObj) {
    console.log("onMetaData");
})
player.media.onPlay(function(position) {
    console.log("onPlay: " + position);
})
player.media.onPause(function(position) {
    console.log("onPause: " + position);
})
player.media.onEnd(function() {
    console.log("onEnd");
})
player.media.onBuffer(function(buffer) {
    console.log("onBuffer: " + buffer);
})
player.media.onProgress(function(progress) {
    console.log("onProgress: " + progress);
})
player.media.onSeekStart(function(position) {
    console.log("onSeekStart: " + position);
})
player.media.onSeekEnd(function(position) {
    console.log("onSeekEnd: " + position);
})
player.media.onVolumeChange(function(newVol) {
    console.log("onVolumeChange: " + newVol);
})
player.media.onFullScreenEnter(function() {
    console.log("onFullScreenEnter");
})
player.media.onFullScreenExit(function() {
    console.log("onFullScreenExit");
})
player.media.onError(function() {
    console.log("onError");
})
player.media.onClipBegin(function() {
    console.log("onClipBegin");
})
player.media.onClipEnd(function() {
    console.log("onClipEnd");
})
player.media.onClipFirstQuarter(function() {
    console.log("onClipFirstQuarter");
})
player.media.onClipSecondQuarter(function() {
    console.log("onClipSecondQuarter");
})
player.media.onClipThirdQuarter(function() {
    console.log("onClipThirdQuarter");
})
player.media.onCuepoint(function() {
    console.log("onCuepoint");
})