Cinema8 Javascript API
A Guide to Integrating Cinema8 Player Using the JavaScript API
This guide assists with integrating Cinema8 Player with your applications using the Cinema8 Player JavaScript API and Cinema8 Data API.
JavaScript API
This section explains the basics of how to use the Cinema8 Player JavaScript API component of Cinema8 Player. It uses the same interface for HTML5 versions of the player.
Setup
Download Cinema8 Player JavaScript API
Setup
<!-- Cinema8 API -->
<script type="text/javascript" src="cinema8.player.api.min.js"></script>
<script>
// Setup
var player = new Cinema8Player([selector], {
id: [VIDEO_ID],
host: [HOST],
width: [String],
height: [String],
raw: [boolean],
autoplay: [boolean],
subtitles: [String],
onready: function(){
console.log("onready fired");
},
onplay: function(){
console.log("onplay fired");
},
onpause: function(){
console.log("onpause fired");
},
onprogress: function(){
console.log("onprogress fired");
},
onend: function(){
console.log("onend fired");
}
});
</script>
Options Methods
duration
Returns the length of the current video, in seconds.
player.duration();
play()
Starts playing the video.
player.play();
pause()
Pauses the currently playing video.
player.pause();
paused()
Returns whether the video is paused or not.
player.paused();
currentTime()
Sets or returns the current playback position in the video (in seconds).
player.currentTime(); // Returns the current playback position in the video
player.currentTime(20); // Sets the current playback position in the video
volume()
Sets or returns the volume of the video (specifies the current volume of the video, between 0.0 and 1.0).
player.volume(); // Returns the volume of the video
player.volume(0.5); // Sets the volume of the video
subtitles()
Sets or returns current subtitles.
player.subtitles(); // Returns the current subtitles
player.subtitles("en"); // Sets the subtitles
removeSubtitles()
- Removes subtitles.
Events
Example
Example Code
<html>
<head></head>
<body>
<div id="video"></div>
<!-- Cinema8 Player API -->
<script type="text/javascript" src="cinema8.player.api.min.js"></script>
<script>
// Setup
var player = new Cinema8Player("#video", {
id: "YVX35oO4",
autoplay: false,
subtitles: "en",
onready: function(){
console.log("onready fired");
},
onplay: function(){
console.log("onplay fired");
},
onpause: function(){
console.log("onpause fired");
},
onprogress: function(){
console.log("onprogress fired");
},
onend: function(){
console.log("onend fired");
}
});
</script>
</body>
</html>