Bug 499874 - Move Wave decoder to ended state when seeking to end of media. r=roc

--HG--
extra : rebase_source : 8cad22f7269f9e4a9ff0f9885036b2a47f525b7d
This commit is contained in:
Matthew Gregan 2009-10-20 15:48:03 +13:00
Родитель da8dcc38aa
Коммит 63158cc63b
5 изменённых файлов: 44 добавлений и 13 удалений

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

@ -85,6 +85,7 @@ _TEST_FILES = \
test_audio2.html \ test_audio2.html \
test_autobuffer.html \ test_autobuffer.html \
test_autoplay.html \ test_autoplay.html \
test_bug495300.html \
test_can_play_type.html \ test_can_play_type.html \
test_constants.html \ test_constants.html \
test_controls.html \ test_controls.html \
@ -182,7 +183,6 @@ _TEST_FILES += \
test_bug486646.html \ test_bug486646.html \
test_bug493187.html \ test_bug493187.html \
test_bug495145.html \ test_bug495145.html \
test_bug495300.html \
test_bug495319.html \ test_bug495319.html \
test_closing_connections.html \ test_closing_connections.html \
test_contentDuration1.html \ test_contentDuration1.html \

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

@ -86,6 +86,7 @@ var gErrorTests = [
var gSeekTests = [ var gSeekTests = [
{ name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 }, { name:"r11025_s16_c1.wav", type:"audio/x-wav", duration:1.0 },
{ name:"seek.ogv", type:"video/ogg", duration:3.966 }, { name:"seek.ogv", type:"video/ogg", duration:3.966 },
{ name:"320x240.ogv", type:"video/ogg", duration:0.233 },
{ name:"bogus.duh", type:"bogus/duh", duration:123 } { name:"bogus.duh", type:"bogus/duh", duration:123 }
]; ];

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

@ -9,26 +9,51 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=495300
<script type="text/javascript" src="/MochiKit/packed.js"></script> <script type="text/javascript" src="/MochiKit/packed.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript" src="manifest.js"></script>
</head> </head>
<body> <body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495300">Mozilla Bug 495300</a> <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=495300">Mozilla Bug 495300</a>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript"> <script class="testbody" type="text/javascript">
var v; var testsWaiting = 0;
var completed = false;
function start(event) { function mediaEnded(event) {
event.target.currentTime = event.target.duration + 1; ok(true, "Got expected 'ended' event: " + event.target.currentSrc);
}
function didEnd(event) { if (event.target._expectedDuration)
ok(true, "Got ended event"); ok(Math.abs(event.target.currentTime - event.target._expectedDuration) < 0.1,
"currentTime equals duration: " + event.target.currentSrc);
if (--testsWaiting == 0)
SimpleTest.finish(); SimpleTest.finish();
} }
SimpleTest.waitForExplicitFinish(); for (var i = 0; i < gSeekTests.length; ++i) {
var test = gSeekTests[i];
var elemType = /^audio/.test(test.type) ? "audio" : "video";
var v1 = document.createElement(elemType);
if (!v1.canPlayType(test.type))
continue;
v1.src = test.name;
if (test.duration) {
v1._expectedDuration = test.duration;
}
v1.addEventListener("loadedmetadata", function (event) {
event.target.currentTime = event.target.duration;
}, false);
v1.addEventListener("ended", mediaEnded, false);
v1.load();
++testsWaiting;
}
if (testsWaiting == 0) {
todo(false, "Can't play anything");
} else {
SimpleTest.waitForExplicitFinish();
}
</script> </script>
</pre> </pre>
<video src='seek.ogv' onloadeddata='start(event)' onended='didEnd(event)' controls></video>
</body> </body>
</html> </html>

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

@ -46,10 +46,10 @@ function doNextFile() {
var name = test.name + " seek test " + i; var name = test.name + " seek test " + i;
var localIs = function(name) { return function(a, b, msg) { var localIs = function(name) { return function(a, b, msg) {
is(a, b, name + ": " + msg); is(a, b, name + ": " + msg);
}}(); }}(name);
var localOk = function(name) { return function(a, msg) { var localOk = function(name) { return function(a, msg) {
ok(a, name + ": " + msg); ok(a, name + ": " + msg);
}}(); }}(name);
var localFinish = function() { var localFinish = function() {
--testsWaiting; --testsWaiting;
if (testsWaiting == 0) { if (testsWaiting == 0) {

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

@ -695,11 +695,15 @@ nsWaveStateMachine::Run()
// event, playback has not ended as far as the user's // event, playback has not ended as far as the user's
// concerned--the state machine needs to return to the last // concerned--the state machine needs to return to the last
// playback state. // playback state.
// Special case #3: if seeking to the end of the media, transition
// directly into STATE_ENDED.
State nextState = mNextState; State nextState = mNextState;
if (nextState == STATE_SEEKING) { if (nextState == STATE_SEEKING) {
nextState = STATE_PAUSED; nextState = STATE_PAUSED;
} else if (nextState == STATE_ENDED) { } else if (nextState == STATE_ENDED) {
nextState = mPaused ? STATE_PAUSED : STATE_PLAYING; nextState = mPaused ? STATE_PAUSED : STATE_PLAYING;
} else if (GetDuration() == seekTime) {
nextState = STATE_ENDED;
} }
ChangeState(nextState); ChangeState(nextState);
} }
@ -795,7 +799,8 @@ IsValidStateTransition(State aStartState, State aEndState)
return PR_TRUE; return PR_TRUE;
break; break;
case STATE_SEEKING: case STATE_SEEKING:
if (aEndState == STATE_PLAYING || aEndState == STATE_PAUSED) if (aEndState == STATE_PLAYING || aEndState == STATE_PAUSED ||
aEndState == STATE_ENDED)
return PR_TRUE; return PR_TRUE;
break; break;
case STATE_PAUSED: case STATE_PAUSED: