Bug 1279865 - Don't run TimeMarchesOn if the MediaElement is not played. r=rillian

1. If mHasUserInteraction MediaElement is false, don't run the TimeMarchesOn because the element is not played. 2. Update the activeCueList only in TimeMarchesOn(). 3. Run TimeMarchesOn() at the beginning of play. r=rillian

MozReview-Commit-ID: BhwsIfRm3B2

--HG--
extra : rebase_source : 9713d4f467f1d708f65a25e54435d0c6e8ff1816
This commit is contained in:
bechen 2016-06-30 13:31:56 +08:00
Родитель 8b5eba1257
Коммит 30cae3d32d
4 изменённых файлов: 12 добавлений и 6 удалений

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

@ -2599,6 +2599,7 @@ HTMLMediaElement::PlayInternal(bool aCallerIsChrome)
break;
case nsIDOMHTMLMediaElement::HAVE_FUTURE_DATA:
case nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA:
FireTimeUpdate(false);
DispatchAsyncEvent(NS_LITERAL_STRING("playing"));
break;
}

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

@ -713,6 +713,14 @@ public:
}
}
bool GetHasUserInteraction()
{
return mHasUserInteraction;
}
// A method to check whether we are currently playing.
bool IsCurrentlyPlaying() const;
/**
* A public wrapper for FinishDecoderSetup()
*/
@ -1138,9 +1146,6 @@ protected:
// A method to check if we are playing through the AudioChannel.
bool IsPlayingThroughTheAudioChannel() const;
// A method to check whether we are currently playing.
bool IsCurrentlyPlaying() const;
// Update the audio channel playing state
void UpdateAudioChannelPlayingState();

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

@ -524,7 +524,8 @@ TextTrackManager::DispatchTimeMarchesOn()
// enqueue the current playback position and whether only that changed
// through its usual monotonic increase during normal playback; current
// executing call upon completion will check queue for further 'work'.
if (!mTimeMarchesOnDispatched && !mShutdown) {
if (!mTimeMarchesOnDispatched && !mShutdown &&
(mMediaElement->GetHasUserInteraction() || mMediaElement->IsCurrentlyPlaying())) {
NS_DispatchToMainThread(NewRunnableMethod(this, &TextTrackManager::TimeMarchesOn));
mTimeMarchesOnDispatched = true;
}
@ -570,6 +571,7 @@ TextTrackManager::TimeMarchesOn()
TextTrack* ttrack = mTextTracks->IndexedGetter(index, dummy);
if (ttrack && dummy) {
// TODO: call GetCueListByTimeInterval on mNewCues?
ttrack->UpdateActiveCueList();
TextTrackCueList* activeCueList = ttrack->GetActiveCues();
if (activeCueList) {
for (uint32_t i = 0; i < activeCueList->Length(); ++i) {

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

@ -215,7 +215,6 @@ TextTrack::UpdateActiveCueList()
TextTrackCueList*
TextTrack::GetActiveCues() {
if (mMode != TextTrackMode::Disabled) {
UpdateActiveCueList();
return mActiveCueList;
}
return nullptr;
@ -225,7 +224,6 @@ void
TextTrack::GetActiveCueArray(nsTArray<RefPtr<TextTrackCue> >& aCues)
{
if (mMode != TextTrackMode::Disabled) {
UpdateActiveCueList();
mActiveCueList->GetArray(aCues);
}
}