How to handle DRM errors

How to handle DRM errors (HTML)

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

Windows Runtime 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);        
    }
}


 

 

Show:
© 2017 Microsoft