The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1KB

  1. package com.roli.juce;
  2. import android.database.ContentObserver;
  3. import android.app.Activity;
  4. import android.net.Uri;
  5. //==============================================================================
  6. public class SystemVolumeObserver extends ContentObserver
  7. {
  8. private native void mediaSessionSystemVolumeChanged (long host);
  9. SystemVolumeObserver (Activity activityToUse, long hostToUse)
  10. {
  11. super (null);
  12. activity = activityToUse;
  13. host = hostToUse;
  14. }
  15. void setEnabled (boolean shouldBeEnabled)
  16. {
  17. if (shouldBeEnabled)
  18. activity.getApplicationContext ().getContentResolver ().registerContentObserver (android.provider.Settings.System.CONTENT_URI, true, this);
  19. else
  20. activity.getApplicationContext ().getContentResolver ().unregisterContentObserver (this);
  21. }
  22. @Override
  23. public void onChange (boolean selfChange, Uri uri)
  24. {
  25. if (uri.toString ().startsWith ("content://settings/system/volume_music"))
  26. mediaSessionSystemVolumeChanged (host);
  27. }
  28. private Activity activity;
  29. private long host;
  30. }