Bug 1282410 - part1 : open unsupported type media. r=cpearce

This commit is contained in:
Alastor Wu
2016-07-06 10:34:29 +08:00
committed by James Willcox
parent a05005f7b3
commit a73b58fc73
3 changed files with 45 additions and 0 deletions

View File

@@ -1031,6 +1031,7 @@ void HTMLMediaElement::NoSupportedMediaSourceError()
DispatchAsyncEvent(NS_LITERAL_STRING("error"));
ChangeDelayLoadStatus(false);
UpdateAudioChannelPlayingState();
OpenUnsupportedMediaWithExtenalAppIfNeeded();
}
typedef void (HTMLMediaElement::*SyncSectionFn)();
@@ -2706,6 +2707,10 @@ HTMLMediaElement::PlayInternal(bool aCallerIsChrome)
UpdateSrcMediaStreamPlaying();
UpdateAudioChannelPlayingState();
// The check here is to handle the case that the media element starts playing
// after it loaded fail. eg. preload the data before playing.
OpenUnsupportedMediaWithExtenalAppIfNeeded();
return NS_OK;
}
@@ -6013,6 +6018,41 @@ HTMLMediaElement::IsAudible() const
return true;
}
bool
HTMLMediaElement::HaveFailedWithSourceNotSupportedError() const
{
if (!mError) {
return false;
}
uint16_t errorCode;
mError->GetCode(&errorCode);
return (mNetworkState == nsIDOMHTMLMediaElement::NETWORK_NO_SOURCE &&
errorCode == nsIDOMMediaError::MEDIA_ERR_SRC_NOT_SUPPORTED);
}
void
HTMLMediaElement::OpenUnsupportedMediaWithExtenalAppIfNeeded()
{
if (!Preferences::GetBool("media.openUnsupportedTypeWithExternalApp")) {
return;
}
if (!HaveFailedWithSourceNotSupportedError()) {
return;
}
// If media doesn't start playing, we don't need to open it.
if (mPaused) {
return;
}
nsContentUtils::DispatchTrustedEvent(OwnerDoc(), static_cast<nsIContent*>(this),
NS_LITERAL_STRING("OpenMediaWithExtenalApp"),
true,
true);
}
static const char* VisibilityString(Visibility aVisibility) {
switch(aVisibility) {
case Visibility::UNTRACKED: {