forked from proprietary/chromium-widevine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-widevine.html
79 lines (72 loc) · 1.61 KB
/
test-widevine.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!doctype html>
<html>
<body>
<ul id="root"></ul>
<script>
const CONFIG = {
"initDataTypes": ["cenc"]
};
const VIDEO_CAPABILITIES = [
"video/mp4;codecs=\"avc1.42c00d\"",
"video/mp4;codecs=\"ec-3\"",
"video/webm;codecs=\"vorbis,vp8\"",
"video/mp2t;codecs=\"avc1.42E01E,mp4a.40.2\""
];
const AUDIO_CAPABILITIES = [
"audio/mp4;codecs=\"mp4a.40.2\""
];
const ROOT = document.getElementById("root");
function report(msg) {
const el = document.createElement("li");
el.innerText = msg;
ROOT.prepend(el);
}
async function check_feature(opts, feature) {
let cfg = Object.assign({}, CONFIG);
if (opts != null) {
Object.assign(cfg, opts);
}
try {
const widevine_test = await navigator.requestMediaKeySystemAccess("com.widevine.alpha", [ cfg ]);
console.log(widevine_test);
report(`[✓] ${feature} supported!`);
return true;
} catch (e) {
console.error(e);
report(`[✗] ${feature} not supported`);
}
return false;
}
(async function() {
let any_detected = false;
for (const video_capability of VIDEO_CAPABILITIES) {
const r = await check_feature(
{
"videoCapabilities": [
{ "contentType": video_capability }
]
},
`video codec ${video_capability}`
);
any_detected = any_detected || r;
}
for (const audio_capability of AUDIO_CAPABILITIES) {
const r = await check_feature(
{
"audioCapabilities": [
{ "contentType": audio_capability }
]
},
`audio codec ${audio_capability}`
);
any_detected = any_detected || r;
}
if (!any_detected) {
report(`[✗] Widevine not found`);
} else {
report(`[✓] Widevine found!`);
}
})();
</script>
</body>
</html>