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

后端 未结 3 532
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 07:13

In one screen I have a looping background video (upon which normal UI elements are shown), implemented with VideoView like this:

String resPath = \"android.         


        
3条回答
  •  余生分开走
    2020-12-06 07:45

    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

提交回复
热议问题