Skip to content

Commit

Permalink
fix: seeking when preload is none (#997)
Browse files Browse the repository at this point in the history
related #910

this fixes an issue where when you seek before the video is loaded we
don't set the video.currentTime.

it's fine to set the currentTime anytime. it doesn't throw for a valid
number value.
but users have to set the `defaultduration` in some cases. not sure with
iOS and native HLS.
  • Loading branch information
luwes authored Oct 4, 2024
1 parent e913e7d commit 5000cc3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/vanilla/mobile.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<body>
<main>
<h1>Media Chrome Standard Mobile Video Usage Example</h1>
<media-controller autohide="2">
<media-controller autohide="2" defaultduration="134">
<video
slot="media"
src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/high.mp4"
Expand Down
4 changes: 2 additions & 2 deletions src/js/media-store/state-mediator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
toggleSubtitleTracks,
} from './util.js';
import { getTextTracksList } from '../utils/captions.js';
import { isValidNumber } from '../utils/utils.js';

export type Rendition = {
src?: string;
Expand Down Expand Up @@ -432,8 +433,7 @@ export const stateMediator: StateMediator = {
},
set(value, stateOwners) {
const { media } = stateOwners;
// If the media supports readyState and it's not ready, don't set currentTime
if (!media || media.readyState === 0) return;
if (!media || !isValidNumber(value)) return;
media.currentTime = value;
},
mediaEvents: ['timeupdate', 'loadedmetadata'],
Expand Down

0 comments on commit 5000cc3

Please sign in to comment.