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

SimpleExoPlayer: Player is accessed on the wrong thread. #53

Closed
nbourdin opened this issue Jul 2, 2020 · 10 comments
Closed

SimpleExoPlayer: Player is accessed on the wrong thread. #53

nbourdin opened this issue Jul 2, 2020 · 10 comments

Comments

@nbourdin
Copy link

nbourdin commented Jul 2, 2020

Hello,
When i launch the sample from branch master I get the following error :


W/SimpleExoPlayer: Player is accessed on the wrong thread. See https://exoplayer.dev/issues/player-accessed-on-wrong-thread
    java.lang.IllegalStateException
        at com.google.android.exoplayer2.SimpleExoPlayer.verifyApplicationThread(SimpleExoPlayer.java:1242)
        at com.google.android.exoplayer2.SimpleExoPlayer.setVideoSurface(SimpleExoPlayer.java:321)
        at com.daasuu.epf.EPlayerRenderer.onSurfaceCreated(EPlayerRenderer.java:103)
        at com.daasuu.epf.EFrameBufferObjectRenderer.onSurfaceCreated(EFrameBufferObjectRenderer.java:40)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1516)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)

Same issue when i try to use the lib in my project.

Any idea ? Thanks in advance

@yangcheng
Copy link
Contributor

I have the same issue.

@ParthP-7
Copy link

ParthP-7 commented Mar 3, 2021

I am facing the same issue. Did you find any solution?

@nbourdin
Copy link
Author

No sorry

@sebdomdev
Copy link

sebdomdev commented Mar 13, 2021

Seems like something changed in the newer exoplayer library versions. If you use 2.10.5, it actually works (that's the version that the library is using). I assume it has to do with exo player being accessed from the open gl thread instead of the main thread but I'm not sure.

@saptan
Copy link

saptan commented Mar 24, 2021

I have the same issue.

@saptan
Copy link

saptan commented Mar 24, 2021

    implementation 'com.google.android.exoplayer:exoplayer-core:2.13.2'
    implementation 'com.google.android.exoplayer:exoplayer-hls:2.13.2'
    implementation 'com.google.android.exoplayer:exoplayer-ui:2.13.2'
    implementation 'com.google.android.exoplayer:extension-rtmp:2.13.2'

@saptan
Copy link

saptan commented Apr 14, 2021

Need replace this code:

        Surface surface = new Surface(previewTexture.getSurfaceTexture());
        this.simpleExoPlayer.setVideoSurface(surface);

with:

new Handler(Looper.getMainLooper()).post(() -> {
            Surface surface = new Surface(previewTexture.getSurfaceTexture());
            simpleExoPlayer.setVideoSurface(surface);
        });

https://github.com/MasayukiSuda/ExoPlayerFilter/blob/master/epf/src/main/java/com/daasuu/epf/EPlayerRenderer.java#L102-L103

@yangcheng
Copy link
Contributor

Need replace this code:

        Surface surface = new Surface(previewTexture.getSurfaceTexture());
        this.simpleExoPlayer.setVideoSurface(surface);

with:

new Handler(Looper.getMainLooper()).post(() -> {
            Surface surface = new Surface(previewTexture.getSurfaceTexture());
            simpleExoPlayer.setVideoSurface(surface);
        });

https://github.com/MasayukiSuda/ExoPlayerFilter/blob/master/epf/src/main/java/com/daasuu/epf/EPlayerRenderer.java#L102-L103

I added a PR based on the suggestion, #58

@MasayukiSuda
Copy link
Owner

Fixed.

@vaibhavpandeyvpz
Copy link

@MasayukiSuda Thanks for fixing this long-term incompatibility with recent ExoPlayer version. Please close and lock this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants