summaryrefslogtreecommitdiff
path: root/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/change-video-source-on-end.html
blob: f84f7f7ac1b14c575587440629e988c28848401b (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
31
32
33
34
35
<head>
    <style>
        video {
            width: 800px;
            height: 600px;
        }
    </style>
    <script type="text/javascript">
        var hasBegunPlayingBefore = false;

        function changeSource() {
            var video = document.querySelector("video");
            video.src = "large-video-with-audio.mp4";
            video.play();
            setTimeout(function() {
                try {
                    window.webkit.messageHandlers.testHandler.postMessage("changed");
                } catch(e) {
                }
            });
        }

        function handlePlaying() {
            if (hasBegunPlayingBefore)
                return;

            hasBegunPlayingBefore = true;
            var video = document.querySelector("video");
            video.currentTime = video.duration - 0.5;
        }
    </script>
</head>
<body>
    <video autoplay onplaying=handlePlaying() src="large-video-with-audio.mp4" onended=changeSource()></video>
</body>