fix(android): track selection parameter has change in last release. (#3594)
Move all setSelectedTrack to String instead of Dynamic Co-authored-by: Olivier Bouillet <olivier@OrdinateOlivier.lan>
This commit is contained in:
parent
3d7444ab25
commit
d5c8b514a1
@ -206,11 +206,11 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
private String extension;
|
private String extension;
|
||||||
private boolean repeat;
|
private boolean repeat;
|
||||||
private String audioTrackType;
|
private String audioTrackType;
|
||||||
private Dynamic audioTrackValue;
|
private String audioTrackValue;
|
||||||
private String videoTrackType;
|
private String videoTrackType;
|
||||||
private Dynamic videoTrackValue;
|
private String videoTrackValue;
|
||||||
private String textTrackType;
|
private String textTrackType;
|
||||||
private Dynamic textTrackValue;
|
private String textTrackValue;
|
||||||
private ReadableArray textTracks;
|
private ReadableArray textTracks;
|
||||||
private boolean disableFocus;
|
private boolean disableFocus;
|
||||||
private boolean focusable = true;
|
private boolean focusable = true;
|
||||||
@ -1635,7 +1635,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
trackSelector.setParameters(disableParameters);
|
trackSelector.setParameters(disableParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedTrack(int trackType, String type, Dynamic value) {
|
public void setSelectedTrack(int trackType, String type, String value) {
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
int rendererIndex = getTrackRendererIndex(trackType);
|
int rendererIndex = getTrackRendererIndex(trackType);
|
||||||
if (rendererIndex == C.INDEX_UNSET) {
|
if (rendererIndex == C.INDEX_UNSET) {
|
||||||
@ -1661,7 +1661,7 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
} else if (type.equals("language")) {
|
} else if (type.equals("language")) {
|
||||||
for (int i = 0; i < groups.length; ++i) {
|
for (int i = 0; i < groups.length; ++i) {
|
||||||
Format format = groups.get(i).getFormat(0);
|
Format format = groups.get(i).getFormat(0);
|
||||||
if (format.language != null && format.language.equals(value.asString())) {
|
if (format.language != null && format.language.equals(value)) {
|
||||||
groupIndex = i;
|
groupIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1669,17 +1669,18 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
} else if (type.equals("title")) {
|
} else if (type.equals("title")) {
|
||||||
for (int i = 0; i < groups.length; ++i) {
|
for (int i = 0; i < groups.length; ++i) {
|
||||||
Format format = groups.get(i).getFormat(0);
|
Format format = groups.get(i).getFormat(0);
|
||||||
if (format.id != null && format.id.equals(value.asString())) {
|
if (format.id != null && format.id.equals(value)) {
|
||||||
groupIndex = i;
|
groupIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type.equals("index")) {
|
} else if (type.equals("index")) {
|
||||||
if (value.asInt() < groups.length) {
|
int iValue = Integer.parseInt(value);
|
||||||
groupIndex = value.asInt();
|
if (iValue < groups.length) {
|
||||||
|
groupIndex = iValue;
|
||||||
}
|
}
|
||||||
} else if (type.equals("resolution")) {
|
} else if (type.equals("resolution")) {
|
||||||
int height = value.asInt();
|
int height = Integer.parseInt(value);
|
||||||
for (int i = 0; i < groups.length; ++i) { // Search for the exact height
|
for (int i = 0; i < groups.length; ++i) { // Search for the exact height
|
||||||
TrackGroup group = groups.get(i);
|
TrackGroup group = groups.get(i);
|
||||||
Format closestFormat = null;
|
Format closestFormat = null;
|
||||||
@ -1827,19 +1828,19 @@ public class ReactExoplayerView extends FrameLayout implements
|
|||||||
return groupIndex;
|
return groupIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedVideoTrack(String type, Dynamic value) {
|
public void setSelectedVideoTrack(String type, String value) {
|
||||||
videoTrackType = type;
|
videoTrackType = type;
|
||||||
videoTrackValue = value;
|
videoTrackValue = value;
|
||||||
setSelectedTrack(C.TRACK_TYPE_VIDEO, videoTrackType, videoTrackValue);
|
setSelectedTrack(C.TRACK_TYPE_VIDEO, videoTrackType, videoTrackValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedAudioTrack(String type, Dynamic value) {
|
public void setSelectedAudioTrack(String type, String value) {
|
||||||
audioTrackType = type;
|
audioTrackType = type;
|
||||||
audioTrackValue = value;
|
audioTrackValue = value;
|
||||||
setSelectedTrack(C.TRACK_TYPE_AUDIO, audioTrackType, audioTrackValue);
|
setSelectedTrack(C.TRACK_TYPE_AUDIO, audioTrackType, audioTrackValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedTextTrack(String type, Dynamic value) {
|
public void setSelectedTextTrack(String type, String value) {
|
||||||
textTrackType = type;
|
textTrackType = type;
|
||||||
textTrackValue = value;
|
textTrackValue = value;
|
||||||
setSelectedTrack(C.TRACK_TYPE_TEXT, textTrackType, textTrackValue);
|
setSelectedTrack(C.TRACK_TYPE_TEXT, textTrackType, textTrackValue);
|
||||||
|
@ -253,10 +253,10 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
public void setSelectedVideoTrack(final ReactExoplayerView videoView,
|
public void setSelectedVideoTrack(final ReactExoplayerView videoView,
|
||||||
@Nullable ReadableMap selectedVideoTrack) {
|
@Nullable ReadableMap selectedVideoTrack) {
|
||||||
String typeString = null;
|
String typeString = null;
|
||||||
Dynamic value = null;
|
String value = null;
|
||||||
if (selectedVideoTrack != null) {
|
if (selectedVideoTrack != null) {
|
||||||
typeString = ReactBridgeUtils.safeGetString(selectedVideoTrack, PROP_SELECTED_VIDEO_TRACK_TYPE);
|
typeString = ReactBridgeUtils.safeGetString(selectedVideoTrack, PROP_SELECTED_VIDEO_TRACK_TYPE);
|
||||||
value = ReactBridgeUtils.safeGetDynamic(selectedVideoTrack, PROP_SELECTED_VIDEO_TRACK_VALUE);
|
value = ReactBridgeUtils.safeGetString(selectedVideoTrack, PROP_SELECTED_VIDEO_TRACK_VALUE);
|
||||||
}
|
}
|
||||||
videoView.setSelectedVideoTrack(typeString, value);
|
videoView.setSelectedVideoTrack(typeString, value);
|
||||||
}
|
}
|
||||||
@ -265,10 +265,10 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
public void setSelectedAudioTrack(final ReactExoplayerView videoView,
|
public void setSelectedAudioTrack(final ReactExoplayerView videoView,
|
||||||
@Nullable ReadableMap selectedAudioTrack) {
|
@Nullable ReadableMap selectedAudioTrack) {
|
||||||
String typeString = null;
|
String typeString = null;
|
||||||
Dynamic value = null;
|
String value = null;
|
||||||
if (selectedAudioTrack != null) {
|
if (selectedAudioTrack != null) {
|
||||||
typeString = ReactBridgeUtils.safeGetString(selectedAudioTrack, PROP_SELECTED_AUDIO_TRACK_TYPE);
|
typeString = ReactBridgeUtils.safeGetString(selectedAudioTrack, PROP_SELECTED_AUDIO_TRACK_TYPE);
|
||||||
value = ReactBridgeUtils.safeGetDynamic(selectedAudioTrack, PROP_SELECTED_AUDIO_TRACK_VALUE);
|
value = ReactBridgeUtils.safeGetString(selectedAudioTrack, PROP_SELECTED_AUDIO_TRACK_VALUE);
|
||||||
}
|
}
|
||||||
videoView.setSelectedAudioTrack(typeString, value);
|
videoView.setSelectedAudioTrack(typeString, value);
|
||||||
}
|
}
|
||||||
@ -277,10 +277,10 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
public void setSelectedTextTrack(final ReactExoplayerView videoView,
|
public void setSelectedTextTrack(final ReactExoplayerView videoView,
|
||||||
@Nullable ReadableMap selectedTextTrack) {
|
@Nullable ReadableMap selectedTextTrack) {
|
||||||
String typeString = null;
|
String typeString = null;
|
||||||
Dynamic value = null;
|
String value = null;
|
||||||
if (selectedTextTrack != null) {
|
if (selectedTextTrack != null) {
|
||||||
typeString = ReactBridgeUtils.safeGetString(selectedTextTrack, PROP_SELECTED_TEXT_TRACK_TYPE);
|
typeString = ReactBridgeUtils.safeGetString(selectedTextTrack, PROP_SELECTED_TEXT_TRACK_TYPE);
|
||||||
value = ReactBridgeUtils.safeGetDynamic(selectedTextTrack, PROP_SELECTED_TEXT_TRACK_VALUE);
|
value = ReactBridgeUtils.safeGetString(selectedTextTrack, PROP_SELECTED_TEXT_TRACK_VALUE);
|
||||||
}
|
}
|
||||||
videoView.setSelectedTextTrack(typeString, value);
|
videoView.setSelectedTextTrack(typeString, value);
|
||||||
}
|
}
|
||||||
|
@ -225,16 +225,18 @@ class VideoPlayer extends Component {
|
|||||||
const selectedTrack = data.audioTracks?.find((x: AudioTrack) => {
|
const selectedTrack = data.audioTracks?.find((x: AudioTrack) => {
|
||||||
return x.selected;
|
return x.selected;
|
||||||
});
|
});
|
||||||
this.setState({
|
|
||||||
audioTracks: data.audioTracks,
|
|
||||||
});
|
|
||||||
if (selectedTrack?.language) {
|
if (selectedTrack?.language) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
audioTracks: data.audioTracks,
|
||||||
selectedAudioTrack: {
|
selectedAudioTrack: {
|
||||||
type: 'language',
|
type: 'language',
|
||||||
value: selectedTrack?.language,
|
value: selectedTrack?.language,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
audioTracks: data.audioTracks,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -243,17 +245,18 @@ class VideoPlayer extends Component {
|
|||||||
return x?.selected;
|
return x?.selected;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setState({
|
|
||||||
textTracks: data.textTracks,
|
|
||||||
});
|
|
||||||
if (selectedTrack?.language) {
|
if (selectedTrack?.language) {
|
||||||
this.setState({
|
this.setState({
|
||||||
textTracks: data,
|
textTracks: data.textTracks,
|
||||||
selectedTextTrack: {
|
selectedTextTrack: {
|
||||||
type: 'language',
|
type: 'language',
|
||||||
value: selectedTrack?.language,
|
value: selectedTrack?.language,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
textTracks: data.textTracks,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user