Skip to content

Commit

Permalink
chore: make selection by index testable (need a small manual patch)
Browse files Browse the repository at this point in the history
  • Loading branch information
freeboub committed May 2, 2024
1 parent 25a5438 commit 2d18146
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions examples/basic/src/VideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class VideoPlayer extends Component {

seekerWidth = 0;

// internal usage change to index if you want to select tracks by index instead of lang
textTracksSelectionBy = 'lang';

srcAllPlatformList = [
{
description: 'local file landscape',
Expand Down Expand Up @@ -300,7 +303,10 @@ class VideoPlayer extends Component {
if (selectedTrack?.language) {
this.setState({
textTracks: data.textTracks,
selectedTextTrack: {
selectedTextTrack: this.textTracksSelectionBy === 'index' ? {
type: 'index',
value: selectedTrack?.index,
}: {
type: 'language',
value: selectedTrack?.language,
},
Expand Down Expand Up @@ -804,7 +810,7 @@ class VideoPlayer extends Component {
console.log('on value change ' + itemValue);
this.setState({
selectedTextTrack: {
type: 'language',
type: this.textTracksSelectionBy === 'index' ? 'index': 'language',
value: itemValue,
},
});
Expand All @@ -814,13 +820,21 @@ class VideoPlayer extends Component {
if (!track) {
return;
}
return (
<Picker.Item
label={track.language}
value={track.language}
key={track.language}
/>
);
if (this.textTracksSelectionBy === 'index') {
return (
<Picker.Item
label={`${track.index}`}
value={track.index}
key={track.index}
/>);
} else {
return (
<Picker.Item
label={track.language}
value={track.language}
key={track.language}
/>);
}
})}
</Picker>
)}
Expand Down

0 comments on commit 2d18146

Please sign in to comment.