android-openslmediaplayer
android-openslmediaplayer copied to clipboard
Disabling "Smooth fade in/out" when starts/pauses playback
Hi. I need fast pause without any fade. Can I turn it off somehow?
From what I can see, OpenSLMediaPlayerFactory#createMediaPlayer is creating the OpenSLMediaPlayer using its own getMediaPlayerOptions().
This is hard coded to always return OpenSLMediaPlayer.OPTION_USE_FADE
There doesn't appear to be a way to pass through any options. If you aren't able to make changes to OpenSLMediaPlyaerFactory yourself, instantiate it as an anonymous class, override the getMediaPlayerOptions behaivor and return zero. This disables the fade on both start and pause.
The same thing applies for the hybrid player. Obviously this isn't pretty, ideally there'd be a way to pass this through as a parameter into the media player factories. When I clean things up my side I plan on submitting a PR allowing this to be toggled easier.
factory = new OpenSLMediaPlayerFactory(activity.getApplicationContext()) {
@Override
protected int getMediaPlayerOptions () {
return 0;
}
};
@anonym24 Hi. As @stickyd has mentioned, his solution is the appropreate way to configure OpenSLMediaPlayer/HybridMediaPlayer not to use smooth fading.
thanks) it suits me more
Hi @h6ah4i. After disabling the Fade effect using the way @stickyd says it works, but then it makes a weird sound after seeking a certain position in the song. How do we fix/avoid it?
@martppa I second you on this. It is making screeching sound on seeking after disabling fade.
@hunnydarapstar Hi, I fixed this issue. clone my fork and build the native library.
@martppa okay Thanks
@martppa can you build the library and upload it coz I am encountering errors while building from source
Sure, here you are
https://mega.nz/#!ppIG0a7R!sxRXMZSgqnhlDIopg8f_1yOwb4o-deBdaUJPMy540jw
If you have any other issue let me know.
@martppa Thanks a ton bro.. btw I have successfullt build the library from source. Cmake was not installed on my lappy, my bad..!!
@stickyd your solution worked for me also!! @martppa Did you see any way to tune the fade in/out times? In order of tune the library i'd like also to tune the max IBasicMediaPlayer instances allowed by the OpenSLMediaPlayerFactory, from current 4 to 5 instances, is it possible to do this without crash?
@billyjoker Not sure, since the instance is created in the native side and controlled by handlers. I will try to take a look in the code and tell you if it worth to modify it. Tell ya soon.
@martppa did you get something about this one? I'm facing another issue with Visualizer, did you notice that when nothing is sounding you have an amplitude level in the graph? If exists signal, represent a graph independent of the volume level.... it's driving me nuts...
@billyjoker Hi, sorry for the delay, I have checked the code and there might be a way to solve it, but it might be tedious and a headache since I am not the author.