diff options
Diffstat (limited to '')
-rw-r--r-- | comm/suite/base/content/fullscreen-video.xhtml | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/comm/suite/base/content/fullscreen-video.xhtml b/comm/suite/base/content/fullscreen-video.xhtml new file mode 100644 index 0000000000..a56789a06a --- /dev/null +++ b/comm/suite/base/content/fullscreen-video.xhtml @@ -0,0 +1,156 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- 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/. --> + +<!DOCTYPE html> +<html xmlns="http://www.w3.org/1999/xhtml" accelerated="11"> +<head> + <link href="chrome://communicator/skin/fullscreen-video.css" + rel="stylesheet" type="text/css"/> + <script> + <![CDATA[ + +var contentVideo = window.arguments[0]; +var isPaused = window.arguments[1]; +var video; +var closeIcon; + +var title = (contentVideo.currentSrc || contentVideo.src).replace(/^.*\//, ""); +try { + title = decodeURI(title); +} catch (e) {} +document.title = title; + +window.addEventListener("focus", onFocus); +window.addEventListener("unload", onUnload); +window.addEventListener("keypress", onKeyPress); + +function onFocus() { + window.removeEventListener("focus", onFocus); + + window.fullScreen = true; + + window.addEventListener("deactivate", autoClose); + + video = document.querySelector("video"); + closeIcon = document.querySelector("div"); + + video.addEventListener("loadeddata", onLoadedData); + + // Automatically close this window when the playback ended, unless the user + // interacted with it. + video.addEventListener("ended", autoClose); + window.addEventListener("click", cancelAutoClose); + window.addEventListener("keypress", cancelAutoClose); + + video.addEventListener("playing", hideUI); + video.addEventListener("seeked", hideUI); + video.addEventListener("seeking", showUI); + video.addEventListener("pause", showUI); + video.addEventListener("ended", showUI); + + window.addEventListener("mousemove", onMouseMove); + + video.src = contentVideo.currentSrc || contentVideo.src; +} + +function onLoadedData() { + video.removeEventListener("loadeddata", onLoadedData); + video.volume = contentVideo.volume; + video.muted = contentVideo.muted; + video.poster = contentVideo.poster; + + if (contentVideo.currentTime && !contentVideo.ended) { + video.addEventListener("seeked", playbackStarts); + + video.currentTime = contentVideo.currentTime; + } else { + playbackStarts(); + } + + video.controls = true; + + if (!isPaused) + video.play(); +} + +function onMouseMove() { + showUI(); + resetIdleTimer(); +} + +function onUnload() { + if (video.currentSrc) { + contentVideo.currentTime = video.currentTime; + contentVideo.volume = video.volume; + contentVideo.muted = video.muted; + if (!video.paused && !video.ended) { + video.pause(); + contentVideo.play(); + } + } +} + +function onKeyPress(event) { + if (event.keyCode == event.DOM_VK_ESCAPE) { + window.close(); + return; + } + + resetIdleTimer(); + + if (!video.controls && + String.fromCharCode(event.charCode) == " ") + video.pause(); +} + +function playbackStarts() { + video.removeEventListener("seeked", playbackStarts); + + // Loading the data from the content video may take a second or two. We hide + // the video during that period. + document.body.style.visibility = "visible"; + video.focus(); +} + +function autoClose() { + window.close(); +} + +function cancelAutoClose() { + video.removeEventListener("ended", autoClose); + window.removeEventListener("click", cancelAutoClose); + window.removeEventListener("keypress", cancelAutoClose); +} + +var idleTimer = 0; +function resetIdleTimer() { + clearTimeout(idleTimer); + idleTimer = setTimeout(hideUI, 2000); +} + +function showUI() { + if (!video.controls) { + window.setCursor("auto"); + closeIcon.style.visibility = "visible"; + video.controls = true; + } +} + +function hideUI() { + if (!video.paused && !video.ended && !video.seeking && !video.error) { + window.setCursor("none"); + closeIcon.style.visibility = "hidden"; + video.controls = false; + } +} + + ]]></script> +</head> +<body> + <div onclick="window.close();"/> + <video/> +</body> +</html> |