Bug 1022025, r=bholley,mfinkle

This commit is contained in:
Gijs Kruitbosch 2014-06-14 22:01:55 +01:00
Родитель 125721fd9c
Коммит e07b6ed7da
5 изменённых файлов: 42 добавлений и 22 удалений

Просмотреть файл

@ -488,6 +488,26 @@ public:
mStatsShowing = aShow; mStatsShowing = aShow;
} }
bool MozAllowCasting() const
{
return mAllowCasting;
}
void SetMozAllowCasting(bool aShow)
{
mAllowCasting = aShow;
}
bool MozIsCasting() const
{
return mIsCasting;
}
void SetMozIsCasting(bool aShow)
{
mIsCasting = aShow;
}
already_AddRefed<DOMMediaStream> GetMozSrcObject() const; already_AddRefed<DOMMediaStream> GetMozSrcObject() const;
void SetMozSrcObject(DOMMediaStream& aValue); void SetMozSrcObject(DOMMediaStream& aValue);
@ -1093,6 +1113,14 @@ protected:
// video controls // video controls
bool mStatsShowing; bool mStatsShowing;
// The following two fields are here for the private storage of the builtin
// video controls, and control 'casting' of the video to external devices
// (TVs, projectors etc.)
// True if casting is currently allowed
bool mAllowCasting;
// True if currently casting this video
bool mIsCasting;
// True if the sound is being captured. // True if the sound is being captured.
bool mAudioCaptured; bool mAudioCaptured;

Просмотреть файл

@ -1992,6 +1992,8 @@ HTMLMediaElement::HTMLMediaElement(already_AddRefed<nsINodeInfo>& aNodeInfo)
mPaused(true), mPaused(true),
mMuted(0), mMuted(0),
mStatsShowing(false), mStatsShowing(false),
mAllowCasting(false),
mIsCasting(false),
mAudioCaptured(false), mAudioCaptured(false),
mPlayingBeforeSeek(false), mPlayingBeforeSeek(false),
mPausedForInactiveDocumentOrChannel(false), mPausedForInactiveDocumentOrChannel(false),

Просмотреть файл

@ -104,6 +104,8 @@ partial interface HTMLMediaElement {
// NB: for internal use with the video controls: // NB: for internal use with the video controls:
[Func="IsChromeOrXBL"] attribute boolean mozMediaStatisticsShowing; [Func="IsChromeOrXBL"] attribute boolean mozMediaStatisticsShowing;
[Func="IsChromeOrXBL"] attribute boolean mozAllowCasting;
[Func="IsChromeOrXBL"] attribute boolean mozIsCasting;
// Mozilla extension: stream capture // Mozilla extension: stream capture
[Throws] [Throws]

Просмотреть файл

@ -250,8 +250,7 @@ var CastingApps = {
// Look for a castable <video> that is playing, and start casting it // Look for a castable <video> that is playing, and start casting it
let videos = browser.contentDocument.querySelectorAll("video"); let videos = browser.contentDocument.querySelectorAll("video");
for (let video of videos) { for (let video of videos) {
let unwrappedVideo = XPCNativeWrapper.unwrap(video); if (!video.paused && video.mozAllowCasting) {
if (!video.paused && unwrappedVideo.mozAllowCasting) {
UITelemetry.addEvent("cast.1", "pageaction", null); UITelemetry.addEvent("cast.1", "pageaction", null);
CastingApps.openExternal(video, 0, 0); CastingApps.openExternal(video, 0, 0);
return; return;
@ -270,13 +269,12 @@ var CastingApps = {
let castableVideo = null; let castableVideo = null;
let videos = aBrowser.contentDocument.querySelectorAll("video"); let videos = aBrowser.contentDocument.querySelectorAll("video");
for (let video of videos) { for (let video of videos) {
let unwrappedVideo = XPCNativeWrapper.unwrap(video); if (video.mozIsCasting) {
if (unwrappedVideo.mozIsCasting) {
// This <video> is cast-active. Break out of loop. // This <video> is cast-active. Break out of loop.
return video; return video;
} }
if (!video.paused && unwrappedVideo.mozAllowCasting) { if (!video.paused && video.mozAllowCasting) {
// This <video> is cast-ready. Keep looking so cast-active could be found. // This <video> is cast-ready. Keep looking so cast-active could be found.
castableVideo = video; castableVideo = video;
} }
@ -324,15 +322,14 @@ var CastingApps = {
// 1. The video is actively being cast // 1. The video is actively being cast
// 2. The video is allowed to be cast and is currently playing // 2. The video is allowed to be cast and is currently playing
// Both states have the same action: Show the cast page action // Both states have the same action: Show the cast page action
let unwrappedVideo = XPCNativeWrapper.unwrap(aVideo); if (aVideo.mozIsCasting) {
if (unwrappedVideo.mozIsCasting) {
this.pageAction.id = NativeWindow.pageactions.add({ this.pageAction.id = NativeWindow.pageactions.add({
title: Strings.browser.GetStringFromName("contextmenu.castToScreen"), title: Strings.browser.GetStringFromName("contextmenu.castToScreen"),
icon: "drawable://casting_active", icon: "drawable://casting_active",
clickCallback: this.pageAction.click, clickCallback: this.pageAction.click,
important: true important: true
}); });
} else if (unwrappedVideo.mozAllowCasting) { } else if (aVideo.mozAllowCasting) {
this.pageAction.id = NativeWindow.pageactions.add({ this.pageAction.id = NativeWindow.pageactions.add({
title: Strings.browser.GetStringFromName("contextmenu.castToScreen"), title: Strings.browser.GetStringFromName("contextmenu.castToScreen"),
icon: "drawable://casting", icon: "drawable://casting",

Просмотреть файл

@ -1671,27 +1671,19 @@
}, },
isVideoCasting : function () { isVideoCasting : function () {
let unwrappedVideo = XPCNativeWrapper.unwrap(this.video); if (this.video.mozIsCasting)
if (unwrappedVideo.mozIsCasting)
return true; return true;
return false; return false;
}, },
updateCasting : function (eventDetail) { updateCasting : function (eventDetail) {
let unwrappedVideo = XPCNativeWrapper.unwrap(this.video);
let castingData = JSON.parse(eventDetail); let castingData = JSON.parse(eventDetail);
if ("allow" in castingData) { if ("allow" in castingData) {
if (castingData.allow) this.video.mozAllowCasting = !!castingData.allow;
unwrappedVideo.mozAllowCasting = true;
else
delete unwrappedVideo.mozAllowCasting;
} }
if ("active" in castingData) { if ("active" in castingData) {
if (castingData.active) this.video.mozIsCasting = !!castingData.active;
unwrappedVideo.mozIsCasting = true;
else
delete unwrappedVideo.mozIsCasting;
} }
this.setCastButtonState(); this.setCastButtonState();
}, },
@ -1701,13 +1693,12 @@
}, },
setCastButtonState : function () { setCastButtonState : function () {
let unwrappedVideo = XPCNativeWrapper.unwrap(this.video); if (this.isAudioOnly || !this.video.mozAllowCasting) {
if (this.isAudioOnly || !unwrappedVideo.mozAllowCasting) {
this.castingButton.hidden = true; this.castingButton.hidden = true;
return; return;
} }
if (unwrappedVideo.mozIsCasting) { if (this.video.mozIsCasting) {
this.castingButton.setAttribute("active", "true"); this.castingButton.setAttribute("active", "true");
} else { } else {
this.castingButton.removeAttribute("active"); this.castingButton.removeAttribute("active");