<!-- Cinema8 Api -->
<script type="text/javascript" src="cinema8.player.api.min.js"></script>
var player = new Cinema8Player(SELECTOR, {
options,
events
}
Options
- id // Project id
width // default: 854px
height // default: 480px
style // default: ''
type // default: VIDEO (VIDEO, RAW_VIDEO)
autoplay // default: false
externalVideoUrl // hls(m3u8), mp4, flv, mp3 etc.
subtitle // (en, tr etc..)
defaultLang // audio track, default: 1 (audio track index. 1, 2, 3 etc.)
controls // Show/hide player controls, default: true
muted // Open video as muted , default :false
loop // restart video on end , default : false
campaignParams // default: null
(e.g. utm_source=ted&utm_medium=banner&utm_campaign=spring_sale&utm_id=554433)
time // Start a video at any specific time in seconds
authToken // authentication token
resumeLastPosition // Resume video from where you previously left off
(works only for authenticated users)
externalUser: {
name: "John",
surname: "Doe",
email: "john.doe@gmail.com",
},
Events
onReady
The event occurs when the browser starts playing the media (when it has buffered enough to begin)
onProgress
The event occurs when the browser is in the process of downloading the media data.
onPlay
The event occurs when the media has been started or is no longer paused
onPause
The event occurs when the media is paused either by the user or programmatically
onEnd
The onend event occurs when the video has reached the end
onCustomCallback
This event triggers if any widget/action within the video is calling
onCustomCallback action, it gets variables from the action
onWebhookResponse
This event triggers when a remote webhook response returns
onError
The event occurs when any error occurs at runtime
Functions
- player.play(); // Play the video
player.pause(); // Pause Video
player.duration(); //Returns the length of the current video, in seconds.
player.currentTime(); // Returns the current playback position in the video
player.currentTime(20); // Sets the current playback position in the video
player.paused(); //Returns whether the video is paused or not
player.volume(); // Returns the volume of the video
player.volume(0.5); // Sets the volume of the video
player.subtitles() // Returns the defined subtitles within video.
[
{
"value": "fr",
"label": "French"
},
{
"value": "en",
"label": "English"
}
]
player.subtitle() // en // returns selected subtitle in runtime
player.subtitle('fr') //changes the subtitle
- player.subtitle('off'); //Turns subtitles off
-
player.audioTracks(); // Lists available audio tracks within video.
[
{
"label": "English",
"value": "en"
},
{
"label": "Spanish",
"value": "es"
},
{
"label": "Commentary (eng)",
"value": "en"
}
]
player.audioTrack(); // Get active audio track at runtime
{label: 'English', value: 'en'}
player.audioTrack(1); // Change audio track
player.getVariables(); // Returns all available variables at runtime
player.setVariable(key, value, persistent); // dynamically set variable within video
//The persistent parameter is optional and the default value is false.
//If set to true, the variable value will be accessible(sticky variable) when the video stream
//continues from another video. (jump to another project).
player.getVariable("key"); // get variable value at runtime
player.setPlaybackRate(1.25); //Default: 1 (0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2)
player.loop() // Returns the current loop state of the player.
player.loop(false) // Sets the loop disabled
player.loop(true) // Sets the loop enabled
player.getAuthenticatedUser(); // Returns authenticated user if there is one, otherwise it returns null
player.launchFullscreen(); // Launch fullscreen
player.exitFullscreen(); // Exit fullscreen
player.hideControls(); // Hide player controls
player.showControls(); // Show player controls
player.qualityLevel(); // Returns current quality level of the video
player.qualityLevel(3); // Sets the quality level of the video to the given quality level
player.qualityLevel("auto"); // "auto" for Auto level
player.qualityLevels(); // Returns available quality levels if exist