mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 00:57:30 +09:00
[Basilisk] Issue MoonchildProductions/UXP#1390 - Remove application support for the Presentation API
This commit is contained in:
parent
fdbd890581
commit
bb4519ea4f
10 changed files with 1 additions and 298 deletions
|
|
@ -214,7 +214,6 @@ pref("browser.slowStartup.timeThreshold", 40000);
|
||||||
pref("browser.slowStartup.maxSamples", 5);
|
pref("browser.slowStartup.maxSamples", 5);
|
||||||
|
|
||||||
pref("browser.enable_automatic_image_resizing", true);
|
pref("browser.enable_automatic_image_resizing", true);
|
||||||
pref("browser.casting.enabled", false);
|
|
||||||
pref("browser.chrome.site_icons", true);
|
pref("browser.chrome.site_icons", true);
|
||||||
pref("browser.chrome.favicons", true);
|
pref("browser.chrome.favicons", true);
|
||||||
// browser.warnOnQuit == false will override all other possible prompts when quitting or restarting
|
// browser.warnOnQuit == false will override all other possible prompts when quitting or restarting
|
||||||
|
|
|
||||||
|
|
@ -226,11 +226,6 @@
|
||||||
label="&emailVideoCmd.label;"
|
label="&emailVideoCmd.label;"
|
||||||
accesskey="&emailVideoCmd.accesskey;"
|
accesskey="&emailVideoCmd.accesskey;"
|
||||||
oncommand="gContextMenu.sendMedia();"/>
|
oncommand="gContextMenu.sendMedia();"/>
|
||||||
<menu id="context-castvideo"
|
|
||||||
label="&castVideoCmd.label;"
|
|
||||||
accesskey="&castVideoCmd.accesskey;">
|
|
||||||
<menupopup id="context-castvideo-popup" onpopupshowing="gContextMenu.populateCastVideoMenu(this)"/>
|
|
||||||
</menu>
|
|
||||||
<menuitem id="context-sendaudio"
|
<menuitem id="context-sendaudio"
|
||||||
label="&emailAudioCmd.label;"
|
label="&emailAudioCmd.label;"
|
||||||
accesskey="&emailAudioCmd.accesskey;"
|
accesskey="&emailAudioCmd.accesskey;"
|
||||||
|
|
|
||||||
|
|
@ -436,8 +436,7 @@
|
||||||
|
|
||||||
<menu id="tools-menu"
|
<menu id="tools-menu"
|
||||||
label="&toolsMenu.label;"
|
label="&toolsMenu.label;"
|
||||||
accesskey="&toolsMenu.accesskey;"
|
accesskey="&toolsMenu.accesskey;">
|
||||||
onpopupshowing="mirrorShow(this)">
|
|
||||||
<menupopup id="menu_ToolsPopup"
|
<menupopup id="menu_ToolsPopup"
|
||||||
#ifdef MOZ_SERVICES_SYNC
|
#ifdef MOZ_SERVICES_SYNC
|
||||||
onpopupshowing="gSyncUI.updateUI();"
|
onpopupshowing="gSyncUI.updateUI();"
|
||||||
|
|
@ -486,13 +485,6 @@
|
||||||
key="key_viewInfo"
|
key="key_viewInfo"
|
||||||
#endif
|
#endif
|
||||||
command="View:PageInfo"/>
|
command="View:PageInfo"/>
|
||||||
<menu id="menu_mirrorTabCmd"
|
|
||||||
hidden="true"
|
|
||||||
accesskey="&mirrorTabCmd.accesskey;"
|
|
||||||
label="&mirrorTabCmd.label;">
|
|
||||||
<menupopup id="menu_mirrorTab-popup"
|
|
||||||
onpopupshowing="populateMirrorTabMenu(this)"/>
|
|
||||||
</menu>
|
|
||||||
<menuseparator id="prefSep"/>
|
<menuseparator id="prefSep"/>
|
||||||
<menuitem id="menu_preferences"
|
<menuitem id="menu_preferences"
|
||||||
label="&preferencesCmd2.label;"
|
label="&preferencesCmd2.label;"
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ Cu.import("resource://gre/modules/NotificationDB.jsm");
|
||||||
["AppConstants", "resource://gre/modules/AppConstants.jsm"],
|
["AppConstants", "resource://gre/modules/AppConstants.jsm"],
|
||||||
["BrowserUsageTelemetry", "resource:///modules/BrowserUsageTelemetry.jsm"],
|
["BrowserUsageTelemetry", "resource:///modules/BrowserUsageTelemetry.jsm"],
|
||||||
["BrowserUtils", "resource://gre/modules/BrowserUtils.jsm"],
|
["BrowserUtils", "resource://gre/modules/BrowserUtils.jsm"],
|
||||||
["CastingApps", "resource:///modules/CastingApps.jsm"],
|
|
||||||
["CharsetMenu", "resource://gre/modules/CharsetMenu.jsm"],
|
["CharsetMenu", "resource://gre/modules/CharsetMenu.jsm"],
|
||||||
["Color", "resource://gre/modules/Color.jsm"],
|
["Color", "resource://gre/modules/Color.jsm"],
|
||||||
["ContentSearch", "resource:///modules/ContentSearch.jsm"],
|
["ContentSearch", "resource:///modules/ContentSearch.jsm"],
|
||||||
|
|
@ -40,7 +39,6 @@ Cu.import("resource://gre/modules/NotificationDB.jsm");
|
||||||
["RecentWindow", "resource:///modules/RecentWindow.jsm"],
|
["RecentWindow", "resource:///modules/RecentWindow.jsm"],
|
||||||
["SessionStore", "resource:///modules/sessionstore/SessionStore.jsm"],
|
["SessionStore", "resource:///modules/sessionstore/SessionStore.jsm"],
|
||||||
["ShortcutUtils", "resource://gre/modules/ShortcutUtils.jsm"],
|
["ShortcutUtils", "resource://gre/modules/ShortcutUtils.jsm"],
|
||||||
["SimpleServiceDiscovery", "resource://gre/modules/SimpleServiceDiscovery.jsm"],
|
|
||||||
["SitePermissions", "resource:///modules/SitePermissions.jsm"],
|
["SitePermissions", "resource:///modules/SitePermissions.jsm"],
|
||||||
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
|
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
|
||||||
["Task", "resource://gre/modules/Task.jsm"],
|
["Task", "resource://gre/modules/Task.jsm"],
|
||||||
|
|
@ -2989,35 +2987,6 @@ function BrowserFullScreen()
|
||||||
window.fullScreen = !window.fullScreen;
|
window.fullScreen = !window.fullScreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
function mirrorShow(popup) {
|
|
||||||
let services = [];
|
|
||||||
if (Services.prefs.getBoolPref("browser.casting.enabled")) {
|
|
||||||
services = CastingApps.getServicesForMirroring();
|
|
||||||
}
|
|
||||||
popup.ownerDocument.getElementById("menu_mirrorTabCmd").hidden = !services.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mirrorMenuItemClicked(event) {
|
|
||||||
gBrowser.selectedBrowser.messageManager.sendAsyncMessage("SecondScreen:tab-mirror",
|
|
||||||
{service: event.originalTarget._service});
|
|
||||||
}
|
|
||||||
|
|
||||||
function populateMirrorTabMenu(popup) {
|
|
||||||
popup.innerHTML = null;
|
|
||||||
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let doc = popup.ownerDocument;
|
|
||||||
let services = CastingApps.getServicesForMirroring();
|
|
||||||
services.forEach(service => {
|
|
||||||
let item = doc.createElement("menuitem");
|
|
||||||
item.setAttribute("label", service.friendlyName);
|
|
||||||
item._service = service;
|
|
||||||
item.addEventListener("command", mirrorMenuItemClicked);
|
|
||||||
popup.appendChild(item);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getWebNavigation()
|
function getWebNavigation()
|
||||||
{
|
{
|
||||||
return gBrowser.webNavigation;
|
return gBrowser.webNavigation;
|
||||||
|
|
|
||||||
|
|
@ -199,21 +199,10 @@ nsContextMenu.prototype = {
|
||||||
// Send media URL (but not for canvas, since it's a big data: URL)
|
// Send media URL (but not for canvas, since it's a big data: URL)
|
||||||
this.showItem("context-sendimage", this.onImage);
|
this.showItem("context-sendimage", this.onImage);
|
||||||
this.showItem("context-sendvideo", this.onVideo);
|
this.showItem("context-sendvideo", this.onVideo);
|
||||||
this.showItem("context-castvideo", this.onVideo);
|
|
||||||
this.showItem("context-sendaudio", this.onAudio);
|
this.showItem("context-sendaudio", this.onAudio);
|
||||||
let mediaIsBlob = this.mediaURL.startsWith("blob:");
|
let mediaIsBlob = this.mediaURL.startsWith("blob:");
|
||||||
this.setItemAttr("context-sendvideo", "disabled", !this.mediaURL || mediaIsBlob);
|
this.setItemAttr("context-sendvideo", "disabled", !this.mediaURL || mediaIsBlob);
|
||||||
this.setItemAttr("context-sendaudio", "disabled", !this.mediaURL || mediaIsBlob);
|
this.setItemAttr("context-sendaudio", "disabled", !this.mediaURL || mediaIsBlob);
|
||||||
let shouldShowCast = Services.prefs.getBoolPref("browser.casting.enabled");
|
|
||||||
// getServicesForVideo alone would be sufficient here (it depends on
|
|
||||||
// SimpleServiceDiscovery.services), but SimpleServiceDiscovery is guaranteed
|
|
||||||
// to be already loaded, since we load it on startup in nsBrowserGlue,
|
|
||||||
// and CastingApps isn't, so check SimpleServiceDiscovery.services first
|
|
||||||
// to avoid needing to load CastingApps.jsm if we don't need to.
|
|
||||||
shouldShowCast = shouldShowCast && this.mediaURL &&
|
|
||||||
SimpleServiceDiscovery.services.length > 0 &&
|
|
||||||
CastingApps.getServicesForVideo(this.target).length > 0;
|
|
||||||
this.setItemAttr("context-castvideo", "disabled", !shouldShowCast);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
initViewItems: function CM_initViewItems() {
|
initViewItems: function CM_initViewItems() {
|
||||||
|
|
@ -1408,25 +1397,6 @@ nsContextMenu.prototype = {
|
||||||
MailIntegration.sendMessage(this.mediaURL, "");
|
MailIntegration.sendMessage(this.mediaURL, "");
|
||||||
},
|
},
|
||||||
|
|
||||||
castVideo: function() {
|
|
||||||
CastingApps.openExternal(this.target, window);
|
|
||||||
},
|
|
||||||
|
|
||||||
populateCastVideoMenu: function(popup) {
|
|
||||||
let videoEl = this.target;
|
|
||||||
popup.innerHTML = null;
|
|
||||||
let doc = popup.ownerDocument;
|
|
||||||
let services = CastingApps.getServicesForVideo(videoEl);
|
|
||||||
services.forEach(service => {
|
|
||||||
let item = doc.createElement("menuitem");
|
|
||||||
item.setAttribute("label", service.friendlyName);
|
|
||||||
item.addEventListener("command", event => {
|
|
||||||
CastingApps.sendVideoToService(videoEl, service);
|
|
||||||
});
|
|
||||||
popup.appendChild(item);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
playPlugin: function() {
|
playPlugin: function() {
|
||||||
gPluginHandler.contextMenuCommand(this.browser, this.target, "play");
|
gPluginHandler.contextMenuCommand(this.browser, this.target, "play");
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,21 +25,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "ReaderMode",
|
||||||
"resource://gre/modules/ReaderMode.jsm");
|
"resource://gre/modules/ReaderMode.jsm");
|
||||||
XPCOMUtils.defineLazyModuleGetter(this, "Readerable",
|
XPCOMUtils.defineLazyModuleGetter(this, "Readerable",
|
||||||
"resource://gre/modules/Readerable.jsm");
|
"resource://gre/modules/Readerable.jsm");
|
||||||
XPCOMUtils.defineLazyGetter(this, "SimpleServiceDiscovery", function() {
|
|
||||||
let ssdp = Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm", {}).SimpleServiceDiscovery;
|
|
||||||
// Register targets
|
|
||||||
ssdp.registerDevice({
|
|
||||||
id: "roku:ecp",
|
|
||||||
target: "roku:ecp",
|
|
||||||
factory: function(aService) {
|
|
||||||
Cu.import("resource://gre/modules/RokuApp.jsm");
|
|
||||||
return new RokuApp(aService);
|
|
||||||
},
|
|
||||||
types: ["video/mp4"],
|
|
||||||
extensions: ["mp4"]
|
|
||||||
});
|
|
||||||
return ssdp;
|
|
||||||
});
|
|
||||||
|
|
||||||
// TabChildGlobal
|
// TabChildGlobal
|
||||||
var global = this;
|
var global = this;
|
||||||
|
|
@ -94,19 +79,6 @@ addMessageListener("MixedContent:ReenableProtection", function() {
|
||||||
docShell.mixedContentChannel = null;
|
docShell.mixedContentChannel = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
addMessageListener("SecondScreen:tab-mirror", function(message) {
|
|
||||||
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let app = SimpleServiceDiscovery.findAppForService(message.data.service);
|
|
||||||
if (app) {
|
|
||||||
let width = content.innerWidth;
|
|
||||||
let height = content.innerHeight;
|
|
||||||
let viewport = {cssWidth: width, cssHeight: height, width: width, height: height};
|
|
||||||
app.mirror(function() {}, content, viewport, function() {}, content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var AboutHomeListener = {
|
var AboutHomeListener = {
|
||||||
init: function(chromeGlobal) {
|
init: function(chromeGlobal) {
|
||||||
chromeGlobal.addEventListener('AboutHomeLoad', this, false, true);
|
chromeGlobal.addEventListener('AboutHomeLoad', this, false, true);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "AlertsService", "@mozilla.org/alerts-s
|
||||||
["RemotePrompt", "resource:///modules/RemotePrompt.jsm"],
|
["RemotePrompt", "resource:///modules/RemotePrompt.jsm"],
|
||||||
["SessionStore", "resource:///modules/sessionstore/SessionStore.jsm"],
|
["SessionStore", "resource:///modules/sessionstore/SessionStore.jsm"],
|
||||||
["ShellService", "resource:///modules/ShellService.jsm"],
|
["ShellService", "resource:///modules/ShellService.jsm"],
|
||||||
["SimpleServiceDiscovery", "resource://gre/modules/SimpleServiceDiscovery.jsm"],
|
|
||||||
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
|
["TabCrashHandler", "resource:///modules/ContentCrashHandlers.jsm"],
|
||||||
["Task", "resource://gre/modules/Task.jsm"],
|
["Task", "resource://gre/modules/Task.jsm"],
|
||||||
["URLBarZoom", "resource:///modules/URLBarZoom.jsm"],
|
["URLBarZoom", "resource:///modules/URLBarZoom.jsm"],
|
||||||
|
|
@ -1017,32 +1016,8 @@ BrowserGlue.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_initServiceDiscovery: function () {
|
|
||||||
if (!Services.prefs.getBoolPref("browser.casting.enabled")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var rokuDevice = {
|
|
||||||
id: "roku:ecp",
|
|
||||||
target: "roku:ecp",
|
|
||||||
factory: function(aService) {
|
|
||||||
Cu.import("resource://gre/modules/RokuApp.jsm");
|
|
||||||
return new RokuApp(aService);
|
|
||||||
},
|
|
||||||
types: ["video/mp4"],
|
|
||||||
extensions: ["mp4"]
|
|
||||||
};
|
|
||||||
|
|
||||||
// Register targets
|
|
||||||
SimpleServiceDiscovery.registerDevice(rokuDevice);
|
|
||||||
|
|
||||||
// Search for devices continuously every 120 seconds
|
|
||||||
SimpleServiceDiscovery.search(120 * 1000);
|
|
||||||
},
|
|
||||||
|
|
||||||
// All initial windows have opened.
|
// All initial windows have opened.
|
||||||
_onWindowsRestored: function BG__onWindowsRestored() {
|
_onWindowsRestored: function BG__onWindowsRestored() {
|
||||||
this._initServiceDiscovery();
|
|
||||||
|
|
||||||
// Show update notification, if needed.
|
// Show update notification, if needed.
|
||||||
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
|
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
|
||||||
this._showUpdateNotification();
|
this._showUpdateNotification();
|
||||||
|
|
|
||||||
|
|
@ -94,8 +94,6 @@ when there are no windows but Firefox is still running. -->
|
||||||
<!ENTITY pageInfoCmd.label "Page Info">
|
<!ENTITY pageInfoCmd.label "Page Info">
|
||||||
<!ENTITY pageInfoCmd.accesskey "I">
|
<!ENTITY pageInfoCmd.accesskey "I">
|
||||||
<!ENTITY pageInfoCmd.commandkey "i">
|
<!ENTITY pageInfoCmd.commandkey "i">
|
||||||
<!ENTITY mirrorTabCmd.label "Mirror Tab">
|
|
||||||
<!ENTITY mirrorTabCmd.accesskey "m">
|
|
||||||
<!-- LOCALIZATION NOTE (enterFullScreenCmd.label, exitFullScreenCmd.label):
|
<!-- LOCALIZATION NOTE (enterFullScreenCmd.label, exitFullScreenCmd.label):
|
||||||
These should match what Safari and other Apple applications use on OS X Lion. -->
|
These should match what Safari and other Apple applications use on OS X Lion. -->
|
||||||
<!ENTITY enterFullScreenCmd.label "Enter Full Screen">
|
<!ENTITY enterFullScreenCmd.label "Enter Full Screen">
|
||||||
|
|
@ -492,8 +490,6 @@ These should match what Safari and other Apple applications use on OS X Lion. --
|
||||||
<!ENTITY emailImageCmd.accesskey "g">
|
<!ENTITY emailImageCmd.accesskey "g">
|
||||||
<!ENTITY emailVideoCmd.label "Email Video…">
|
<!ENTITY emailVideoCmd.label "Email Video…">
|
||||||
<!ENTITY emailVideoCmd.accesskey "a">
|
<!ENTITY emailVideoCmd.accesskey "a">
|
||||||
<!ENTITY castVideoCmd.label "Send Video To Device">
|
|
||||||
<!ENTITY castVideoCmd.accesskey "e">
|
|
||||||
<!ENTITY emailAudioCmd.label "Email Audio…">
|
<!ENTITY emailAudioCmd.label "Email Audio…">
|
||||||
<!ENTITY emailAudioCmd.accesskey "a">
|
<!ENTITY emailAudioCmd.accesskey "a">
|
||||||
<!ENTITY playPluginCmd.label "Activate this plugin">
|
<!ENTITY playPluginCmd.label "Activate this plugin">
|
||||||
|
|
|
||||||
|
|
@ -1,164 +0,0 @@
|
||||||
// -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
|
||||||
/* 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/. */
|
|
||||||
"use strict";
|
|
||||||
this.EXPORTED_SYMBOLS = ["CastingApps"];
|
|
||||||
|
|
||||||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
|
||||||
Cu.import("resource://gre/modules/SimpleServiceDiscovery.jsm");
|
|
||||||
|
|
||||||
|
|
||||||
var CastingApps = {
|
|
||||||
_sendEventToVideo: function (element, data) {
|
|
||||||
let event = element.ownerDocument.createEvent("CustomEvent");
|
|
||||||
event.initCustomEvent("media-videoCasting", false, true, JSON.stringify(data));
|
|
||||||
element.dispatchEvent(event);
|
|
||||||
},
|
|
||||||
|
|
||||||
makeURI: function (url, charset, baseURI) {
|
|
||||||
return Services.io.newURI(url, charset, baseURI);
|
|
||||||
},
|
|
||||||
|
|
||||||
getVideo: function (element) {
|
|
||||||
if (!element) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
let extensions = SimpleServiceDiscovery.getSupportedExtensions();
|
|
||||||
let types = SimpleServiceDiscovery.getSupportedMimeTypes();
|
|
||||||
|
|
||||||
// Grab the poster attribute from the <video>
|
|
||||||
let posterURL = element.poster;
|
|
||||||
|
|
||||||
// First, look to see if the <video> has a src attribute
|
|
||||||
let sourceURL = element.src;
|
|
||||||
|
|
||||||
// If empty, try the currentSrc
|
|
||||||
if (!sourceURL) {
|
|
||||||
sourceURL = element.currentSrc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sourceURL) {
|
|
||||||
// Use the file extension to guess the mime type
|
|
||||||
let sourceURI = this.makeURI(sourceURL, null, this.makeURI(element.baseURI));
|
|
||||||
if (this.allowableExtension(sourceURI, extensions)) {
|
|
||||||
return { element: element, source: sourceURI.spec, poster: posterURL, sourceURI: sourceURI};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, look to see if there is a <source> child element that meets
|
|
||||||
// our needs
|
|
||||||
let sourceNodes = element.getElementsByTagName("source");
|
|
||||||
for (let sourceNode of sourceNodes) {
|
|
||||||
let sourceURI = this.makeURI(sourceNode.src, null, this.makeURI(sourceNode.baseURI));
|
|
||||||
|
|
||||||
// Using the type attribute is our ideal way to guess the mime type. Otherwise,
|
|
||||||
// fallback to using the file extension to guess the mime type
|
|
||||||
if (this.allowableMimeType(sourceNode.type, types) || this.allowableExtension(sourceURI, extensions)) {
|
|
||||||
return { element: element, source: sourceURI.spec, poster: posterURL, sourceURI: sourceURI, type: sourceNode.type };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
sendVideoToService: function (videoElement, service) {
|
|
||||||
if (!service)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let video = this.getVideo(videoElement);
|
|
||||||
if (!video) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure we have a player app for the given service
|
|
||||||
let app = SimpleServiceDiscovery.findAppForService(service);
|
|
||||||
if (!app)
|
|
||||||
return;
|
|
||||||
|
|
||||||
video.title = videoElement.ownerGlobal.top.document.title;
|
|
||||||
if (video.element) {
|
|
||||||
// If the video is currently playing on the device, pause it
|
|
||||||
if (!video.element.paused) {
|
|
||||||
video.element.pause();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app.stop(() => {
|
|
||||||
app.start(started => {
|
|
||||||
if (!started) {
|
|
||||||
Cu.reportError("CastingApps: Unable to start app");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
app.remoteMedia(remoteMedia => {
|
|
||||||
if (!remoteMedia) {
|
|
||||||
Cu.reportError("CastingApps: Failed to create remotemedia");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.session = {
|
|
||||||
service: service,
|
|
||||||
app: app,
|
|
||||||
remoteMedia: remoteMedia,
|
|
||||||
data: {
|
|
||||||
title: video.title,
|
|
||||||
source: video.source,
|
|
||||||
poster: video.poster
|
|
||||||
},
|
|
||||||
videoRef: Cu.getWeakReference(video.element)
|
|
||||||
};
|
|
||||||
}, this);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
getServicesForVideo: function (videoElement) {
|
|
||||||
let video = this.getVideo(videoElement);
|
|
||||||
if (!video) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
let filteredServices = SimpleServiceDiscovery.services.filter(service => {
|
|
||||||
return this.allowableExtension(video.sourceURI, service.extensions) ||
|
|
||||||
this.allowableMimeType(video.type, service.types);
|
|
||||||
});
|
|
||||||
|
|
||||||
return filteredServices;
|
|
||||||
},
|
|
||||||
|
|
||||||
getServicesForMirroring: function () {
|
|
||||||
return SimpleServiceDiscovery.services.filter(service => service.mirror);
|
|
||||||
},
|
|
||||||
|
|
||||||
// RemoteMedia callback API methods
|
|
||||||
onRemoteMediaStart: function (remoteMedia) {
|
|
||||||
if (!this.session) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
remoteMedia.load(this.session.data);
|
|
||||||
|
|
||||||
let video = this.session.videoRef.get();
|
|
||||||
if (video) {
|
|
||||||
this._sendEventToVideo(video, { active: true });
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onRemoteMediaStop: function (remoteMedia) {
|
|
||||||
},
|
|
||||||
|
|
||||||
onRemoteMediaStatus: function (remoteMedia) {
|
|
||||||
},
|
|
||||||
|
|
||||||
allowableExtension: function (uri, extensions) {
|
|
||||||
return (uri instanceof Ci.nsIURL) && extensions.indexOf(uri.fileExtension) != -1;
|
|
||||||
},
|
|
||||||
|
|
||||||
allowableMimeType: function (type, types) {
|
|
||||||
return types.indexOf(type) != -1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
@ -9,7 +9,6 @@ EXTRA_JS_MODULES += [
|
||||||
'AboutNewTab.jsm',
|
'AboutNewTab.jsm',
|
||||||
'AttributionCode.jsm',
|
'AttributionCode.jsm',
|
||||||
'BrowserUsageTelemetry.jsm',
|
'BrowserUsageTelemetry.jsm',
|
||||||
'CastingApps.jsm',
|
|
||||||
'ContentClick.jsm',
|
'ContentClick.jsm',
|
||||||
'ContentCrashHandlers.jsm',
|
'ContentCrashHandlers.jsm',
|
||||||
'ContentLinkHandler.jsm',
|
'ContentLinkHandler.jsm',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue