Deny my audio app using NuPlayer on Android Lollipop 5.x?

I have an audio application that plays several tracks simultaneously, each with its own mediaPlayer . Each track is quite long, more than two minutes.

While the tracks are encoded as ogg files, everything works fine on Android 4.x. I have not yet encountered a device working with a 4.x margin that has any sound problems with this setting.

But on Lollipop 5.x there are a lot of different sound problems - stuttering, cutting tracks and bluetooth sound almost never work.

I found that switching to the developer options in 5.x and unchecking the "use Nuplayer (experimental)" checkbox instantly solves these problems and returns to 4.x performance.

Is there a way by which I can programmatically force my application to use stacks for 4.x files (I think this is called Awesomeplayer?) And not use the new Nuplayer system? At least until I can find the source of Nuplayer problems?

+6
source share
2 answers

Update : Installing partial trace lock on MediaPlayer fixes this problem:

playerToPrepare.setWakeMode(context, PowerManager.PARTIAL_WAKE_LOCK);

Partial blocking of a track should not have too much effect, and it seems that MediaPlayer itself clears it when playback is completed.

- Original answer ---

So, I finally found a way to safely detect whether or not NuPlayer will be used or not on Lollipop. It seems like a better strategy is to tell the user to open the developer’s settings and enable AwesomePlayer until Google installs NuPlayer . Unfortunately, there is no good way to change this parameter for the user, we can just read its value if you are not subscribed as a system application.

This approach checks the values ​​of the properties of the Android system to see if the user has allowed the use of AwesomePlayer or not in the developer’s settings. Since Lollipop has NuPlayer by default, if this value is disabled, we know that NuPlayer will be used.

Drop SystemProperties.java into your project to access system properties, do not change its package name from android.os (it calls up to the corresponding JNI methods, so you need to stay the same).

Now you can check if the phone is Lollipop / 5.0 if AwesomePlayer turned on and acts accordingly if it is not (for example, by opening the developer’s settings):

 public void openDeveloperSettingsIfAwesomePlayerNotActivated(final Context context) { final boolean useAwesome = SystemProperties.getBoolean("persist.sys.media.use-awesome", false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && !useAwesome) { final Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); context.startActivity(intent); } } 
+3
source

Enabling / disabling NuPlayer did not help. But I had a wakelock part with a friendly interface. I’m going to look today at KitKat’s SysCtl and compare it with Lollipop, maybe I can find something interesting.

So bluetooth stuttering is connected to the dumb core on 5.02, which stutters as soon as the screen is off. I used partial wakelock, so the CPU remains active after the screen with this application. It is working. No more stuttering. For speakers that require a high sampling rate, I just switched the processor control to performance. A workaround, but partial wakelock should work especially on bluetooth headphones . Here's a link to the app https://play.google.com/store/apps/details?id=eu.thedarken.wl&hl=en

+1
source

Source: https://habr.com/ru/post/979912/


All Articles