78 lines
3.1 KiB
HTML
78 lines
3.1 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>default-actionHandlers</title>
|
|
<script src="../video-test.js"></script>
|
|
<script src="../media-file.js"></script>
|
|
<script>
|
|
|
|
async function runTest() {
|
|
findMediaElement();
|
|
run('video.src = findMediaFile("video", "../content/test")');
|
|
await waitFor(video, 'loadeddata');
|
|
|
|
consoleWrite('Test that default media element action will be run when no media session handlers exist for that action.');
|
|
|
|
testExpected("video.paused", true);
|
|
|
|
await navigator.mediaSession.callActionHandler({action: "play"});
|
|
testExpected("video.paused", false);
|
|
|
|
await navigator.mediaSession.callActionHandler({action: "pause"});
|
|
testExpected("video.paused", true);
|
|
|
|
run('video.currentTime = 0');
|
|
testExpected("video.currentTime", 0);
|
|
|
|
await navigator.mediaSession.callActionHandler( {action: "seekto", seekTime: 1});
|
|
testExpected("video.currentTime", 1);
|
|
|
|
await navigator.mediaSession.callActionHandler({action: "seekforward", seekOffset: 5});
|
|
testExpected("video.currentTime", 6);
|
|
|
|
await navigator.mediaSession.callActionHandler({action: "seekbackward", seekOffset: 5});
|
|
testExpected("video.currentTime", 1);
|
|
|
|
consoleWrite('Test that if an action handler is defined, the default action won\'t be called');
|
|
|
|
navigator.mediaSession.setActionHandler("play", actionDetails => {
|
|
consoleWrite(`ACTION: ${actionDetails.action}`);
|
|
});
|
|
await navigator.mediaSession.callActionHandler({action: "play"});
|
|
// Playback shouldn't have started if a handler for the play action was defined and it did nothing.
|
|
testExpected("video.paused", true);
|
|
|
|
navigator.mediaSession.setActionHandler("play", null);
|
|
await navigator.mediaSession.callActionHandler({action: "play"});
|
|
testExpected("video.paused", false);
|
|
|
|
navigator.mediaSession.setActionHandler("pause", actionDetails => {
|
|
consoleWrite(`ACTION: ${actionDetails.action}`);
|
|
});
|
|
await navigator.mediaSession.callActionHandler({action: "pause"});
|
|
// Playback shouldn't have been interrupted if a handler for the pause action was defined and it did nothing.
|
|
testExpected("video.paused", false);
|
|
|
|
navigator.mediaSession.setActionHandler("pause", null);
|
|
await navigator.mediaSession.callActionHandler({action: "pause"});
|
|
testExpected("video.paused", true);
|
|
|
|
navigator.mediaSession.setActionHandler("seekto", actionDetails => {
|
|
consoleWrite(`ACTION: ${actionDetails.action}`);
|
|
});
|
|
await navigator.mediaSession.callActionHandler({action: "seekto", seekTime: 5});
|
|
testExpected("video.currentTime", 1);
|
|
|
|
navigator.mediaSession.setActionHandler("seekto", null);
|
|
await navigator.mediaSession.callActionHandler({action: "seekto", seekTime: 5});
|
|
testExpected("video.currentTime", 5);
|
|
|
|
endTest();
|
|
}
|
|
</script>
|
|
</head>
|
|
<body onload="runTest()">
|
|
<video controls preload='auto'></video>
|
|
</body>
|
|
</html>
|