Skip to content

Commit b80371a

Browse files
Buthrakaurdoranteseduardo
authored andcommitted
fix AVPlayer unnecessary switching of threads in case current thread is already the main thread - this fixes also problem with disposing the video instance when AR scene is unmounted as it causes pause() to be called and somehow deadlocks threads
1 parent 5bb5be8 commit b80371a

File tree

1 file changed

+4
-0
lines changed
  • android/sharedCode/src/main/java/com/viro/core/internal

1 file changed

+4
-0
lines changed

android/sharedCode/src/main/java/com/viro/core/internal/AVPlayer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public interface PlayerAction<T> {
145145
}
146146

147147
private <T> T runSynchronouslyOnMainThread(PlayerAction<T> action) throws ExecutionException, InterruptedException {
148+
if (Looper.myLooper() == Looper.getMainLooper()) {
149+
return action.performAction(mExoPlayer);
150+
}
151+
148152
Callable<T> callable = () -> action.performAction(mExoPlayer);
149153
FutureTask<T> future = new FutureTask<>(callable);
150154

0 commit comments

Comments
 (0)