mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
fix playing event: only dispatch on paused-to-playing transition
Per MDN, playing fires "after playback is first started, and whenever it is restarted." A second play() while already playing should be a no-op. Both play and playing now only fire on the paused -> playing transition.
This commit is contained in:
@@ -64,21 +64,21 @@
|
||||
audio.play();
|
||||
testing.expectEqual('play,playing', events.join(','));
|
||||
|
||||
// Second play: already playing, fires only playing (not play)
|
||||
// Second play: already playing, no events
|
||||
audio.play();
|
||||
testing.expectEqual('play,playing,playing', events.join(','));
|
||||
testing.expectEqual('play,playing', events.join(','));
|
||||
|
||||
// Pause: playing -> paused, fires pause
|
||||
audio.pause();
|
||||
testing.expectEqual('play,playing,playing,pause', events.join(','));
|
||||
testing.expectEqual('play,playing,pause', events.join(','));
|
||||
|
||||
// Second pause: already paused, no event
|
||||
audio.pause();
|
||||
testing.expectEqual('play,playing,playing,pause', events.join(','));
|
||||
testing.expectEqual('play,playing,pause', events.join(','));
|
||||
|
||||
// Load: fires emptied
|
||||
audio.load();
|
||||
testing.expectEqual('play,playing,playing,pause,emptied', events.join(','));
|
||||
testing.expectEqual('play,playing,pause,emptied', events.join(','));
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -144,8 +144,8 @@ pub fn play(self: *Media, page: *Page) !void {
|
||||
self._network_state = .NETWORK_IDLE;
|
||||
if (was_paused) {
|
||||
try self.dispatchEvent("play", page);
|
||||
try self.dispatchEvent("playing", page);
|
||||
}
|
||||
try self.dispatchEvent("playing", page);
|
||||
}
|
||||
|
||||
pub fn pause(self: *Media, page: *Page) !void {
|
||||
|
||||
Reference in New Issue
Block a user