Skip to content
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

Merged
merged 10 commits into from
Jul 11, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -762,7 +763,14 @@ public void setSelectedTextTrack(String type, Dynamic value) {
trackIndex = value.asInt();
} else { // default. invalid type or "system"
trackSelector.clearSelectionOverrides(index);
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 Locale.getDefault.getDisplayLanguage(); as stated here:
https://stackoverflow.com/questions/4212320/get-the-current-language-in-device

} else return;

}

if (trackIndex == C.INDEX_UNSET) {
Expand Down
Loading