Apply initial text track prop when the video is loaded

This commit is contained in:
Hampton Maxwell 2018-06-04 11:48:59 -07:00
parent 03017c0f63
commit 11584f28d1

View File

@ -104,6 +104,8 @@ class ReactExoplayerView extends FrameLayout implements
private Uri srcUri; private Uri srcUri;
private String extension; private String extension;
private boolean repeat; private boolean repeat;
private String textTrackType;
private Dynamic textTrackValue;
private boolean disableFocus; private boolean disableFocus;
private float mProgressUpdateInterval = 250.0f; private float mProgressUpdateInterval = 250.0f;
private boolean playInBackground = false; private boolean playInBackground = false;
@ -449,6 +451,7 @@ class ReactExoplayerView extends FrameLayout implements
private void videoLoaded() { private void videoLoaded() {
if (loadVideoStarted) { if (loadVideoStarted) {
loadVideoStarted = false; loadVideoStarted = false;
setSelectedTextTrack(textTrackType, textTrackValue);
Format videoFormat = player.getVideoFormat(); Format videoFormat = player.getVideoFormat();
int width = videoFormat != null ? videoFormat.width : 0; int width = videoFormat != null ? videoFormat.width : 0;
int height = videoFormat != null ? videoFormat.height : 0; int height = videoFormat != null ? videoFormat.height : 0;
@ -643,6 +646,9 @@ class ReactExoplayerView extends FrameLayout implements
} }
public void setSelectedTextTrack(String type, Dynamic value) { public void setSelectedTextTrack(String type, Dynamic value) {
textTrackType = type;
textTrackValue = value;
int index = getTextTrackRendererIndex(); int index = getTextTrackRendererIndex();
if (index == C.INDEX_UNSET) { if (index == C.INDEX_UNSET) {
return; return;