Bug 1192818 - part4 : only mute media element if there is alive track. r=jwwang

If we don't have any alive track in MediaTrackList, we don't need to mute
MediaElement.

MozReview-Commit-ID: 9vY692O7N0e
This commit is contained in:
Alastor Wu
2017-02-23 14:16:44 +08:00
parent ea15b79fc6
commit f0cc040c78

View File

@@ -2039,15 +2039,19 @@ void HTMLMediaElement::NotifyMediaTrackDisabled(MediaTrack* aTrack)
(!aTrack->AsVideoTrack() || !aTrack->AsVideoTrack()->Selected()));
if (aTrack->AsAudioTrack()) {
bool shouldMute = true;
for (uint32_t i = 0; i < AudioTracks()->Length(); ++i) {
if ((*AudioTracks())[i]->Enabled()) {
shouldMute = false;
break;
// If we don't have any alive track , we don't need to mute MediaElement.
if (AudioTracks()->Length() > 0) {
bool shouldMute = true;
for (uint32_t i = 0; i < AudioTracks()->Length(); ++i) {
if ((*AudioTracks())[i]->Enabled()) {
shouldMute = false;
break;
}
}
if (shouldMute) {
SetMutedInternal(mMuted | MUTED_BY_AUDIO_TRACK);
}
}
if (shouldMute) {
SetMutedInternal(mMuted | MUTED_BY_AUDIO_TRACK);
}
} else if (aTrack->AsVideoTrack()) {
if (mSrcStream) {