Loading Player V3 for Cross-Device Resume

Important: Ooyala Player V3 is deprecated and is scheduled to be disabled on 2018-01-31. After that date, Player V3 will no longer play your video or audio content. Customers still using Player V3 need to migrate to Player V4 (see Migrating from Player V3 and Player Migration FAQ).
Ooyala supports the ability to start video content on one device and resume it on another. For the full Cross-Device Resume experience, you need to do the following:
  1. Load the player for your specific provider account (your account needs to have a unique identifier). This saves the position of the last playback on the Cross-Device Resume servers.
  2. When loading a player for your specific provider account, check if the viewer has already partially watched the movie. If so, you need to programmatically seek or fast-forward to the appropriate position.

This API is REST-based, and requires that you sign all of your requests as described in General Algorithm for Signing Requests.

Loading the Player Library

Load the Player v3 library as you usually would. When you create a player in the option hash you should pass in an embed token that will contain the account id. For example:

<script src="http://player.ooyala.com/v3/PLAYER_BRANDING_ID"></script>
      

Example: Loading a Player for a Specific User

The following code demonstrates how to load a player for a typical user we call Alice. It will save Alice’'s position in the asset on the Cross-Device Resume servers.
Note: For more information about the generate_signature function see the General Algorithm for Signing Requests.
 
OO.Player.create('playerwrapper','<%= params[:embed_code] %>', {
  embedToken: "<%= signed_embed_code_url %>"
});


`signed_embed_code_url` is the following url that is generated server side. The sample code is in ruby but obviously doesn't have to be. It signs the url for account id "Alice"

  a
  uri = URI.parse("http://player.ooyala.com/sas/embed_token/#{pcode}/" +
             "#{embed_code}?"
                  "account_id=#{account_id}&" +
                  "api_key=#{api_key}&" +
                  "expires=#{Time.now.to_i + 60 * 60 * 24}")
  params_hash = {}
  uri.query.split("&").map { |pair| pair.split("=", 2) }.each do |key,value|
    params_hash[CGI.unescape(key).to_sym] = (value && CGI.unescape(value)) if (key && !key.empty? && value)
  end
  signature = generate_signature(secret, "GET", uri.path, params_hash,

"", [])
  return "#{uri.to_s}&signature=#{CGI.escape(signature)}"

Getting the Playback Position

There are two ways to get a playback position:
  • For a specific asset for a given user
  • For all assets of a given user
Note:

User account ids are distinct per provider. Two different providers can have a user with the same name, but these are treated as distinct users. The account_id you use with Ooyala APIs must be unique in your own systems. For privacy, Ooyala encourages that the value of account_id be some sort of GUID (global unique identifier), rather than a plain-text username or email address. For example, an acceptable account_id is to use a base64, URl-encoded, Secure-hash-algorithm-(SHA)-256 digest of the username or email address, salted with some secret string that only you know. This salt must not be reused for any of your vendors other than Ooyala. This ensures that neither Ooyala nor a "man-in-the-middle" hacker sniffing network traffic can translate back from your GUIDs to real usernames or passwords. The account_id must be less than 255 characters and must not contain reserved URL characters such as [/, &, |, or ]. In most cases, you do not need to explicitly create an account with Ooyala APIs; you simply refer to an account wherever an API request requires it.

To get the playback position for a specific asset for a given user:

[GET] http://api.ooyala.com/v2/cross_device_resume/accounts/account_id/viewed_assets/embed_code(identifier for the asset)/playhead_info

Response:

{
    playhead_seconds: <position in seconds>,
    timestamp: <when the play event was received>
  }   

To get the playback position(s) for all assets viewed for a specific user:

[GET] http://api.ooyala.com/v2/cross_device_resume/accounts/account_id/playhead_info?limit=max_number_results&start_date=yyyy-mm-dd

The limit parameter is optional, and specifies the maximum number of results to return. The start_date parameter is also optional, and specifies the earliest date to return plays for (the end date will always be the time when the API is called, or present time).

Response:

{
  "items": [
    {
      "playhead_seconds": <position in seconds>,
      "timestamp": <when the play event was recieved>,
      "embed_code": <embed code>
    }
  ],
  "account": <account_id>
  "provider_id": <id of the provider or "pcode">
}

Seeking to the Correct Playback Position

For a seamless transition from different devices (or the same device), you need to include some scripting to seek to the correct playback position. Using the Player v3 initialTimeoption might be a good idea. Consult the Player API documentation for information about how to seek to a specific part in the asset. You can find the Player V3 documentation at:

해당 내용이 도움 되었습니까?