private void _initialiseMediaProtectionManager(MediaElement mediaElement) { var mediaProtectionManager = new Windows.Media.Protection.MediaProtectionManager(); mediaProtectionManager.Properties["Windows.Media.Protection.MediaProtectionContainerGuid"] = "{9A04F079-9840-4286-AB92-E65BE0885F95}"; // Setup the container GUID for CFF var cpsystems = new Windows.Foundation.Collections.PropertySet(); cpsystems["{F4637010-03C3-42CD-B932-B48ADF3A6A54}"] = "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput"; // PlayReady mediaProtectionManager.Properties["Windows.Media.Protection.MediaProtectionSystemIdMapping"] = cpsystems; mediaProtectionManager.Properties["Windows.Media.Protection.MediaProtectionSystemId"] = "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"; mediaElement.ProtectionManager = mediaProtectionManager; mediaProtectionManager.ServiceRequested += MediaProtectionManager_ServiceRequested; }
private async void MediaProtectionManager_ServiceRequested(Windows.Media.Protection.MediaProtectionManager sender, Windows.Media.Protection.ServiceRequestedEventArgs e) { var completionNotifier = e.Completion; IPlayReadyServiceRequest request = (IPlayReadyServiceRequest)e.Request; //TODO: retrieve service request type from Microsoft.Media.Protection.PlayReady if (request.Type != new Guid("c6b344bd-6017-4199-8474-694ac3ec0b3f")) { request.Uri = new Uri(licenseUrl); } try { await request.BeginServiceRequest(); completionNotifier.Complete(true); } catch (Exception ex) { completionNotifier.Complete(false); } }
/// <summary> /// This method Register the PlayReady component . /// </summary> public bool RegisterPlayReady() { bool bResult = false; // PlayReady // Init PlayReady Protection Manager if (protectionManager != null) { protectionManager.ComponentLoadFailed -= ProtectionManager_ComponentLoadFailed; protectionManager.ServiceRequested -= ProtectionManager_ServiceRequested; protectionManager = null; } protectionManager = new Windows.Media.Protection.MediaProtectionManager(); if (protectionManager != null) { Windows.Foundation.Collections.PropertySet cpSystems = new Windows.Foundation.Collections.PropertySet(); cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput"); //Playready protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); /* //Indicate to the MF pipeline to use PlayReady's TrustedInput cpSystems.Add("{F4637010-03C3-42CD-B932-B48ADF3A6A54}", "Windows.Media.Protection.PlayReady.PlayReadyWinRTTrustedInput"); protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemIdMapping", cpSystems); //Use by the media stream source about how to create ITA InitData. //See here for more detai: https://msdn.microsoft.com/en-us/library/windows/desktop/aa376846%28v=vs.85%29.aspx protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionSystemId", "{F4637010-03C3-42CD-B932-B48ADF3A6A54}"); */ // Setup the container GUID that's in the PPSH box protectionManager.Properties.Add("Windows.Media.Protection.MediaProtectionContainerGuid", "{9A04F079-9840-4286-AB92-E65BE0885F95}"); Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; // Check if the platform does support hardware DRM LogMessage((IsHardwareDRMSupported() == true ? "Hardware DRM is supported on this platform" : "Hardware DRM is not supported on this platform")); // Associate the MediaElement with the protection manager mediaElement.ProtectionManager = protectionManager; mediaElement.ProtectionManager.ComponentLoadFailed += ProtectionManager_ComponentLoadFailed; mediaElement.ProtectionManager.ServiceRequested += ProtectionManager_ServiceRequested; bResult = true; } return bResult; }