How to handle DRM errors (Windows Store apps using JavaScript and HTML)

0 out of 1 rated this helpful - Rate this topic

Windows Store apps can enable playback of Digital Rights Management (DRM) protected media content by using the MediaProtectionManager. The MediaError interface is extended to include an msExtendedCode attribute so developers can get feedback during implementation.

The following code shows how to use MediaProtectionManager with the msExtendedCode attribute.


function DRMErrors() {
    var myVideo = document.getElementById("videoTag1");
    var cpm = new Windows.Media.Protection.MediaProtectionManager();
    cpm.addEventListener('servicerequested', EnableContent, false);
    myVideo.msSetMediaProtectionManager(cpm);

    myVideo.addEventListener('error', function onError() {
        var error = myVideo.error.msExtendedCode;
        // handle error.
    }, false);


    myVideo.addEventListener('canplay', function onCanplay() {
        myVideo.play();
    }, false);

    myVideo.src = "http://www.contoso.com/test.wmv";
}

function EnableContent(e) {
    if (typeof (e.request) != 'undefined') {
        var req = e.request;
        var system = req.protectionSystem;
        var type = req.type;

        // take necessary actions Based on the system and type;
    }
    if (typeof (e.completion) != 'undefined') { // requested action completed
        var comp = e.completion;       
        comp.complete(true);        
    }
}


 

 

Build date: 11/29/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.