Bug 475441. Make nsOggDecoder seek instead of reloading when asked to replay after playback has ended. r=doublec

This commit is contained in:
Robert O'Callahan 2009-04-01 14:07:10 +13:00
parent 64b6352d5f
commit 32245a0582

View File

@ -1399,6 +1399,8 @@ nsresult nsOggDecoder::Play()
mNextState = PLAY_STATE_PLAYING;
return NS_OK;
}
if (mPlayState == PLAY_STATE_ENDED)
return Seek(0);
ChangeState(PLAY_STATE_PLAYING);
@ -1418,7 +1420,11 @@ nsresult nsOggDecoder::Seek(float aTime)
// above will result in the new seek occurring when the current seek
// completes.
if (mPlayState != PLAY_STATE_SEEKING) {
mNextState = mPlayState;
if (mPlayState == PLAY_STATE_ENDED) {
mNextState = PLAY_STATE_PLAYING;
} else {
mNextState = mPlayState;
}
ChangeState(PLAY_STATE_SEEKING);
}
@ -1656,7 +1662,8 @@ void nsOggDecoder::PlaybackEnded()
if (mShuttingDown || mPlayState == nsOggDecoder::PLAY_STATE_SEEKING)
return;
Stop();
ChangeState(PLAY_STATE_ENDED);
if (mElement) {
mElement->PlaybackEnded();
}
@ -1867,20 +1874,6 @@ void nsOggDecoder::ChangeState(PlayState aState)
return;
}
if (mPlayState == PLAY_STATE_ENDED &&
aState != PLAY_STATE_SHUTDOWN) {
// If we've completed playback then the decode and display threads
// have been shutdown. To honor the state change request we need
// to reload the resource and restart the threads.
// Like seeking, this will require opening a new channel, which means
// we may not actually get the same resource --- a server may send
// us something different.
mNextState = aState;
mPlayState = PLAY_STATE_LOADING;
Load(mURI, nsnull, nsnull);
return;
}
mPlayState = aState;
switch (aState) {
case PLAY_STATE_PAUSED: