diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index d5f4413870f9..aac88ae04576 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -517,8 +517,6 @@ const listeners = { "FormValidation:HidePopup": ["FormValidationHandler"], "PictureInPicture:Request": ["PictureInPicture"], "PictureInPicture:Close": ["PictureInPicture"], - "PictureInPicture:Playing": ["PictureInPicture"], - "PictureInPicture:Paused": ["PictureInPicture"], "Prompt:Open": ["RemotePrompt"], "Reader:FaviconRequest": ["ReaderParent"], "Reader:UpdateReaderButton": ["ReaderParent"], diff --git a/toolkit/actors/PictureInPictureChild.jsm b/toolkit/actors/PictureInPictureChild.jsm index bdad99b1285f..059a7a9061e7 100644 --- a/toolkit/actors/PictureInPictureChild.jsm +++ b/toolkit/actors/PictureInPictureChild.jsm @@ -16,10 +16,6 @@ var gWeakVideo = null; var gWeakPlayerContent = null; class PictureInPictureChild extends ActorChild { - static videoIsPlaying(video) { - return !!(video.currentTime > 0 && !video.paused && !video.ended && video.readyState > 2); - } - handleEvent(event) { switch (event.type) { case "MozTogglePictureInPicture": { @@ -34,14 +30,6 @@ class PictureInPictureChild extends ActorChild { this.closePictureInPicture(); break; } - case "play": { - this.mm.sendAsyncMessage("PictureInPicture:Playing"); - break; - } - case "pause": { - this.mm.sendAsyncMessage("PictureInPicture:Paused"); - break; - } } } @@ -85,7 +73,6 @@ class PictureInPictureChild extends ActorChild { gWeakVideo = Cu.getWeakReference(video); this.mm.sendAsyncMessage("PictureInPicture:Request", { - playing: PictureInPictureChild.videoIsPlaying(video), videoHeight: video.videoHeight, videoWidth: video.videoWidth, }); @@ -141,14 +128,6 @@ class PictureInPictureChild extends ActorChild { this.setupPlayer(); break; } - case "PictureInPicture:Play": { - this.play(); - break; - } - case "PictureInPicture:Pause": { - this.pause(); - break; - } } } @@ -161,8 +140,6 @@ class PictureInPictureChild extends ActorChild { let originatingWindow = originatingVideo.ownerGlobal; if (originatingWindow) { originatingWindow.addEventListener("pagehide", this); - originatingVideo.addEventListener("play", this); - originatingVideo.addEventListener("pause", this); } } @@ -176,8 +153,6 @@ class PictureInPictureChild extends ActorChild { let originatingWindow = originatingVideo.ownerGlobal; if (originatingWindow) { originatingWindow.removeEventListener("pagehide", this); - originatingVideo.removeEventListener("play", this); - originatingVideo.removeEventListener("pause", this); } } @@ -249,18 +224,4 @@ class PictureInPictureChild extends ActorChild { gWeakPlayerContent = Cu.getWeakReference(this.content); } - - play() { - let video = this.weakVideo; - if (video) { - video.play(); - } - } - - pause() { - let video = this.weakVideo; - if (video) { - video.pause(); - } - } } diff --git a/toolkit/components/pictureinpicture/PictureInPicture.jsm b/toolkit/components/pictureinpicture/PictureInPicture.jsm index 8a4bbd2aaa1f..05e3647fdf64 100644 --- a/toolkit/components/pictureinpicture/PictureInPicture.jsm +++ b/toolkit/components/pictureinpicture/PictureInPicture.jsm @@ -35,25 +35,9 @@ var PictureInPicture = { this.closePipWindow(); break; } - case "PictureInPicture:Playing": { - this.weakPipControls.classList.add("playing"); - break; - } - case "PictureInPicture:Paused": { - this.weakPipControls.classList.remove("playing"); - break; - } } }, - focusTabAndClosePip() { - let gBrowser = this.browser.ownerGlobal.gBrowser; - let tab = gBrowser.getTabForBrowser(this.browser); - gBrowser.selectedTab = tab; - this.unload(); - this.closePipWindow(); - }, - /** * Find and close any pre-existing Picture in Picture windows. */ @@ -64,6 +48,7 @@ var PictureInPicture = { if (win.closed) { continue; } + win.close(); } }, @@ -89,26 +74,12 @@ var PictureInPicture = { * the player component inside it has finished loading. */ async handlePictureInPictureRequest(browser, videoData) { - this.browser = browser; let parentWin = browser.ownerGlobal; this.closePipWindow(); let win = await this.openPipWindow(parentWin, videoData); - this.weakPipControls = win.document.getElementById("controls"); - if (videoData.playing) { - this.weakPipControls.classList.add("playing"); - } win.setupPlayer(browser, videoData); }, - /** - * unload event has been called in player.js, cleanup our preserved - * browser object. - */ - unload() { - delete this.weakPipControls; - delete this.browser; - }, - /** * Open a Picture in Picture window on the same screen as parentWin, * sized based on the information in videoData. diff --git a/toolkit/components/pictureinpicture/content/player.js b/toolkit/components/pictureinpicture/content/player.js index 6e3c43ec0d04..5c957cbe97e8 100644 --- a/toolkit/components/pictureinpicture/content/player.js +++ b/toolkit/components/pictureinpicture/content/player.js @@ -2,8 +2,6 @@ * 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/. */ -const {PictureInPicture} = ChromeUtils.import("resource://gre/modules/PictureInPicture.jsm"); - async function setupPlayer(originatingBrowser, videoData) { window.windowUtils.setChromeMargin(0, 0, 0, 0); let holder = document.querySelector(".player-holder"); @@ -21,33 +19,12 @@ async function setupPlayer(originatingBrowser, videoData) { let mm = browser.frameLoader.messageManager; mm.sendAsyncMessage("PictureInPicture:SetupPlayer"); - document.getElementById("play").addEventListener("click", () => { - mm.sendAsyncMessage("PictureInPicture:Play"); - }); - - document.getElementById("pause").addEventListener("click", () => { - mm.sendAsyncMessage("PictureInPicture:Pause"); - }); - - document.getElementById("unpip").addEventListener("click", () => { - PictureInPicture.focusTabAndClosePip(); - }); - // If the content process hosting the video crashes, let's // just close the window for now. browser.addEventListener("oop-browser-crashed", () => { window.close(); }); - browser.addEventListener("unload", () => { - PictureInPicture.unload(); - }); - await window.promiseDocumentFlushed(() => {}); browser.style.MozWindowDragging = "drag"; - - let close = document.getElementById("close"); - close.addEventListener("click", () => { - window.close(); - }); } diff --git a/toolkit/components/pictureinpicture/content/player.xhtml b/toolkit/components/pictureinpicture/content/player.xhtml index a4b18def5c18..76b3f7217830 100644 --- a/toolkit/components/pictureinpicture/content/player.xhtml +++ b/toolkit/components/pictureinpicture/content/player.xhtml @@ -21,11 +21,5 @@