mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
revert _playing flag: playing event fires on every resume
Tested in Chrome (headless, --autoplay-policy=no-user-gesture-required): playing fires on every pause-to-play transition, not just the first time. The _playing flag was incorrectly suppressing this. Removed it and updated tests to match verified Chrome behavior.
This commit is contained in:
@@ -76,21 +76,21 @@
|
||||
audio.pause();
|
||||
testing.expectEqual('play,playing,pause', events.join(','));
|
||||
|
||||
// Third play: resume from pause, fires play only (not playing)
|
||||
// Third play: resume from pause, fires play + playing (verified in Chrome)
|
||||
audio.play();
|
||||
testing.expectEqual('play,playing,pause,play', events.join(','));
|
||||
testing.expectEqual('play,playing,pause,play,playing', events.join(','));
|
||||
|
||||
// Pause again
|
||||
audio.pause();
|
||||
testing.expectEqual('play,playing,pause,play,pause', events.join(','));
|
||||
testing.expectEqual('play,playing,pause,play,playing,pause', events.join(','));
|
||||
|
||||
// Load: resets state, fires emptied
|
||||
audio.load();
|
||||
testing.expectEqual('play,playing,pause,play,pause,emptied', events.join(','));
|
||||
testing.expectEqual('play,playing,pause,play,playing,pause,emptied', events.join(','));
|
||||
|
||||
// Play after load: fires play + playing again (fresh start)
|
||||
// Play after load: fires play + playing
|
||||
audio.play();
|
||||
testing.expectEqual('play,playing,pause,play,pause,emptied,play,playing', events.join(','));
|
||||
testing.expectEqual('play,playing,pause,play,playing,pause,emptied,play,playing', events.join(','));
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -61,7 +61,6 @@ _playback_rate: f64 = 1.0,
|
||||
_ready_state: ReadyState = .HAVE_NOTHING,
|
||||
_network_state: NetworkState = .NETWORK_EMPTY,
|
||||
_error: ?*MediaError = null,
|
||||
_playing: bool = false,
|
||||
|
||||
pub fn asElement(self: *Media) *Element {
|
||||
return self._proto._proto;
|
||||
@@ -145,10 +144,7 @@ pub fn play(self: *Media, page: *Page) !void {
|
||||
self._network_state = .NETWORK_IDLE;
|
||||
if (was_paused) {
|
||||
try self.dispatchEvent("play", page);
|
||||
if (!self._playing) {
|
||||
self._playing = true;
|
||||
try self.dispatchEvent("playing", page);
|
||||
}
|
||||
try self.dispatchEvent("playing", page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +157,6 @@ pub fn pause(self: *Media, page: *Page) !void {
|
||||
|
||||
pub fn load(self: *Media, page: *Page) !void {
|
||||
self._paused = true;
|
||||
self._playing = false;
|
||||
self._current_time = 0;
|
||||
self._ready_state = .HAVE_NOTHING;
|
||||
self._network_state = .NETWORK_LOADING;
|
||||
|
||||
Reference in New Issue
Block a user