question

Marsh avatar image
Marsh asked

Web App : Sleep : Audio continues to play from HLS video stream

Using the WASK our m3u8 HLS URL continues to play audio when the FireTV 4K is put to sleep. There is a slight pause so our guess is it continues to play the audio-only track of the m3u8 which is not expected or desired behavior.

Most of what we have found on the forums and elsewhere point to Android apps handling the onPause() event, has anyone dealt with it in the web app world?

fire tvaudioweb appsvideoapp
10 |5000

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

Jacek avatar image
Jacek answered

Hi Marsh,

1. If your WASK app plays videos, you should request 'Prevent Sleep for Video Playback' during the app submission (on your App File(s) tab). This flag will prevent Fire TV from going to sleep while your app is streaming any video
2. If you requested that flag, it means that you either exited your app using back or menu key on remote. In the first case, I assume you do your cleanup, in the second you need to intercept 'pause'/'resume' events.
3. In your JS code, you should add event listener for at least 'pause' event. My understanding is that Amazon expects you to pause your playback when that event kicks in, and resume playback from where it stopped when 'resume' kicks in. However, I would suggest that you abort your playback during 'pause' event (you don't know how long your app will stay in that paused state, and potentially when it returns to life, your video may be not there anymore - it may be easier to implement 'resume playback from where you stopped' than to deal with some convoluted error scenarios coming out of nowhere).

Based on the above, if Fire TV is transitioning to 'sleep' mode while your app is playing videos, it would suggest that you may want to look at #1 above. If you trigger that 'sleep' mode by using menu button on your remote, you may want to look at #3 above. Although, even if you request that permission from #1, it would be still beneficial to look into #3, as your app will end up in that state when menu button is being used.

Thank you, Jacek

10 |5000

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

Dixie Normous avatar image
Dixie Normous answered

I just actually ran into this myself. And, I do believe there's a bug in the Amazon framework that makes this way more difficult than it should be. Hooking to the system pause event is simple. BUT, the resume event fires when it should not. EX. Press-Hold on the HOME button on the remote and you will get an overlay (HUD) menu. This fires the system pause on your app. But, if you select any of the items on the menu, the menu is dismissed, and you get the system resume, even though your app will no longer be in the foreground. The only safe thing to do is catch system pause and pause anything playing. In the system resume handler, just set state that you have returned from the interruption, but you must make the user press a button to continue any playback.

10 |5000

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

nbc4292 avatar image
nbc4292 answered

I'm experiencing the same issue with the fire tv app builder. Any suggestions on how to fix this setting in android studio?

10 |5000

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