1

Well I've done an app in android studio and this app has a video running in background for the Login. The video is in a VideoView and works perfectly but when I was testing it in my phone while I was playing music I noticed that it pauses the music player. How can I solve this?

protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    vid = findViewById(R.id.videoView2);
    Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.video);
    vid.setVideoURI(uri);
    vid.start();
    vid.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
        @Override
        public void onPrepared(MediaPlayer mp) {
            mp.setLooping(true);
        }
    });
    usuRut = findViewById(R.id.usuRut);
    girPass = findViewById(R.id.usuPass);
    girId = findViewById(R.id.girId);
}

This is where I run the video.

Asez97
  • 51
  • 5
  • Possible duplicate of [How to prevent VideoView/MediaPlayer from stopping other apps' audio?](https://stackoverflow.com/questions/29280191/how-to-prevent-videoview-mediaplayer-from-stopping-other-apps-audio) – IteratioN7T Sep 14 '18 at 08:23

2 Answers2

4

videoView.setAudioFocusRequest(AudioManager.AUDIOFOCUS_NONE);

Prayag
  • 422
  • 3
  • 9
0

You need to use the setAudioFocusRequest method. It's only available from API level 26

Ravjit Singh
  • 798
  • 5
  • 17