I have a video without any audio playing in my activity, so if my music player is playing and my app is opened the music stops. I was wondering if there is a way to not request the Audio focus and let the music play in the background even when my video is playing ? I have tried abandoning audio focus after starting the video but that doesn't seem to work either.
Here's the code I have tried till now -
String path = "android.resource://" + getPackageName() + "/" + R.raw.backgroundvideo;
mvvBackground.setVideoURI(Uri.parse(path));
mvvBackground.setMediaController(null);
mvvBackground.start();
AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
am.abandonAudioFocus(new AudioManager.OnAudioFocusChangeListener() {
@Override
public void onAudioFocusChange(int focusChange) {
Log.d(LOG_TAG, "Audio focus changed!");
}
});
Any suggestions will be appreciated ! Thanks