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

Playing Audio with Fade In/Out effect #10702

Open
aareeph opened this issue Oct 19, 2022 · 2 comments
Open

Playing Audio with Fade In/Out effect #10702

aareeph opened this issue Oct 19, 2022 · 2 comments
Assignees

Comments

@aareeph
Copy link

aareeph commented Oct 19, 2022

Previously I was using the Timer() thread to create a Volume Fade In and Fade Out effects while playing the audio and setting up the volume in it. After upgrading to the latest version of ExoPlayer now I am getting the following error message:

java.lang.IllegalStateException: Player is accessed on the wrong thread.
Current thread: 'Timer-0'
Expected thread: 'main'

I understand that ExoPlayer needs to accessed via same thread, but is there a way to create the Volume Fade In/Fade Out effect?

Thanks

@tonihei
Copy link
Collaborator

tonihei commented Oct 21, 2022

Yes, that's right, your need to access the player from a single thread at all times (usually the main thread). If you get signals on another thread, you can usually send a Handler message/post to the player thread to handle them there. This has always been the case, we just didn't enforce it.

We also don't support fading effects out of the box at the moment. I can mark this as an enhancement to support such effects either via Exoplayer's audio processors or via VolumeShaper.

@Abcfinite
Copy link

Abcfinite commented Nov 19, 2023

it would be great to have built in function for fade in/out but meanwhile. We can do something like this :

var handler = Handler(player.applicationLooper)

handler.postDelayed({
    controller.volume = 0.6f
}, 1000)

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

No branches or pull requests

4 participants