In my previous blog post, Implementing Voice Control with the Media Session API on Amazon Fire TV, I explained how you can implement the Media Session API to voice-enable the transport controls (play, pause, rewind, etc.) in your Fire TV app. In this post, I’ll share the nuances of handling near-field voice control, which uses the microphone button on the remote, and far-field voice control, which uses an Alexa-enabled device linked to a Fire TV.
Fire TV supports voice interaction through the microphone button on its remote (near-field control) and also through a connected Alexa device (far-field control). With near field, when a voice utterance is received, a blue line (Alexa chrome interface) appears as an overlay activity on top of Fire TV screen. The apps should take a cue at this time and either pause the video or turn the volume to zero. Audio apps should go on mute and follow recommended best practices for audio focus handling.
Additionally, pressing the microphone button on the remote control brings up the Alexa overlay on Fire TV and thus sends an Android lifecycle event, onPause() (which is independent of AUDIOFOCUS_LOSS event).
In general, your app should pause (or at least mute the audio) in response to voice interactions. Your application should be prepared to receive the events in any order allowed by Android. Among other options, users can instruct Alexa to start new applications or, for example, users can turn a sound system on or off. As a result, the audio capabilities might change while your playback is paused. You should properly react to all these changes before continuing playback. The release of the microphone button on the remote issues onResume() lifecycle event. Apps should resume their content from where the users left off after receiving this event, provided the app has also regained the audio focus.
Far-field control (when a Fire TV stick is paired with an Echo device) is slightly different in implementation from near-field in the sense that no voice chrome overlay appears when a user utters a voice command through a connected Echo/Dot device. Since there is no chrome overlay, onPause() and onResume() events aren’t triggered. Apps must continue to honor audio focus at all times and play only when they regain audio focus.
If far-field voice is passed through the Fire TV Cube (rather than a linked Echo device), the blue chrome appears on both the Cube and the TV on invocation. In this case, follow the same guidelines relevant for near-field utterances.
Test your app for the following scenarios to make sure your app handles audio focus in near-field and far-field utterances correctly.
Test near-field control: Open your app and play some content. Using your remote’s microphone button, say “Weather today” and then observe the following:
Test far-field control: Connect your Fire TV to an Alexa device or use Fire TV Cube and say “Alexa, weather today.” Then observe the following:
For the best user experience, keep these tips in mind: