Commit 5c0612b 1 parent bee6a87 commit 5c0612b Copy full SHA for 5c0612b
File tree 1 file changed +15
-2
lines changed
1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -142,12 +142,25 @@ export const DocumentCPU = {
142
142
}
143
143
144
144
if ( audiotag . fastSeek ) {
145
- // HTMLAudioElement.fastSeek() is an experimental but really fast function.
145
+ // HTMLAudioElement.fastSeek() is an experimental but really fast function. Firefox only, alas
146
146
audiotag . fastSeek ( seconds ) ;
147
147
} else {
148
148
try {
149
+ const settime = ( ) => { audiotag . currentTime = seconds ; } ;
149
150
// Browsers may not have fastSeek but can set currentTime
150
- audiotag . currentTime = seconds ;
151
+ if ( audiotag . readyState >= audiotag . HAVE_CURRENT_DATA ) {
152
+ // Chrome, Edge, and any other webkit-like except Safari on iPhone
153
+ settime ( ) ;
154
+ } else {
155
+ // Safari on iPhone is totally incumbent on media throbbing
156
+ // See https://github.com/dascritch/cpu-audio/issues/138#issuecomment-816526902
157
+ // and https://stackoverflow.com/questions/18266437/html5-video-currenttime-not-setting-properly-on-iphone
158
+ audiotag . load ( ) ;
159
+ settime ( ) ;
160
+ if ( audiotag . currentTime < seconds ) {
161
+ audiotag . addEventListener ( "loadedmetadata" , settime , { once :true } ) ;
162
+ }
163
+ }
151
164
} catch ( e ) {
152
165
// except sometimes, so you must use standard media fragment
153
166
audiotag . src = `${ audiotag . currentSrc . split ( '#' ) [ 0 ] } #t=${ seconds } ` ;
You can’t perform that action at this time.
0 commit comments