-
-
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 1 commit
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; | ||
|
@@ -759,7 +760,14 @@ public void setSelectedTextTrack(String type, Dynamic value) { | |
trackIndex = value.asInt(); | ||
} else { // default. invalid type or "system" | ||
trackSelector.clearSelectionOverrides(index); | ||
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()) trackIndex=0; | ||
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. Thanks for figuring out this exists! I either forgot or didn't know this was available. We should look for the track that matches the language the UI is set to. I believe we can use |
||
} 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.
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 comment
The 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.