gecko/browser/metro/base/content/pages/fullscreen-video.xhtml
2013-02-12 14:51:25 -06:00

155 lines
3.8 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<!--
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->
<html xmlns="http://www.w3.org/1999/xhtml" accelerated="11">
<head>
<style type="text/css"><![CDATA[
html,
body,
video {
height: 100%;
}
body {
margin: 0;
background: black;
overflow: -moz-hidden-unscrollable;
}
video {
width: 100%;
max-height: 100%;
}
]]></style>
<script type="application/javascript;version=1.8"><![CDATA[
var TheaterTab = {
videoElement: null,
idleTimer: 0,
init: function init() {
this.videoElement = document.querySelector("video");
/*
* video events
*/
this.videoElement.addEventListener("loadeddata", TheaterTab.loadDataCallback, false);
this.videoElement.addEventListener("seeked", TheaterTab.seekComplete, false);
this.videoElement.addEventListener("pause", TheaterTab.pauseCallback, false);
this.videoElement.addEventListener("play", TheaterTab.playCallback, false);
this.videoElement.addEventListener("ended", TheaterTab.endedCallback, false);
/*
* window events
*/
window.addEventListener("click", function () {
TheaterTab.togglePlay();
TheaterTab.resetIdleTimer();
}, false);
window.addEventListener("unload", function () {
if (TheaterTab.videoElement.currentSrc) {
contentVideo.currentTime = TheaterTab.videoElement.currentTime;
contentVideo.volume = TheaterTab.videoElement.volume;
contentVideo.muted = TheaterTab.videoElement.muted;
if (!TheaterTab.videoElement.paused && !TheaterTab.videoElement.ended) {
TheaterTab.videoElement.pause();
}
}
}, false);
window.addEventListener("keypress", function (event) {
TheaterTab.resetIdleTimer();
}, false);
// Load the video up and play it
this.videoElement.mozLoadFrom(contentVideo);
},
/*
* Video element callbacks
*/
loadDataCallback: function loadDataCallback() {
dump("loadDataCallback()\n");
TheaterTab.videoElement.removeEventListener("loadeddata", arguments.callee, false);
TheaterTab.videoElement.volume = contentVideo.volume;
TheaterTab.videoElement.muted = contentVideo.muted;
TheaterTab.videoElement.poster = contentVideo.poster;
// If we are starting from mid stream, wait until we have
// seeked to the start location.
dump(contentVideo + "\n");
if (contentVideo.currentTime && !contentVideo.ended) {
// set up callback to play
TheaterTab.videoElement.addEventListener("seeked", function () {
TheaterTab.videoElement.removeEventListener("seeked", arguments.callee, false);
TheaterTab.seekComplete();
}, false);
// seek
TheaterTab.videoElement.currentTime = contentVideo.currentTime;
return;
}
TheaterTab.play();
},
seekComplete: function seekComplete() {
TheaterTab.play();
},
pauseCallback: function pauseCallback() {
},
playCallback: function playCallback() {
},
endedCallback: function endedCallback() {
},
/*
* Video control
*/
play: function play() {
this.videoElement.play();
},
pause: function pause() {
this.videoElement.pause();
},
togglePlay: function togglePlay() {
if (this.videoElement.paused) {
this.play();
} else {
this.pause();
}
},
};
Components.utils.import("resource:///modules/video.jsm");
// The video in the content tab we launched from
var contentVideo = Video.fullScreenSourceElement;
// ??
Video.fullScreenSourceElement = null;
]]></script>
</head>
<body onload="TheaterTab.init();">
<video controls="true"/>
</body>
</html>