3

I currently have an app which plays numerous animated gifs in .webm format. However, as I have this in a videoview, it gains audio focus, therefore other apps playing audio will stop.

Is there any work around to prevent this?

Thanks!

Tmarsh2
  • 417
  • 2
  • 16

1 Answers1

1

The only way that I found (personally, I do not recommend it) is copy VideoView class 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);

Finally I opted for ruxy solution but probably will not be an option in your case

Community
  • 1
  • 1
Ana Llera
  • 1,376
  • 16
  • 32
  • 1
    Thanks, Ana. In the end I ended up putting a MediaPlayer on a SurfaceView. Unfortunately it meant I had to make my own Media Controller, as you can only attach them to Video Views, but does sort my problem out. (an example can be found here http://stackoverflow.com/questions/16700587/how-to-attach-mediaplayer-with-surfaceview-in-android) – Tmarsh2 Apr 19 '16 at 13:28