DRM 오류를 처리하는 방법(HTML)

[ 이 문서는 Windows 런타임 앱을 작성하는 Windows 8.x 및 Windows Phone 8.x 개발자를 대상으로 합니다. Windows 10용으로 개발하는 경우에는 최신 설명서를 참조하세요.]

Windows 런타임 앱에서는 MediaProtectionManager를 사용하여, DRM(디지털 권한 관리)으로 보호된 미디어 콘텐츠의 재생을 지원할 수 있습니다. MediaError 인터페이스는 msExtendedCode 특성을 포함하도록 확장되었으므로 개발자가 구현 중 피드백을 볼 수 있습니다.

다음 코드에서는 msExtendedCode 특성과 함께 MediaProtectionManager를 사용하는 방법을 보여 줍니다.

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 = "https://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);        
    }
}