Bug 495145. Don't change the state away from ENDED if we try to pause in the ENDED state. r=doublec

This commit is contained in:
Robert O'Callahan 2009-05-28 15:49:22 +12:00
parent fa87f5d65b
commit cb8e86ef15
5 changed files with 146 additions and 2 deletions

View File

@ -1774,7 +1774,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsOggDecoder, nsIObserver)
void nsOggDecoder::Pause()
{
nsAutoMonitor mon(mMonitor);
if (mPlayState == PLAY_STATE_SEEKING) {
if (mPlayState == PLAY_STATE_SEEKING || mPlayState == PLAY_STATE_ENDED) {
mNextState = PLAY_STATE_PAUSED;
return;
}

View File

@ -406,7 +406,7 @@ nsWaveStateMachine::Pause()
nsAutoMonitor monitor(mMonitor);
mPaused = PR_TRUE;
if (mState == STATE_LOADING_METADATA || mState == STATE_SEEKING ||
mState == STATE_BUFFERING) {
mState == STATE_BUFFERING || mState == STATE_ENDED) {
mNextState = STATE_PAUSED;
} else if (mState == STATE_PLAYING) {
ChangeState(STATE_PAUSED);

View File

@ -72,6 +72,7 @@ _TEST_FILES += \
test_bug468190.html \
test_bug482461.html \
test_bug493187.html \
test_bug495145.html \
test_can_play_type_ogg.html \
test_closing_connections.html \
test_contentDuration1.html \
@ -146,6 +147,7 @@ _TEST_FILES += \
test_bug463162.xhtml \
test_bug465498.html \
test_bug468190_wav.html \
test_bug495145_wav.html \
test_can_play_type_wave.html \
test_paused_after_ended.html \
test_wav_8bit.html \

View File

@ -0,0 +1,71 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=495145
-->
<head>
<title>Bug 495145 - pausing while ended shouldn't cause problems</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495145">Mozilla Bug 495145</a>
<pre id="test">
<script class="testbody" type="text/javascript">
var v;
var completed = false;
var testFinishedCount = 0;
var ended1Count = 0;
function finishTest() {
++testFinishedCount;
if (testFinishedCount == 2) {
completed = true;
SimpleTest.finish();
}
}
function start(event) {
event.target.play();
}
function ended1(event) {
if (completed)
return;
++ended1Count;
if (ended1Count == 2) {
ok(true, "Playing after pause while ended works");
finishTest();
return;
}
event.target.pause();
event.target.play();
}
function ended2(event) {
if (completed)
return;
event.target.pause();
event.target.currentTime = 0;
}
function seeked2(event) {
if (completed)
return;
ok(event.target.paused, "Paused after seek after pause while ended");
finishTest();
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<video src='320x240.ogv' onloadeddata='start(event)' onended='ended1(event)'></video>
<video src='320x240.ogv' onloadeddata='start(event)' onended='ended2(event)' onseeked="seeked2(event)"></video>
</body>
</html>

View File

@ -0,0 +1,71 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=495145
-->
<head>
<title>Bug 495145 - pausing while ended shouldn't cause problems</title>
<script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495145">Mozilla Bug 495145</a>
<pre id="test">
<script class="testbody" type="text/javascript">
var v;
var completed = false;
var testFinishedCount = 0;
var ended1Count = 0;
function finishTest() {
++testFinishedCount;
if (testFinishedCount == 2) {
completed = true;
SimpleTest.finish();
}
}
function start(event) {
event.target.play();
}
function ended1(event) {
if (completed)
return;
++ended1Count;
if (ended1Count == 2) {
ok(true, "Playing after pause while ended works");
finishTest();
return;
}
event.target.pause();
event.target.play();
}
function ended2(event) {
if (completed)
return;
event.target.pause();
event.target.currentTime = 0;
}
function seeked2(event) {
if (completed)
return;
ok(event.target.paused, "Paused after seek after pause while ended");
finishTest();
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<audio src='r11025_u8_c1.wav' onloadeddata='start(event)' onended='ended1(event)'></audio>
<audio src='r11025_u8_c1.wav' onloadeddata='start(event)' onended='ended2(event)' onseeked="seeked2(event)"></audio>
</body>
</html>