blob: 7cff7f4f69616d57543bc1234c1f4bd2955bdcfe (
plain)
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
|
<!DOCTYPE html>
<html>
<head>
<title>Media Session and non-autoplay media</title>
</head>
<body>
<video id="testVideo" src="gizmo.mp4" loop></video>
<h1 id="result"></h1>
<script type="text/javascript">
const MediaSessionActions = [
"play",
"pause",
"seekbackward",
"seekforward",
"previoustrack",
"nexttrack",
"stop",
];
for (const action of MediaSessionActions) {
navigator.mediaSession.setActionHandler(action, () => {
document.getElementById("result").innerHTML = action;
document.getElementById("result").dispatchEvent(new CustomEvent("actionChanged"));
});
}
</script>
</body>
</html>
|