Share via


Playing Back a PlayReady Protected Smooth Streaming File

In this procedure, you will modify the Windows Store application created in Creating a Basic Smooth Streaming Store App so that the application can play back PlayReady protected Smooth Streaming files.

The app you create in this procedure uses a public PlayReady Test Server.

This topic contains the following procedures:

  • Change the media file to be played back to a PlayReady protected file.
  • Reference the PlayReady Client SDK.
  • Modify the code behind file.
  • Compile and test the application.

To play back a PlayReady protected file

  1. In Visual Studio, open the basic Smooth Streaming app project you created in Creating a Basic Smooth Streaming Store App.

  2. In Solution Explorer, open the shortcut menu for MainPage.xaml, and then choose View Designer.

  3. Scroll down to the txtMediaSource line and change the HTTP address to:

    http://playready.directtaps.net/smoothstreaming/SSWSS720H264PR/SuperSpeedway_720.ism/Manifest
    
  4. Choose the CTRL+S keys to save the file.

If you build and run the file, note that the video will no longer play. Since this is a PlayReady protected Smooth Streaming file, you will need to add the reference to the PlayReady client SDK along with code for the protection manager and PlayReady service request before the content will play back.

To add a reference to the Microsoft PlayReady Client SDK

  1. In Visual Studio, open the basic Smooth Streaming app project you created in Creating a Basic Smooth Streaming Store App.

  2. In Solution Explorer, open the shortcut menu for the SSPlayer project, and then choose Add Reference.

  3. In the Reference Manager dialog, expand the Windows tab and choose Extensions.

  4. Select the check box next to Microsoft PlayReady Client SDK.

  5. Choose the OK button.

  6. From the PROJECT menu, choose SSPlayer Properties.

  7. Choose the Build tab.

  8. Under the General section, choose the Platform target from the list.

Note

You must choose the specific target platform - do not use Any CPU.

To modify the MainPage.xaml code behind file

  1. In Solution Explorer, open the shortcut menu for MainPage.xaml, and then choose View Code.

  2. After the using Windows.UI.Xaml.Navigation line, add the following using statements:

    using Windows.Media.Protection;
    using Microsoft.Media.PlayReadyClient;
    
    
  3. At the beginning of the MainPage class, add the following data members:

    private MediaProtectionManager _protectionManager = new MediaProtectionManager();
    
    
  4. In the btnSetSource_Click method after the sliderProgress.Value = 0; line, add the following code:

    _protectionManager.ServiceRequested += new ServiceRequestedEventHandler(ProtectionManager_ServiceRequested);
    
    //Setup PlayReady as the ProtectionSystem to use
    //The native ASF media source will use this information to instantiate PlayReady ITA (InputTrustAuthority)
    Windows.Foundation.Collections.PropertySet cpSystems = new Windows.Foundation.Collections.PropertySet();
    cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput"); //Playready TrustedInput Class Name
    _protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems);
    _protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}");
    
    mediaElement.ProtectionManager = _protectionManager;
    
  5. At the end of the MainPage class, add the following methods:

    void ProtectionManager_ServiceRequested(MediaProtectionManager sender, ServiceRequestedEventArgs srEvent)
    {
      HandleServiceRequest(srEvent);
    }
    
    async void HandleServiceRequest(ServiceRequestedEventArgs srEvent)
    {
      IPlayReadyServiceRequest serviceRequest = (IPlayReadyServiceRequest)srEvent.Request;
    
      await serviceRequest.BeginServiceRequest();
      srEvent.Completion.Complete(true);
    }
    
    

    The ProtectionManager_ServiceRequested method is the most important piece. The ProtectionManager will file different service requests. The HandleServiceRequest method processes these requests based on the the event that occurred.

  6. Press the CTRL+S keys to save the file.

To compile and test the app

  1. On the menu bar, choose BUILD, Configuration Manager.
  2. In the Configuration Manager dialog, choose your development platform from the Active solution platform list, and then choose the Close button.
  3. Choose the F6 key to compile the project.
  4. Choose the F5 key to run the app.
  5. In the app, choose the Set Source button. Individualization and license acquisition takes extra time to complete, so it can take a few seconds before the video begins to play.