• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Application used MediaPlayer library always loss AUDIOFOCUS initially

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Application used MediaPlayer library always loss AUDIOFOCUS initially... I used emulator to run the application. When I googled I got the following link:

http://stackoverflow.com/questions/12334110/audiofocus-loss-called-after-phone-in-android

There they have said

" Two things to check: 1) Do you have a play button for instance, that when clicked, requests focus and starts playback? I had a problem once that they played a "tick" sound to provide feedback of a click. They would take audio focus away from my app when that happened. In your XML set this value to false for all your buttons in that activity:

android:soundEffectsEnabled = 'false'
2) Check for the installation of other media player apps that also request focus. Are they requesting focus right after losing it? If so there's not much you can do about this other than warn your users not to install this app.
"

I did first one. I don't know how to do the second thing in emulator.

How to avoid loss of audio focus?

 
Ranch Hand
Posts: 202
Android PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about check MediaPlayer is null or not (If i understand your correctly).

MediaPlayer mp;

if(!mp == null)
mp = null;
 
Jeyaganeshan Jeyatharsini
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked mediaplayer is not null.
 
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read these links.these might be useful

http://developer.android.com/reference/android/media/MediaPlayer.html
http://developer.android.com/guide/topics/media/mediaplayer.html

reply if you still not get solution of your problem
 
Seriously Rick? Seriously? You might as well just read this tiny ad:
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!