<!-- Used by media_basic_playback to verify basic playback. -->
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Basic Media Playback Test</title>
</head>
<body>
<video autoplay preload controls></video>
</body>
<script type="text/javascript" src="utils.js"></script>
<script type="text/javascript">
var video = document.querySelector('video');
// Used to keep track of events.
var events;
// List of events to log. Events in this list are those which are expected
// plus those which are unexpected and will have a negative impact on
// playback.
var eventsToLog = [
'abort', 'emptied', 'error', 'playing', 'stalled', 'suspend', 'waiting'];
function logEvent(evt) {
events.push(evt.type);
}
for(var i = 0; i < eventsToLog.length; i++)
video.addEventListener(eventsToLog[i], logEvent, false);
video.addEventListener('ended', function(event) {
firstEndedEvent = events.indexOf('ended') < 0;
logEvent(event);
// At the end of the first playback, seek near end and replay. 0.8 was
// chosen arbitrarily.
if (firstEndedEvent) {
video.currentTime = 0.8 * video.duration;
} else {
// Notify PyAuto that we've completed testing. Send test of currentTime
// at the same time for efficiency.
window.domAutomationController.send(
video.currentTime == video.duration);
}
}, false);
video.addEventListener('seeked', function(event) {
logEvent(event);
video.play();
}, false);
function startTest(media) {
events = [];
video.src = media;
}
</script>
</html>