How to Use the Cincopa Player API
The Cincopa Player API allows you to control various aspects of your video player, such as play, pause, fullscreen, subtitle selection, and chapter navigation. This API is designed to work with all players and templates.
For additional support, feel free to contact us at support@cincopa.com.
Player API Functions
The following functions can be used to control the Cincopa player:
Function | Description |
---|---|
goTo(index, callback) | Jumps to a specific video by index or asset ID. Calls callback after action. |
play() | Starts the video playback. |
pause() | Pauses the video playback. |
setCurrentTime(time) | Sets the current playback time to the specified time in seconds. |
videoTrim(start, end) | Trims the video playback to the specified start and end times. |
duration() | Returns the total duration of the video in seconds. |
currentTime() | Returns the current playback time in seconds. |
isPaused() | Returns true if the video is paused, otherwise false . |
playlistAppend(asset) | Adds a video to the current playlist. Use get_asset_meta for adding asset . |
playlistRemove(index) | Removes a video from the playlist by index or asset ID. |
enterFullScreen() | Enters fullscreen mode. |
exitFullScreen() | Exits fullscreen mode. |
isFullScreen() | Returns true if the player is in fullscreen mode. |
playNext() | Plays the next video in the playlist. |
playPrev() | Plays the previous video in the playlist. |
setVolume(level) | Sets the volume level (0-100). |
stopVideo() | Stops video playback. |
getPlayerContainer() | Returns the container element for the player. |
getLayersContainer() | Returns the container element for layers. |
getControlsContainer() | Returns the container element for controls. |
getVideoElement() | Returns the actual video element. |
getCurrentPlayingUrl() | Returns the URL of the currently playing video. |
hideControls() | Hides the player controls. |
showControls() | Shows the player controls. |
addLayer(name, html) | Adds an overlay layer to the player. |
removeLayer(name) | Removes a specified layer by name . |
getLayer(name) | Retrieves a specific layer by name . |
getPlaylistItems() | Returns all items in the current playlist. |
toggleMute(command) | Mutes (mute ) or unmutes (unmute ) the player. |
subtitleToggle(command) | Enables (on ) or disables (off ) subtitles. |
selectSubtitle(language) | Selects a subtitle language (e.g., none , en , es ). |
goToChapter(index) | Jumps to a specific chapter in the video. |
getCurrentChapter() | Returns the index of the current chapter being played. |
playCurrent() | Plays the currently selected video. |
playbackSpeed(speed) | Sets playback speed (e.g., 1.0 for normal speed, 1.5 for 1.5x speed). |
Example Usage
Below is an example demonstrating how to use the Cincopa Player API to control the video player:
<script src="https://rtcdn.cincopa.com/libasync.js" type="text/javascript"></script>
<div class="button-block">
<button onclick="playVideo()">Play</button>
<button onclick="pauseVideo()">Pause</button>
<button onclick="jumpToSec('forward')">Jump +10sec</button>
<button onclick="jumpToSec('backward')">Jump -10sec</button>
<button onclick="toggleMute('mute')">Mute</button>
<button onclick="toggleMute('unmute')">Unmute</button>
<button onclick="enterFullScreen()">Fullscreen in</button>
<button onclick="exitFullScreen()">Fullscreen out</button>
</div>
<div id="playerID">...</div>
<script type="text/javascript">
function playerAPI() {
var galleryWrapID = 'playerID';
if (cincopa && cincopa.getGalleryById(galleryWrapID) && cincopa.getGalleryById(galleryWrapID).playerAPI) {
return cincopa.getGalleryById(galleryWrapID).playerAPI;
} else {
return false;
}
}
function playVideo() {
var player = playerAPI();
if (player) {
player.play();
}
}
function pauseVideo() {
var player = playerAPI();
if (player) {
player.pause();
}
}
function jumpToSec(direction) {
var player = playerAPI();
if (player) {
var currentTime = player.currentTime();
player.setCurrentTime(direction === 'forward' ? currentTime + 10 : currentTime - 10);
}
}
function toggleMute(command) {
var player = playerAPI();
if (player) {
player.toggleMute(command);
}
}
function enterFullScreen() {
var player = playerAPI();
if (player) {
player.enterFullScreen();
}
}
function exitFullScreen() {
var player = playerAPI();
if (player) {
player.exitFullScreen();
}
}
</script>