Skip to content

Commit

Permalink
fix: loaded triggered after seek and then pause
Browse files Browse the repository at this point in the history
  • Loading branch information
bwallberg authored and martinstark committed Oct 30, 2024
1 parent 4feb943 commit 8e187e1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"react-dom": "18.3.1",
"react-hook-form": "7.53.0",
"semantic-release": "24",
"shaka-player": "4.11.2",
"shaka-player": "4.11.7",
"swc-loader": "0.2.6",
"terser-webpack-plugin": "5.3.10",
"ts-node": "10.9.2",
Expand Down
11 changes: 6 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 8 additions & 23 deletions src/media-event-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const getMediaEventFilter = ({
// guard for when an engine sets playbackRate to 0 to continue buffering
// recover in "ratechange" event.
// Not used in mp4Mode as the engine doesn't update playbackRate with mp4s
if (!mp4Mode && mediaElement.playbackRate === 0) {
if (!mp4Mode && state.loading && mediaElement.playbackRate === 0) {
state = {
...state,
deferCanPlayThroughHandling: true,
Expand Down Expand Up @@ -390,30 +390,15 @@ export const getMediaEventFilter = ({
// Safari autoplay block triggers with a deferred loaded event,
// recover to a paused state
if (state.deferCanPlayThroughHandling) {
state = {
...state,
loading: false,
deferCanPlayThroughHandling: false,
};

callback(FilteredMediaEvent.LOADED);

if (mediaElement.paused) {
state = {
...state,
paused: true,
};
onCanPlayThrough();
}

callback(FilteredMediaEvent.PAUSE);
}
} else {
state = {
...state,
paused: true,
};
state = {
...state,
paused: true,
};

callback(FilteredMediaEvent.PAUSE);
}
callback(FilteredMediaEvent.PAUSE);
};

const shouldTriggerRatechangeBuffer = () =>
Expand Down

0 comments on commit 8e187e1

Please sign in to comment.