MediaPlayer setDataSource failed with status=0x80000000 for Ringtone set by filepath on 2.3.4

Answer by Lorne below was most helpful when dealing with this problem. For anyone else struggling with it, here is the code that I have been using for over 6 months now with errors almost not reported anymore. fileinfo can be both of below (examples): /system/media/audio/alarms/Walk_in_the_forest.ogg content://media/internal/audio/media/20 public static void setMediaPlayerDataSource(Context context, MediaPlayer mp, String … Read more

How to prevent VideoView/MediaPlayer from stopping other apps’ audio?

Copy paste VideoView from Android sources and comment out these lines: AudioManager am = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); am.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN); You could name the new class MutedVideoView, for example. gist here: https://gist.github.com/vishna/7e9d3466bced8502fcdd

How to play audio continuously while orientation changes in Android?

Simplest Answer for this question. @Override protected void onSaveInstanceState(Bundle outState) { outState.putInt(“possition”, mpbg.getCurrentPosition()); mpbg.pause(); super.onSaveInstanceState(outState); } @Override protected void onRestoreInstanceState(Bundle savedInstanceState) { int pos = savedInstanceState.getInt(“possition”); mpbg.seekTo(pos); super.onRestoreInstanceState(savedInstanceState); }

MediaSessionCompat:Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent

If you are NOT USING PendingIntent anywhere. The issue might be resolved by adding or updating this dependency // required to avoid crash on Android 12 API 31 implementation ‘androidx.work:work-runtime-ktx:2.7.1’ This fixed my problem. You can execute ./gradlew app:dependencies in the terminal in your project and discover what dependency is including work-runtime with and older … Read more

Music player control in notification

You need to set a custom intent action, not the AudioPlayerBroadcastReceiver component class. Create a Intent with custom action name like this Intent switchIntent = new Intent(“com.example.app.ACTION_PLAY”); Then, register the PendingIntent Broadcast receiver PendingIntent pendingSwitchIntent = PendingIntent.getBroadcast(this, 100, switchIntent, 0); Then, set a onClick for the play control , do similar custom action for other … Read more