Android Google Music App Stops When My Intro Video Plays
I'm using a VideoView in my Android app to display the intro animation. If the Google Music App is playing music in the background, calling videoview.start() stops music playing i
Solution 1:
Turns out Google Music App and a few other apps will stop their music when any video starts playing.
In order to make sure I'm not interrupting the listening experience for my users I now skip the intro video if I determine that there is music playing in the background.
To do this:
AudioManageram= (AudioManager) getSystemService(Context.AUDIO_SERVICE);
if (am.isMusicActive()) {
loadApp(); // skip video and go straight to the app
}
else {
videoView.start(); // play video
}
Solution 2:
Using both the answers previously given, here is a solution that will resume music after your video ends:
finalbooleanmusic_was_playing= ((AudioManager) getSystemService(Context.AUDIO_SERVICE)).isMusicActive();
VideoViewvv_Video= (VideoView) findViewById(R.id.intro_video_view);
// play the intro video
vv_Video.setOnCompletionListener( newOnCompletionListener() {
@OverridepublicvoidonCompletion(MediaPlayer m) {
// resume music if it was playing cause our intro video just paused it temporarilyif (music_was_playing) {
Intenti=newIntent("com.android.music.musicservicecommand");
i.putExtra("command", "play");
sendBroadcast(i);
}
// go to main menu
startActivity(newIntent(IntroActivity.this, MainMenuActivity.class));
}
});
Solution 3:
Taken from openVideo() in VideoView.java
Intenti=newIntent("com.android.music.musicservicecommand");
i.putExtra("command", "pause");
mContext.sendBroadcast(i);
Post a Comment for "Android Google Music App Stops When My Intro Video Plays"