Bug 1022025, r=bholley,mfinkle

This commit is contained in:
Gijs Kruitbosch 2014-06-14 22:01:55 +01:00
parent 125721fd9c
commit e07b6ed7da
5 changed files with 42 additions and 22 deletions

View File

@ -488,6 +488,26 @@ public:
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;
void SetMozSrcObject(DOMMediaStream& aValue);
@ -1093,6 +1113,14 @@ protected:
// video controls
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.
bool mAudioCaptured;

View File

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

View File

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

View File

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

View File

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