Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Use middleware and a wrapped function for seeking instead of rel…
…ying on unreliable 'seeking' events (#161)
- Loading branch information
Showing
5 changed files
with
48 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import videojs from 'video.js'; | ||
|
||
// since VHS handles HLS and DASH (and in the future, more types), use * to capture all | ||
videojs.use('*', (player) => { | ||
return { | ||
setSource: (srcObj, next) => { | ||
// pass null as the first argument to indicate that the source is not rejected | ||
next(null, srcObj); | ||
}, | ||
|
||
// VHS needs to know when seeks happen. For external seeks (generated at the player | ||
// level), this middleware will capture the action. For internal seeks (generated at | ||
// the tech level), we use a wrapped function so that we can handle it on our own | ||
// (specified elsewhere). | ||
setCurrentTime: (time) => { | ||
if (player.vhs && player.currentSource().src === player.vhs.source_.src) { | ||
player.vhs.setCurrentTime(time); | ||
} | ||
|
||
return time; | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters