theothernt / AerialViews

A screensaver for Android TV devices including Nvidia Shield, Fire TV, and Chromecast with Google TV. Inspired by Apple TV's video screensaver.
GNU General Public License v3.0
469 stars 35 forks source link

Pressing Play on Shield TV remote is not passed on to app #30

Closed youri-- closed 2 years ago

youri-- commented 2 years ago

I just realized in the previous (0.99) release notes, it states "Media buttons will exit the screensaver and be passed to the app in the background".

I've had 0.99 installed, and now the newest release, but this never worked for me. The screensaver quits, but nothing else happens. VLC just closes the (streamed) video when screensaver starts it seems and pressing Play on the streams screen does nothing anyway, so nothing you can do about that. However Netflix doesn't pick up the play-press either. The screensaver quits and then I have to press Play a second time to get Netflix to resume the video.

Am I misunderstanding this feature or is something bugged for me?

I have a Shield TV Pro (2019) running its stock Android TV 9.

PS. Love your screensaver. Big thanks!

theothernt commented 2 years ago

Hmmm... that's an odd one. I don't use Netflix at the moment, so can try to replicate the issue with YouTube or Plex (if you use it). And just so we're on the same page...

  1. Open YouTube, pick a video, play at least 5 seconds
  2. Pause the video and wait the amount of time for the screensaver to start (5 mins for me)
  3. Let the screensaver play for 5 seconds, then press the Play button on your remote

And btw, I don't think you misunderstood anything. I may have missed something. The Shield is a little different compared to a TV so the keypress or codes it uses maybe different. If so, we'll figure it out and get it fixed!

youri-- commented 2 years ago

I had actually uninstalled YouTube, because I use SmartTubeNext, with the ATV Bridge for YouTube installed as well. The latter has the same package name as the official YouTube app, to enable voice search with STN. For your testing purposes, I uninstalled the bridge app and installed official YouTube from Play Store (side note: searching for "YouTube" in the Play Store weirdly only finds "YouTube for Kids"; had to search for "YouTube for Android TV" to find the regular YouTube app). I also installed YouTube for Kids.

I have screensaver time also set to 5 minutes. For testing I started a video in each app, let it play a bit and hit pause on remote. Then did nothing until Aerial Views screensaver started playing (4K/HEVC/HDR) for at all least a few seconds, then hit Play/Pause button on remote once.

Here are the results:

I don't use Plex, and didn't test it. I noticed YouTube, YouTube for Kids and SmartTubeNext, all keep the video "open", so to speak, when the screensaver starts, whereas Netflix and Prime close/stop the paused video when screensaver kicks in. Netflix resumes a video from its info screen with a Play press though. Whereas Prime Video doesn't; it only starts with an OK press (middle button in the dpad circle on the remote). So I would expect the Play press to at least be passed on successfully to YouTube for Kids, STN and Netflix as well.

BTW, middle button (inside dpad circle on remote) doesn't quit the screensaver, but maybe this is by design?

Might be worth noting, I have Button Mapper installed, and just in case it was interfering, before testing I turned it off in Android TV Settings > Accessibility.

theothernt commented 2 years ago

Interesting results, thanks for testing all those apps.

To get a few of the easier questions about of the way...

  1. The middle button is trapped by the Aerial Views as my thinking was that it's easy to accidentally press it (depending on the remote) when you're pressing left or right to skip
  2. For the apps that don't keep the video open while paused, I'm not sure there is much that can be done there as the keypress is probably ignored/disposed by the time the video is restored and listening for key/button presses

Both YouTube and Plex keep the video open while paused and those are what I tested with btw. I'll have to test with YouTubeNext and YT Kids to see what's going on.

Btw, you can turn off the 'skip next/previous video' in Settings, which means the OK/center button will be passed through if you want?

youri-- commented 2 years ago

Honestly I think passing the button press to Netflix could work (in theory, what do I know), because when you exit a video you end up on the same screen where you started the video. Which is where you can start the video with the play button on the remote, even when the "Resume ……" line isn't highlighted. When you back out of a playing video, the "resume" line is automatically highlighted, too, not that that matters. Here's a picture of such a screen after playing the video and closing it manually with the Back button on the remote: IMG_20211214_183558_resize_86

And here's a link to SmartTubeNext, just in case, because there's a bunch of places offering it for download and they're all shady, except for the author's github repo: https://github.com/yuliskov/SmartTubeNext It's recommended to grab the beta version (from the installation instructions) as it's very actively developed/updated.

And I don't actually mind the middle button and I like being able to skip, so that part's all good then!

Thank you for looking into this. If it's too much trouble to get it to work with Netflix, then so be it. It's a convenient feature, but it's only a single extra press if it doesn't work.

BTW what does the "Enable tunneling" option do? I noticed it's turned on in my settings, don't know why.

theothernt commented 2 years ago

One other thing I thought of... can you use one of the built in screensavers (ie. provided by Google) and see how that behaves? that'll give me a clue as whether it's possible to fix this issue or not...

About Tunneling, it's basically a hardware acceleration feature apparently needed for HDR. I'm not sure why it's not on automatically but I've left the option available just in case it causes problems - that said, it hasn't so far!

youri-- commented 2 years ago

One other thing I thought of... can you use one of the built in screensavers (ie. provided by Google) and see how that behaves? that'll give me a clue as whether it's possible to fix this issue or not...

Okay, I've tested with the stock Daydream screensaver. Never used it before, because I was worried the Chromecast message or clock would cause problems for my OLED TV in the long run.

Results are exactly the same as my earlier tests with your screensaver. Out of the ones I tested, it only works with regular YouTube.

Does that mean it's not possible for the other apps?

theothernt commented 2 years ago

I'm afraid so. Just to explain what I think is going on, if you're curious...

  1. When the screensaver starts, the current app is 'suspended' and is notified of this
  2. Some apps, like Netflix for example, will close their player to a) release memory and b) save play position
  3. When resuming, some apps may take 1+ seconds to restore state and during this time they 'miss' or aren't listening for button presses yet

To make sure my app doesn't cause any additional problems, when you press a button that my app doesn't use (eg. the Play/Pause button), I see that it's not on the list of buttons I use, then pass it back to the OS and say 'I didn't handle this'... and the app being resumed is now able to listen/handle it.

https://github.com/theothernt/AerialViews/blob/master/app/src/main/java/com/neilturner/aerialviews/ui/screensaver/DreamActivity.kt (line 30 onwards)

youri-- commented 2 years ago

Thank you, I appreciate the explanation! I've a better understanding now.

What's weird to me is how the YouTube app handles differently than YT Kids in this situation. The player does look different, but one would think they use the same video player codebase for the 2 apps, just with different controls, but maybe not. Oh, well.

I guess I could maybe file an issue on the SmartTubeNext repo to see if STN could catch the button press that's passed on.

Anyway, thanks again.