Bug 841239 - Have HTMLMediaElement.canPlayType respond affirmatively to codecs=mp3 and audio/x-m4a. r=padenot

This commit is contained in:
Chris Pearce 2013-02-27 09:27:43 +13:00
parent 68d9b3d62a
commit a96f6b66a2
3 changed files with 28 additions and 8 deletions

View File

@ -2187,6 +2187,11 @@ nsHTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
aResult.AssignLiteral("maybe");
break;
}
LOG(PR_LOG_DEBUG, ("%p CanPlayType(%s) = \"%s\"", this,
NS_ConvertUTF16toUTF8(aType).get(),
NS_ConvertUTF16toUTF8(aResult).get()));
return NS_OK;
}

View File

@ -7,6 +7,14 @@ function check_mp4(v, enabled) {
check("video/mp4", "maybe");
check("audio/mp4", "maybe");
check("audio/mpeg", "maybe");
check("audio/mp3", "maybe");
check("audio/x-m4a", "maybe");
// Not the MIME type that other browsers respond to, so we won't either.
check("audio/m4a", "");
// Only Safari responds affirmatively to "audio/aac",
// so we'll let x-m4a cover aac support.
check("audio/aac", "");
check("video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"", "probably");
check("video/mp4; codecs=\"avc1.42001E, mp4a.40.2\"", "probably");
@ -22,6 +30,14 @@ function check_mp4(v, enabled) {
check("video/mp4; codecs=\"avc1.64001E\"", "probably");
check("video/mp4; codecs=\"avc1.64001F\"", "probably");
check("audio/mpeg; codecs=\"mp3\"", "probably");
check("audio/mpeg; codecs=mp3", "probably");
check("audio/mp3; codecs=\"mp3\"", "probably");
check("audio/mp3; codecs=mp3", "probably");
check("audio/mp4; codecs=\"mp4a.40.2\"", "probably");
check("audio/mp4; codecs=mp4a.40.2", "probably");
check("audio/x-m4a; codecs=\"mp4a.40.2\"", "probably");
check("audio/x-m4a; codecs=mp4a.40.2", "probably");
}

View File

@ -26,19 +26,17 @@ WMFDecoder::GetSupportedCodecs(const nsACString& aType,
NS_FAILED(LoadDLLs()))
return false;
// MP3 is specified to have no codecs in its "type" param:
// http://wiki.whatwg.org/wiki/Video_type_parameters#MPEG
// So specify an empty codecs list, so that if script specifies
// a "type" param with codecs, it will be reported as not supported
// as per the spec.
// Assume that if LoadDLLs() didn't fail, we can playback the types that
// we know should be supported on Windows 7+ using WMF.
static char const *const mp3AudioCodecs[] = {
"mp3",
nullptr
};
if (aType.EqualsASCII("audio/mpeg")) {
if (aType.EqualsASCII("audio/mpeg") ||
aType.EqualsASCII("audio/mp3")) {
if (aCodecList) {
*aCodecList = mp3AudioCodecs;
}
// Assume that if LoadDLLs() didn't fail, we can decode MP3.
return true;
}
@ -47,7 +45,8 @@ WMFDecoder::GetSupportedCodecs(const nsACString& aType,
"mp4a.40.2", // AAC-LC
nullptr
};
if (aType.EqualsASCII("audio/mp4")) {
if (aType.EqualsASCII("audio/mp4") ||
aType.EqualsASCII("audio/x-m4a")) {
if (aCodecList) {
*aCodecList = aacAudioCodecs;
}