americosfacebook / googletv-issues

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

Handling Audio Focus is not working on Google TV for transparent layout apps. #66

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
1. Audio Focus is not working when ever background app(youtube or tv stream) 
playing/running. But same functionality is working find in android mobiles.

Original issue reported on code.google.com by poornach...@gmail.com on 11 Jul 2012 at 4:09

GoogleCodeExporter commented 8 years ago
Please attach sample code that demonstrates this issue.

Original comment by mjo...@google.com on 16 Jul 2012 at 6:18

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 comment by poornach...@gmail.com on 27 Jul 2012 at 6:15

GoogleCodeExporter commented 8 years ago
FYI: here my activity is running with transparent background view.

Original comment by poornach...@gmail.com on 27 Jul 2012 at 7:36