Skip to content

Commit

Permalink
Added keyboard shortcuts for web player
Browse files Browse the repository at this point in the history
  • Loading branch information
SurfaceS committed Nov 1, 2024
1 parent 166e582 commit 50ae300
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions react-client/src/components/Player/VideoJsPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ export const VideoJsPlayer = (vpOptions: VideoPlayerOption) => {
const options = {} as any;
options.liveui = true;
options.controls = true;
options.userActions = {
hotkeys: function(event: any) {
if (event.which === 32) {
if (this.paused()) {
this.play();
} else {
this.pause();
}
}
if (event.which === 37) {
this.currentTime(Math.max(0, this.currentTime() - 15));
}
if (event.which === 39) {
const duration = this.liveTracker && this.liveTracker.isLive() ? this.liveTracker.seekableEnd() : this.duration();
this.currentTime(Math.min(this.currentTime() + 15), duration);
}
}
};
options.sources = [{ src: playerApiUrl + 'media/' + vpOptions.uuid + '/' + vpOptions.media.id, type: vpOptions.media.mime }];
options.poster = playerApiUrl + 'thumbnail/' + vpOptions.uuid + '/' + vpOptions.media.id;
if (vpOptions.media.mediaType === 'audio') {
Expand Down

0 comments on commit 50ae300

Please sign in to comment.