Skip to content
Augustin Roux edited this page Jul 3, 2015 · 1 revision

play

Plays a content or channel.

// Channel content
R7('play', { channelId }, callback)
R7('play', { channelNumber }, callback)

// Video content streaming
R7('play', { uri, [position], [resumePlaying], [fileSystem], [metadata] }, callback)

To play a channel:

  • channel or channelNumber Channel with the given channelNumber
  • channelId Channel with the given channelId

To play a video content:

  • uri An uri that the player would play.
  • [position] The position in milliseconds at which the video will be started.
  • [resumePlaying] If true and the content is read from file system, the player will try to resume the position to the previously known stop position.
  • [fileSystem] If true will ensure that the content you will play will be read from the file system as a PDL or Record
  • [metadata] Custom content attributes for the content.
    • see the program's metadata page for program's metadata
    • duration in milliseconds is mandatory to have a valid timeline inside the player.
    • mpeg2ts as a boolean is required for MPEG2TS contents to make the position option to work.
    • totalSize in bytes is required for MPEG2TS contents to make the position option work.

stop

Stops the currently playing.

R7('stop', callback);

resume

Change the speed of the content (default: 1). Also used to resume paused content.

// General function. speed is a number and not mandatory
R7('resume', speed, callback)

// Play a paused content
R7('resume', callback)

// Play at 2* normal speed
R7('resume', 2, callback)

// Play at 0.5* normal speed
R7('resume', 0.5, callback)

pause

Pause the playing content. Equivalent to resume with speed at 0.

R7('pause', callback)

getPlayer

Returns the player metadata. New : return the available subtitles and audiotracks. Live is now updated and delivers all informations needed

R7('getPlayer', callback)
{
  "metadata": {
    "channelId": 9104,
    "uri": "null://",
    "channelNumber": 99
  },
  "uri": "null://",
  "parentalMaxRating": 8,
  "status": "stopped"
}
  • status State of the player: 'paused', 'playing' or 'stopped'

getPlayerProgress

Returns the player progression information.

R7('getPlayerProgress', callback)
{
    "buffer": 37.316269841269836,
    "duration": 252000,
    "position": 37.316269841269836,
    "relative": 94037,
    "type": "video"
}
  • relative position of the player
  • duration duration of the content (passed in play arguments)
  • position position of the player in percent

getPlayerAudioTracks

Returns the list of available player's audio tracks.

R7('getPlayerAudioTracks', callback)
[
  {
    "active":             false,
    "AudioPid":           "230",
    "AudioLang":          "fra",
    "AudioComponentTag":  "0",
    "AudioCodec":         "eac3",
    "AudioLangType":      "0",
    "languageInFrench":   "français"
  }
]
  • active True if player's audio track is current
  • AudioPid Audio Packet Identifier of the track
  • AudioLang Audio Language descriptor
  • languageInFrench French name of the audio track

setPlayerAudioTrack

Sets a selected audio track as the active audio track of the player.

R7('setPlayerAudioTrack', audiotrack, callback)
  • audiotrack: Hash description of the audio track. See getPlayerAudioTracks.

getVideoFrame

Returns video frame coordinates (available since webapp version 1.11.2).

R7('getVideoFrame', callback)
  • x left position of the current video frame in pixels
  • y top position of the current video frame in pixels
  • width current width of the video frame in pixels
  • height current height of the video frame in pixels

setVideoFrame

Sets video frame coordinates (available since webapp version 1.11.2).

R7('setVideoFrame', coord, callback)
  • x left position of the current video frame in pixels
  • y top position of the current video frame in pixels
  • width current width of the video frame in pixels
  • height current height of the video frame in pixels

setFullScreen

Restores video frame to FULL SCREEN (available since webapp version 1.11.2).

R7('restoreVideoFrame', callback)

Examples

// Simple content without license
R7('play', {
  uri: 'http://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_surround-fix.avi',
  metadata: {
    duration: 600000, // in milliseconds,
    titleLbl: 'Big Buck Bunny'
  }
}, callback);
// MPEG2TS content with a seek at 10 seconds before play
R7('play', {
  uri: 'http://baz.quz/video.ts',
  position: 10e3 // in milliseconds
  metadata: {
    mpeg2ts: true,
    duration: 600e3, // in milliseconds
    totalSize: 30e6, // in bytes
  }
}, callback)
// Content played from filesystem after download
R7('download', { extId: 123, catalog: 'cplusald' }, function(err, vod) {
  if (err) {
    return console.error(err);
  }
  R7('play', { uri: vod.uri, fileSystem: true } function(err, pdl) {
    if (err) {
      console.error(err);
    } else {
      console.log(pdl);
    }
  });
});
// Stop and Play
R7('stop', function(err) {
  if (err) { return; }
  R7('play', { uri: 'http://...' }, callback);
});
R7('getPlayerAudioTracks', function(err, audiotracks) {
  var eng = _.where(audiotracks, function(at) {
    return at.AudioLang === 'eng';
  });
  if (!err && eng) {
    R7('setPlayerAudioTrack', eng);
  }
});
var width, height;
R7('getVideoFrame', function(err, data) {
  if (!err & data) {
    width = data.witdh;
    height = data.height;

    R7('setVideoFrame',  {
      x: width * 0.25,
      y: height * 0.25,
      width: width * 0.5,
      height: height * 0.5,
    });
  }
});