question

David T. Schaller avatar image
David T. Schaller asked

How to stop audio when FireTV switches to screensaver

We've got a problem with our Unity game; when the device switches to the screensaver, the in-game music should stop playing, but it does not. We don't have any idea how to tell the game to shut off the music. Is there any signal from the device that the game can listen for?
fire tv
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jhample avatar image
jhample answered
I have not tried it yet, but I assume that the app becomes the background process when the screensaver starts. So that may be something to check for. I actually disabled the screensaver for my game to get around any screensaver related issues like this.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Fire TV is essentially an Android API level 17 device (4.2). The screensaver will call onWindowFocusChanged(boolean) on the point in which it is turned on. You can implement that callback in their activity to be able to pause your app gracefully when this happens. Thanks.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Mark Sebesta avatar image
Mark Sebesta answered
As far as I know Unity3d does not have access to this function. At this point there seems to be no possible way for a Unity3d game that uses sound to be certifiable on the Fire TV. Please add an exception for this requirement as was done for the Media button requirement.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jhample avatar image
jhample answered
There is already an exception for this. I was given the following feedback for my app. Observation:- App continues to play audio after the system enters screen saver or standby mode (exception is granted for music apps) : Ensure that the app stops playing audio once the device begins displaying a screen saver (dream state) or enters standby mode. Note that if your app uses a framework such as Unity, you may ignore this requirement, as apps built on Unity3D do not receive DreamService intents.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David T. Schaller avatar image
David T. Schaller answered
Actually, you can mute the audio, using OnApplicationFocus.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Thanks David, yes OnApplicationFocus of all game objects receive a callback when the player gets or loses focus in unity. http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.OnApplicationFocus.html You can stop the player when this method is called back focusStatus is sent as true.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.