PlayReady Example
A PlayReady reference implementation shows example code needed to implement and initialize PlayReady content protection.
-
Make an authorization request to Ooyala (see step 3 in the PlayReady Workflow table).
-
Parse the stream url and auth_token from the auth_response.
- Insert the auth_token into the PlayReady license request and then play the smooth stream (see step 5 in the previous PlayReady Workflow table).
Anatomy of an Authorization Token
In step 3 of the PlayReady Workflow, an authorization request is made. When this authorization request includes a valid Ooyala Player Token, the response will include an auth_token. This authorization token will look something like the following:
``` {"authorization_data"=> ..., "debug_data"=>..., "auth_token" => "foo", "signature"=> ... } ```
The auth_token needs to be included in the PlayReady license request as indicated in step 5 of the PlayReady Workflow.
Using the Smooth Stream Client SDK
You can use PlayReady with the Smooth Stream Client SDK, which you can download at (http://www.iis.net/downloads/microsoft/smooth-streaming-client-sdk). A sample is available from your Customer Success Manager that illustrates how to use the IIS (Smooth Stream Client SDK) to playback smooth streams and make the license request. The following excerpt from the sample (written in C#), shows:
- how the stream url is obtained from the authorization request.
- when the authorization response contains the auth_token, how to insert the auth_token into the license request.
// Make an authorization request first, then get the manifest and auth token from the response. WebClient client = new WebClient(); client.DownloadStringCompleted += (target, eventData) => { try { OutputText.Text += "Authorization response received\n"; JsonObject response = (JsonObject)JsonObject.Load(new StringReader(eventData.Result)); // The stream url is obtained from the authz response. Byte[] streamUrlArray = Convert.FromBase64String(((JsonObject) response["authorization_data"]).Values.First()["streams"][0]["url"]["data"]); String streamUrl = Encoding.UTF8.GetString(streamUrlArray, 0, streamUrlArray.Length); // If the authz response includes an auth token, insert it into the license request. if(response.ContainsKey("auth_token")) { SmoothPlayer.LicenseAcquirer.ChallengeCustomData = "auth_token=" + response["auth_token"]; } SmoothPlayer.AutoPlay = true; SmoothPlayer.SmoothStreamingSource = new Uri(streamUrl); } catch (Exception exception) { OutputText.Text += "Error: " + exception.ToString() + "\n"; } }; // For the purpose of this sample, the authorization url is set by the user. See Authorization API docs for how to // construct the Authorization request, and Ooyala Player Tokens. OutputText.Text += "Making authorization Request\n"; client.DownloadStringAsync(new Uri(UrlText.Text)); }
Using Other Client Libraries
For other types of client libraries the auth_token must be included in the license request as CustomData in the: '/soap:Envelop/soap:Body/AquireLicense/challenge/Challenge/LA/CustomData' The following example show how to include the auth_token in the license request for other client libraries:
``` <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <AcquireLicense xmlns="http://schemas.microsoft.com/DRM/2007/03/protocols"> <challenge> <Challenge xmlns="http://schemas.microsoft.com/DRM/2007/03/protocols/messages"> <LA xmlns="http://schemas.microsoft.com/DRM/2007/03/protocols" Id="SignedData" xml:space="preserve"> ... <CustomData>auth_token=foo</CustomData> </LA> </Challenge> </challenge> </AcquireLicense> </soap:Body> </soap:Envelope> ```