Deprecated player's methods and events (Legacy)

Deprecated player's methods and events (Legacy)

 The following article contains legacy Player's method. If you are starting a new implementation we recommend you to use the latest version of te Player's API. Learn How to interact with THRON's Player.

 

 

NV4ME.player.api contains several functions that can be used to interact with the player. 

A single entry point is defined:

NV4ME.player.api.call(node, methodName, ...arguments)

 

Input:

  • node: container (div or iframe) id of the player you want to manage.
  • methodName: the name of the method you want to call. Available methods are described below.
  • target method arguments

Output:

  • A promise (see this) that returns a "done" method which receives a callback as a parameter, such callback will be invoked at the end of the execution and will have as parameter an object containing the values illustrated in each specific method.

 

Note: If you want to use JS API with an iframe embed a new JS script is required: 

[code]http://[clientId]-cdn.thron.com/shared/player/current/scripts/iframe-min.js[/code]

Classic embed doesn’t need other scripts.

Example:

[code]<html>
   <head>
      <script type="text/javascript" src="http://[clientId]-cdn.thron.com/shared/player/current/scripts/iframe-min.js"></script>
   </head>
   <body>
      <iframe id="iframeid" width="720" height="400"
         src="//[clientId]-cdn.thron.com/shared/player/current/embed/[contentId]/[pkey]" frameborder="0" allowfullscreen></iframe>
      <script type="text/javascript">
         NV4ME.player.api.call("iframeid", 'getStatus').done(function(result) {
         
         console.log(result);
         
         });
         
         NV4ME.player.api.call("iframeid", 'setVolume', 0.7);
         
      </script>
   </body>
</html>[/code]

 

Methods

playlistBack

If the content is a playlist, ask the player to skip back to the previous content, if any.

  • Arguments: No input parameters.
  • Output: No return from this function.

playlistForward

If the content is a playlist, ask player to skip forward to the next content, if any.

  • Arguments: No input parameters.
  • Output: No return from this function.

getEmbedCodeString

Returns a string containing the html code for embedding the player.

  • Arguments: node: container (div or iframe) id of the player you want to manage.
    • embedType : a string that specify the embed type. The only accepted value at this time is “SCRIPT”.
  • Output: A promise that returns a "done" method which receives a callback as a parameter, such callback will be invoked at the end of the execution and will have as parameter an object containing a string which is the the html code for embedding the player.

getInterfaceLang

Returns the interface language

  • Arguments: No input parameters.
  • Output: A promise that returns a "done" method which receives a callback as a parameter, such callback will be invoked at the end of the execution and will have as parameter the interface language.

resize

Refresh the player and resize it within its container (div or iframe).

  • Arguments: No input parameters.
  • Output: No return from this function.

getStatus

Returns the current status of the player

  • Arguments: No input parameters.
  • Output: A promise that returns a "done" method which receives a callback as a parameter, such callback will be invoked at the end of the execution and will have as parameter an object containing the following values:
    • playing:Boolean true if the player is either currently playing or it is paused;
    • volume:Number value between 0 and 1 that represents the current volume level;
    • ready:Boolean true if the player has successfully loaded a content;
    • Status:String the status of the player (playing, buffering, etc);
    • Ts:Number the actual play time
    • Duration:Number the duration of the media
    • canSeek:Boolean true if the player can seek

play

Starts to play the content (or resumes a paused content).

  • Arguments: No input parameters.
  • Output: No return from this function.

pause

Pauses the content currently being played.

  • Arguments: No input parameters.
  • Output: No return from this function.

setScreenMode

Asks player to change screenMode. Currently you can only exit from fullscreen mode asking for “normalScreen”.

  • Arguments: “normalScreen” String to exit from full screen mode.
  • Output: No return from this function.
  • Note: this function is only available for the flash player

seekTime

Seeks the content currently being played:

  • Arguments: The Number of seconds to seek to.
  • Output: No return from this function.

setVolume

Changes the current volume.

  • Arguments: A Number value between 0 and 1 (0=mute, 1=max).
  • Output: No return from this function.

getSubtitlesList

Retrieves the subtitles list for the current content (if any).

  • Arguments: No input parameters.
  • Output: A promise that returns a "done" method which receives a callback as a parameter, such callback will be invoked at the end of the execution and will have as parameter an object containing a string which is the JSON representation for an object with this structure:

{status:String, subtitles:Array}

The status field contains one of the following values:

  • NOT_YET_LOADED: the player hasn’t loaded the subtitles for this content yet
  • OK: the content has been scanned and the subtitles (if present) have been downloaded
  • EXCEPTION: a problem has occurred while fetching the subtitles; they will not be downloaded again for this content.

The subtitles array will contain a series of objects in this form:

{start:Number, end:Number, duration:Number, text:String}

And this is the meaning of the fields:

  • start: this is the starting time for this subtitle (in seconds from the beginning)
  • end: the ending time for this subtitle (in seconds from the beginning)
  • duration: the number of seconds that the subtitle should last (end-start)
  • text: the string that should be displayed

Note: this function is only available for the flash player

changeThumbnail

Changes the current thumbnail.

  • Arguments: A String value with the URL of the image. Please pay attention to Crossdomain policies
  • Output: No return from this function.

NOTE: this function is only available for the flash player

loginAs

It connects the device in use to a new contact, providing a specific identity.

  • Arguments:
    • loginType: String; it is the type of identity provided, you can use a free text here (e.g.: "e-mail") but remember to keep coherence in the name (please note that "thronuser" is a reserved key used to identify THRON usernames)
    • loginValue: String; it is the value of the identity provided (e.g. the e-mail address)
    • contactName: String, it is the full name of the new contact.
  • Output: No response from this function.

 

Listen Player events

For a better integration with THRON Player sometimes can be useful to listen player events to perform custom actions.

A similar entry point is also available for player event management:

NV4ME.player.api.on(eventName, node, handler, context)

Input:

  • eventName: the name of the event you want to listen. Available events are described below.
  • node: container (div or iframe) id of the player that you want to manage.
  • handler: a function to execute each time the event is triggered.
  • context: the JavaScript context of the handler function. This is an optional parameter.

Output: No return for this function

Note: if you want to use JS API with an iframe embed a new JS script is required:

[code]http://[clientId]-cdn.thron.com/shared/player/current/scripts/iframe-min.js[/code]

Classic embed doesn’t need other scripts.

Example:

[code]<html>
   <head>
      <script type="text/javascript" src="http://[clientId]-cdn.thron.com/shared/player/current/scripts/iframe-min.js"></script>
   </head>
   <body>
      <iframe id="iframeid" width="720" height="400"
         src="//[clientId]-cdn.thron.com/shared/player/current/embed/[clientId]/[contentId]/[pkey]" frameborder="0" allowfullscreen></iframe>
      <script type="text/javascript">
         NV4ME.player.api.on("metadata", "iframeid", function(result) {
         
         console.log("Metadata received:", result);
         
         });
         
      </script>
   </body>
</html>[/code]

 


Methods 

fp_update

Notifies that an update of Flash Player is required or an installation is needed.

  • Data: No additional data for this event.

metadata

Fired when the player receives content medatada.

  • Data: an object (“key/value” pair collection) containing the content metadata.

content_complete

Fired when the playback of the current content is completed.

  • Data: content URL.

wake_up

Fired when the player initialization is completed.

  • Data: No additional data for this event.
  • Note: this function is only available for the flash player

start_adv

Fired when an advertisement has just started.

  • Data:
    • adType (a string value): the type of the advertisement (PREROLL or POSTROLL);
    • descriptorContent (a string value): the content of a VAST XML descriptor. This is an optional param.

complete_adv

Fired when an advertisement playback has completed.

  • Data: the type of the advertisement (PREROLL or POSTROLL).

stream_switch

Fired during a live event when the stream in input has switched.

  • Data:
    • streamIndex (an integer value): the index of the current stream;
    • bitrate (an integer value): the current bitrate for the stream as read from the descriptor (in bits per second).

connection_test

If the content is in streaming and being served by a Flash Media Server, the player notifies the browser that a new connection attempt has been started, or that the connection has been instantiated; this method also shows the protocol and the port being tested or established.

  • Data:
    • status: a string explaining the current status; may be one of:
      • CONNECTTIMEOUT: the connection tests have failed;
      • STREAMINGCONNECTIONERROR: a connection has been established, but a problem has occurred while receiving the content;
      • CONNECTIONTEST: the player is currently testing a specific protocol and port;
      • CONNECTIONPROTOCOLANDPORT: the player has chosen a specific protocol / port pair.
    • args: a string adding more details about the current condition (for example, if status is CONNECTIONTEST, the args string shows the current pair of protocol and port being tested, like “RTMP/1935”.

play_state

Fired on play/pause when player play state change.

  • Data: true if player is playing.

content_visited

Fired when an audio or video starts.

  • Data: An object containing:
    • contentId: the id of the content
    • title: the title of the content
    • poster: the path of the thumbnail
    • duration: the duration of the content (ms)
    • kind: the type of the content (audio-video)
    • category: the category path of the content (id)

error

Fired when player initialization fail.

  • Data: The error code String. Supported values are:
    • unsupportedDevice”: The device doesn’t support both flash player and HTML5. We recommend to install or update Flash Player.
    • live_error”: Live event isn’t started yet.
    • liveAndIe10Metro”: It isn’t possible to play a live event on IE10 Metro mode.
    • video_not_found”: This device can’t play the specific content (HTML5 player only).
    • “content_not_found”: The content has been deleted or the user do not have sufficient rights to access it.
    • unavailable_channel_type”: The content has no playable channels available for this device.
Was this article helpful?
0 out of 0 found this helpful

Have more questions?

SUBMIT A REQUEST

Hai altre domande?

INOLTRA UNA RICHIESTA

Comments