23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

if (typeof (e.request) != 'undefined') {<br />

var req = e.request;<br />

var system = req.protectionSystem;<br />

var type = req.type;<br />

}<br />

//Take necessary actions based on the system and type<br />

}<br />

if (typeof (e.completion) != 'undefined') {<br />

//Requested action completed<br />

var comp = e.completion;<br />

comp.complete(true);<br />

}<br />

How you specifically check for rights, of course, is particular to the service you’re drawing from—and<br />

not something you’d want to publish in any case!<br />

For a more complete demonstration of handling DRM, check out the Simple PlayReady sample,<br />

which will require that you download and install the Microsoft PlayReady Client SDK. PlayReady, if you<br />

aren’t familiar with it yet, is a license service that Microsoft provides so that you don’t have to create one<br />

from scratch. The PlayReady client SDK provides additional tools and framework support for apps<br />

wanting to implement both online and offline media scenarios, such as progressive download,<br />

download to own, rentals, and subscriptions. Plus, with the SDK you don’t need to submit your app for<br />

DRM Conformance testing. In any case, here’s how the Simple PlayReady sample sets up its content<br />

protection manager, just to give an idea of how the WinRT APIs are used with specific DRM service<br />

identifiers:<br />

mediaProtectionManager = new Windows.Media.Protection.MediaProtectionManager();<br />

mediaProtectionManager.properties["Windows.Media.Protection.MediaProtectionSystemId"] =<br />

'{F4637010-03C3-42CD-B932-B48ADF3A6A54}'<br />

var cpsystems = new Windows.Foundation.Collections.PropertySet();<br />

cpsystems["{F4637010-03C3-42CD-B932-B48ADF3A6A54}"] =<br />

"Microsoft.Media.PlayReadyClient.PlayReadyWinRTTrustedInput";<br />

mediaProtectionManager.properties[<br />

"Windows.Media.Protection.MediaProtectionSystemIdMapping"] = cpsystems;<br />

Streaming from App to Network<br />

The next case to consider is when an app is the source of streaming media rather than the consumer,<br />

which means that client apps elsewhere are acting in that capacity. In reality, in this scenario—audio or<br />

video communications and conferencing—it’s usually the case that the app plays both roles, streaming<br />

media to other clients and consuming media from them. This is the case with Windows Live Messenger,<br />

Skype, and other such utilities, along with apps like games that include chat capabilities.<br />

462

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!