americosfacebook / googletv-issues

Automatically exported from code.google.com/p/googletv-issues
0 stars 0 forks source link

I need my app to get the audio focus when tv is ruuing a channel and my app is launched and loose focus when it goes to background. I tried it but not working in google tv. #72

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I need my app to get the audio focus when tv is ruuing a channel and my app is 
launched and loose focus when it goes to background. I tried it but not working 
in google tv. I tried 
mAudioManager.requestAudioFocus(this,AudioManager.STREAM_MUSIC,AudioManager.AUDI
OFOCUS_GAIN); It working in device.i.e music stopped as app launched. but not 
worked in google tv with any parameters. Steps for audio focus are:

1.In MainApp AudioManager mAudioManager = (AudioManager) 
getSystemService(Context.AUDIO_SERVICE); requestFocus();

In onresume() protected void onResume() { super.onResume(); requestFocus(); }
3.in onStop() protected void onStop(){ abandonFocus(); super.onStop();

    Log.e("APPLICATION", "APPLICATION onStop");
}
4.in onDestroy() public void onDestroy(){ super.onDestroy(); 
//Log.e("APPLICATION", "APPLICATION onDestroy"); abandonFocus(); } 5.Methods 
for AudioFocus.

/** Requests audio focus. Returns whether request was successful or not. */ 
public boolean requestFocus() { return AudioManager.AUDIOFOCUS_REQUEST_GRANTED 
== mAudioManager.requestAudioFocus(this, AudioManager.STREAM_DTMF, 
AudioManager.AUDIOFOCUS_GAIN);

    }

    /** Abandons audio focus. Returns whether request was successful or not. */
    public boolean abandonFocus() {
        return AudioManager.AUDIOFOCUS_REQUEST_GRANTED == mAudioManager.abandonAudioFocus(this);
    }

    /**
     * Called by AudioManager on audio focus changes. We implement this by calling our
     * MusicFocusable appropriately to relay the message.
     */
    public void onAudioFocusChange(int focusChange) {

        switch (focusChange) {
            case AudioManager.AUDIOFOCUS_GAIN:
                Log.e("AUDIOFOCUS","AUDIOFOCUS_GAIN");
                break;
            case AudioManager.AUDIOFOCUS_LOSS:Log.e("AUDIOFOCUS","AUDIOFOCUS_LOSS");
            case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT:Log.e("AUDIOFOCUS","AUDIOFOCUS_LOSS_TRANSIENT");

                break;
            case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK:Log.e("AUDIOFOCUS","AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
                break;
             default:
        }
    }
Can any one please help me in this. who did the audio focus in google tv.

Original issue reported on code.google.com by poornach...@gmail.com on 30 Jul 2012 at 10:34

GoogleCodeExporter commented 8 years ago
Please ask questions on StackOverflow:
http://stackoverflow.com/questions/tagged/google-tv

Original comment by mjo...@google.com on 15 Aug 2012 at 11:56