-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS Side loading for captions and offline support #1109
Changes from 5 commits
3e2e16e
05d4be2
fa63a9e
c9b7524
572c11a
6339b9a
93ce4d6
ea7bc15
0d32a31
fe26f54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import android.util.Log; | ||
import android.view.View; | ||
import android.view.Window; | ||
import android.view.accessibility.CaptioningManager; | ||
import android.widget.FrameLayout; | ||
|
||
import com.brentvatne.react.R; | ||
|
@@ -68,6 +69,7 @@ | |
import java.util.Map; | ||
import java.lang.Object; | ||
import java.util.ArrayList; | ||
import java.util.Locale; | ||
|
||
@SuppressLint("ViewConstructor") | ||
class ReactExoplayerView extends FrameLayout implements | ||
|
@@ -103,7 +105,7 @@ class ReactExoplayerView extends FrameLayout implements | |
private boolean loadVideoStarted; | ||
private boolean isFullscreen; | ||
private boolean isInBackground; | ||
private boolean isPaused; | ||
private boolean isPaused = true; | ||
private boolean isBuffering; | ||
private float rate = 1f; | ||
|
||
|
@@ -762,7 +764,26 @@ public void setSelectedTextTrack(String type, Dynamic value) { | |
trackIndex = value.asInt(); | ||
} else { // default. invalid type or "system" | ||
trackSelector.clearSelectionOverrides(index); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this or the setSelectionOverride anymore? If we are SDK <= 18 or no groups, the trackIndex will be C.INDEX_UNSET and we'll clear the overrides further down. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cobarx we need the setSelectionOverride in cases where captions were previously enabled, and are now explicitly disabled (or the system settings are disabled). I've moved this up further in the code for clarity. |
||
return; | ||
trackSelector.setSelectionOverride(index, groups, null); | ||
|
||
int sdk = android.os.Build.VERSION.SDK_INT; | ||
if (sdk>18 && groups.length>0) { | ||
CaptioningManager captioningManager = (CaptioningManager) themedReactContext.getSystemService(Context.CAPTIONING_SERVICE); | ||
if (captioningManager.isEnabled()) { | ||
// default is to take the first object | ||
trackIndex = 0; | ||
|
||
String locale = Locale.getDefault().getDisplayLanguage(); | ||
for (int i = 0; i < groups.length; ++i) { | ||
Format format = groups.get(i).getFormat(0); | ||
if (format.language != null && format.language.equals(locale)) { | ||
trackIndex = i; | ||
break; | ||
} | ||
} | ||
} | ||
} else return; | ||
|
||
} | ||
|
||
if (trackIndex == C.INDEX_UNSET) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a change that got wiped out during the merge. Please revert.