android-openslmediaplayer icon indicating copy to clipboard operation
android-openslmediaplayer copied to clipboard

Disabling "Smooth fade in/out" when starts/pauses playback

Open anonym24 opened this issue 8 years ago • 14 comments

Hi. I need fast pause without any fade. Can I turn it off somehow?

anonym24 avatar Apr 16 '17 15:04 anonym24

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;
			}
			
		};

rtaylor205 avatar Apr 18 '17 22:04 rtaylor205

@anonym24 Hi. As @stickyd has mentioned, his solution is the appropreate way to configure OpenSLMediaPlayer/HybridMediaPlayer not to use smooth fading.

h6ah4i avatar Apr 18 '17 23:04 h6ah4i

thanks) it suits me more

anonym24 avatar Apr 19 '17 20:04 anonym24

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 avatar Jul 13 '17 13:07 martppa

@martppa I second you on this. It is making screeching sound on seeking after disabling fade.

hunnydarapstar avatar Nov 22 '17 06:11 hunnydarapstar

@hunnydarapstar Hi, I fixed this issue. clone my fork and build the native library.

martppa avatar Nov 22 '17 17:11 martppa

@martppa okay Thanks

hunnydarapstar avatar Nov 29 '17 05:11 hunnydarapstar

@martppa can you build the library and upload it coz I am encountering errors while building from source

hunnydarapstar avatar Dec 04 '17 08:12 hunnydarapstar

Sure, here you are

https://mega.nz/#!ppIG0a7R!sxRXMZSgqnhlDIopg8f_1yOwb4o-deBdaUJPMy540jw

If you have any other issue let me know.

martppa avatar Dec 04 '17 08:12 martppa

@martppa Thanks a ton bro.. btw I have successfullt build the library from source. Cmake was not installed on my lappy, my bad..!!

hunnydarapstar avatar Dec 04 '17 08:12 hunnydarapstar

@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 avatar Feb 08 '18 19:02 billyjoker

@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 avatar Feb 08 '18 19:02 martppa

@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 avatar Feb 15 '18 10:02 billyjoker

@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.

martppa avatar Feb 22 '18 16:02 martppa