- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / media / html / media_basic_playback.html
1 <!-- Used by media_basic_playback to verify basic playback. -->
2 <!DOCTYPE html>
3 <html lang="en-US">
4   <head>
5     <title>Basic Media Playback Test</title>
6   </head>
7
8   <body>
9     <video autoplay preload controls></video>
10   </body>
11
12   <script type="text/javascript" src="utils.js"></script>
13   <script type="text/javascript">
14     var video = document.querySelector('video');
15
16     // Used to keep track of events.
17     var events;
18
19     // List of events to log.  Events in this list are those which are expected
20     // plus those which are unexpected and will have a negative impact on
21     // playback.
22     var eventsToLog = [
23       'abort', 'emptied', 'error', 'playing', 'stalled', 'suspend', 'waiting'];
24
25     function logEvent(evt) {
26       events.push(evt.type);
27     }
28
29     for(var i = 0; i < eventsToLog.length; i++)
30       video.addEventListener(eventsToLog[i], logEvent, false);
31
32     video.addEventListener('ended', function(event) {
33       firstEndedEvent = events.indexOf('ended') < 0;
34       logEvent(event);
35
36       // At the end of the first playback, seek near end and replay.  0.8 was
37       // chosen arbitrarily.
38       if (firstEndedEvent) {
39         video.currentTime = 0.8 * video.duration;
40       } else {
41         // Notify PyAuto that we've completed testing.  Send test of currentTime
42         // at the same time for efficiency.
43         window.domAutomationController.send(
44             video.currentTime == video.duration);
45       }
46     }, false);
47
48     video.addEventListener('seeked', function(event) {
49       logEvent(event);
50       video.play();
51     }, false);
52
53     function startTest(media) {
54       events = [];
55       video.src = media;
56     }
57   </script>
58 </html>