fix(ios): fix text track selection by index (#3728)
* fix(ts): onPlaybackRateChangeData was not correctly typed * fix: ensure tracks are well displayed in the sample * fix(ios): text tracks selection by index. regression due to codegen rework * chore: make selection by index testable (need a small manual patch) * chore(ios): fix linter warning
This commit is contained in:
parent
4c63988d12
commit
51e22abfe3
@ -104,6 +104,9 @@ class VideoPlayer extends Component {
|
|||||||
|
|
||||||
seekerWidth = 0;
|
seekerWidth = 0;
|
||||||
|
|
||||||
|
// internal usage change to index if you want to select tracks by index instead of lang
|
||||||
|
textTracksSelectionBy = 'lang';
|
||||||
|
|
||||||
srcAllPlatformList = [
|
srcAllPlatformList = [
|
||||||
{
|
{
|
||||||
description: 'local file landscape',
|
description: 'local file landscape',
|
||||||
@ -300,7 +303,10 @@ class VideoPlayer extends Component {
|
|||||||
if (selectedTrack?.language) {
|
if (selectedTrack?.language) {
|
||||||
this.setState({
|
this.setState({
|
||||||
textTracks: data.textTracks,
|
textTracks: data.textTracks,
|
||||||
selectedTextTrack: {
|
selectedTextTrack: this.textTracksSelectionBy === 'index' ? {
|
||||||
|
type: 'index',
|
||||||
|
value: selectedTrack?.index,
|
||||||
|
}: {
|
||||||
type: 'language',
|
type: 'language',
|
||||||
value: selectedTrack?.language,
|
value: selectedTrack?.language,
|
||||||
},
|
},
|
||||||
@ -804,7 +810,7 @@ class VideoPlayer extends Component {
|
|||||||
console.log('on value change ' + itemValue);
|
console.log('on value change ' + itemValue);
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedTextTrack: {
|
selectedTextTrack: {
|
||||||
type: 'language',
|
type: this.textTracksSelectionBy === 'index' ? 'index': 'language',
|
||||||
value: itemValue,
|
value: itemValue,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@ -814,13 +820,21 @@ class VideoPlayer extends Component {
|
|||||||
if (!track) {
|
if (!track) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return (
|
if (this.textTracksSelectionBy === 'index') {
|
||||||
<Picker.Item
|
return (
|
||||||
label={track.language}
|
<Picker.Item
|
||||||
value={track.language}
|
label={`${track.index}`}
|
||||||
key={track.language}
|
value={track.index}
|
||||||
/>
|
key={track.index}
|
||||||
);
|
/>);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={track.language}
|
||||||
|
value={track.language}
|
||||||
|
key={track.language}
|
||||||
|
/>);
|
||||||
|
}
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
)}
|
)}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
struct SelectedTrackCriteria {
|
struct SelectedTrackCriteria {
|
||||||
let type: String
|
let type: String
|
||||||
let value: Any?
|
let value: String?
|
||||||
|
|
||||||
let json: NSDictionary?
|
let json: NSDictionary?
|
||||||
|
|
||||||
@ -13,6 +13,6 @@ struct SelectedTrackCriteria {
|
|||||||
}
|
}
|
||||||
self.json = json
|
self.json = json
|
||||||
self.type = json["type"] as? String ?? ""
|
self.type = json["type"] as? String ?? ""
|
||||||
self.value = json["value"]
|
self.value = json["value"] as? String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,11 @@ enum RCTPlayerOperations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if type == "index" {
|
} else if type == "index" {
|
||||||
if let value = criteria?.value, let index = value as? Int {
|
if let value = criteria?.value { // check value is provided
|
||||||
if textTracks.count > index {
|
if let indexValue = Int(value as String) { // ensure value is an integer an String to Snt
|
||||||
selectedTrackIndex = index
|
if textTracks.count > indexValue { // ensure value is in group range
|
||||||
|
selectedTrackIndex = indexValue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -106,9 +108,11 @@ enum RCTPlayerOperations {
|
|||||||
// } else if ([type isEqualToString:@"default"]) {
|
// } else if ([type isEqualToString:@"default"]) {
|
||||||
// option = group.defaultOption; */
|
// option = group.defaultOption; */
|
||||||
} else if type == "index" {
|
} else if type == "index" {
|
||||||
if let value = criteria?.value, let index = value as? Int {
|
if let value = criteria?.value { // check value is provided
|
||||||
if group.options.count > index {
|
if let indexValue = Int(value as String) { // ensure value is an integer an String to Snt
|
||||||
mediaOption = group.options[index]
|
if group.options.count > indexValue { // ensure value is in group range
|
||||||
|
mediaOption = group.options[indexValue]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // default. invalid type or "system"
|
} else { // default. invalid type or "system"
|
||||||
|
Loading…
Reference in New Issue
Block a user