4

On the new Android 5.0 Lollipop a new setting was added on the Developer Options called "Use NuPlayer (beta)". My app sometimes is not working well when this setting is enabled. I'm afraid when the new version of Android gets released to the public many people would enable it and have problems with my app without knowing what is wrong.

So I wanted to display a warning message about this only if the NuPlayer setting is checked on the device. I tried looking for it on the documentation of Android but I couldn't find how to access the status of this new setting.

So the question is that, how can I check the value of this setting programatically?

Thanks

Synx
  • 142
  • 1
  • 1
  • 9
  • Since NuPlayer is going to be the default (as far as I know) , should you consider filing a bug report instead on the issue you're facing? – harism Oct 25 '14 at 21:45
  • 1
    It's hard to replicate the bug, it happens with .webm files, and not always. I've been using the NuPlayer for a few days just fine and suddenly yesterday the videos played were showing a green noise all over the videos. It also doesn't only happened on my app but also on Google Chrome embeded videos, and not only happened to me but also to some other users of my app who have the 5.0 installed. I assume this bug was reported already, so for now I would like just to check the setting and warn about it, as I doubt it will get fixed before the release. – Synx Oct 25 '14 at 22:10
  • I see, unfortunately I have no idea is it possible to read this setting. But instead encourage you to file an issue on such a behaviour. At least I didn't find any bugs even nearly related to one you experience - and AFAIK NuPlayer has been enabled only since L preview so it's rather tiny user base at the end so far (if compare to all Android devices to avail). – harism Oct 25 '14 at 22:20
  • If it helps, you could continue using the `StagefrightPlayer` by setting a couple of system properties. Please refer to this code in the android framework: http://androidxref.com/5.0.0_r2/xref/frameworks/av/media/libmediaplayerservice/MediaPlayerFactory.cpp#63 . You can always set and read the system properties inside your code. – Ganesh Nov 09 '14 at 00:28
  • Just ran into this issue as well on my app. All users on Android 5.0.1 are seeing that the audio is being cut off before completion. Here's my StackOverflow regarding it: http://stackoverflow.com/questions/27789840/mediaplayer-cutting-off-playback-too-early-on-lollipop-when-screen-is-off/27827402#27827402 You'll see I've also filed a bug against Android. – b.lyte Jan 07 '15 at 19:48

1 Answers1

5

I'm cross-posting my answer from here by request:

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

So, I finally found a way to safely detect wether or not NuPlayer will be used or not on Lollipop. Seems like the best strategy for now is to inform the user to open Developer Settings and enable AwesomePlayer until Google fixes NuPlayer. Sadly, there's no good way to change this setting for the user, we can just read its value unless you're signed as a system application.

This approach checks Android's system properties values to see if the user have enabled the use of AwesomePlayer or not under Developer Settings. Since Lollipop have NuPlayer on by default, if this value is disabled, we know NuPlayer will be used.

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

You can now check if the phone is Lollipop/5.0, if AwesomePlayer is enabled, and act accordingly if it's not (e.g. by opening the Developer 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);                
    }
}
Community
  • 1
  • 1
Sveinung Kval Bakken
  • 3,715
  • 1
  • 24
  • 30