VEX-7093: Protect initialization of DRM (#29)

This PR will fix the crash from the experiment on react-native-video

Jira: VEX-7093

velocity PR: crunchyroll/velocity#2443

The crash was caused by using the player object before it was set by another thread, the change simply waits for the player to be available before executing any player interaction after DRM initialization.

Reviews
Major reviewer (domain expert): @jctorresM
Minor reviewer: @jacob-livingston
This commit is contained in:
Gabriel Rivero 2022-04-28 20:17:59 -04:00 committed by GitHub
parent f6e9cc8502
commit b274541431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -632,6 +632,16 @@ class ReactExoplayerView extends FrameLayout implements
mediaSource = new MergingMediaSource(textSourceArray); mediaSource = new MergingMediaSource(textSourceArray);
} }
// wait for player to be set
while (player == null) {
try {
wait();
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
Log.e("ExoPlayer Exception", ex.toString());
}
}
boolean haveResumePosition = resumeWindow != C.INDEX_UNSET; boolean haveResumePosition = resumeWindow != C.INDEX_UNSET;
if (haveResumePosition) { if (haveResumePosition) {
player.seekTo(resumeWindow, resumePosition); player.seekTo(resumeWindow, resumePosition);