Windows Dev Center

How to handle DRM errors (HTML)

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.addEventListener('error', function onError() {
        var error = myVideo.error.msExtendedCode;
        // handle error.
    }, false);

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

    myVideo.src = "";

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;       



© 2015 Microsoft