Skip to content

Commit

Permalink
fix: add exact check for language and kind, referring docs
Browse files Browse the repository at this point in the history
  • Loading branch information
asharma991 committed Apr 2, 2024
1 parent 612fa7f commit 68a0ec8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/components/VideoPlayer2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
let volumeSetTimeout: ReturnType<typeof setInterval> | null = null;
const handleKeyPress = (event: any) => {
const isShiftPressed = event.shiftKey;
const tracks: TextTrackList = player.textTracks();
if (isShiftPressed) {
const currentIndexPeriod: number = PLAYBACK_RATES.indexOf(
player.playbackRate(),
Expand Down Expand Up @@ -182,11 +183,15 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
event.stopPropagation();
break;
case 'KeyC':
if (subtitles && player.textTracks().length) {
if (player.textTracks()[0].mode === 'showing') {
player.textTracks()[0].mode = 'hidden';
} else {
player.textTracks()[0].mode = 'showing';
for (let i = 0; i < tracks.length; i++) {
const track = tracks[i];

if (track.kind === 'subtitles' && track.language === 'en') {
if (track.mode === 'hidden') {
track.mode = 'showing';
} else {
track.mode = 'hidden';
}
}
}
break;
Expand Down

0 comments on commit 68a0ec8

Please sign in to comment.