Skip to content
English - United Kingdom
  • There are no suggestions because the search field is empty.

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

 
  1. <!-- 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.

  1. player.duration();

play()

Starts playing the video.

  1. player.play();

pause()

Pauses the currently playing video.

  1. player.pause();

paused()

Returns whether the video is paused or not.

  1. player.paused();

currentTime()

Sets or returns the current playback position in the video (in seconds).

  1. player.currentTime(); // Returns the current playback position in the video
  2. 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).

  1. player.volume(); // Returns the volume of the video
  2. player.volume(0.5); // Sets the volume of the video

subtitles()

Sets or returns current subtitles.

  1. player.subtitles(); // Returns the current subtitles
  2. player.subtitles("en"); // Sets the subtitles
  3. removeSubtitles() - Removes subtitles.

Events

Example

Example Code

 
  1. <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>