SRGSSR / srgletterbox-apple

The official SRG SSR media playback experience
https://srgssr.github.io/marketing/letterbox/
MIT License
14 stars 7 forks source link

tvOS support #167

Closed crymscom closed 4 years ago

crymscom commented 5 years ago

Hello, we are evaluating the feasibility of developing an app for Apple TV that integrates the Letterbox frameworks.

Could you please tell us if is supported or if is planned for the future?

defagos commented 5 years ago

Hi! Sorry, at the moment there is no work going on in making our Letterbox ecosystem compatible with tvOS. This is of course something we would like to provide (in fact we already hacked some SRG Media Player-based tvOS app prototype in the past), but this requires work for which we sadly have no dedicated time at the moment.

defagos commented 5 years ago

For information, we have started work to add tvOS support to SRG Media Player.

This looks very promising, but of course requires further work. SRG Letterbox support is still far away, though, as we have to update several more frameworks to make it possible.

This work is done on our spare time, though, so we cannot promise you when tvOS support will be delivered in a stable form.

crymscom commented 5 years ago

Hello, thank you for your update.

We have also worked to adapt the frameworks to support tvOS and at the moment I believe we have reached our goal.

We have removed all references to not supported features on Apple TV as CoreMotion, PictureInPicture, ... and recompiled these frameworks:

We've developed a demo app and the livestreams are played correctly with the analytics integration. We need more tests but I think that for our purpose this could be a good start.

We have forked your repositories to ours and added a new branch to work on. If you need I can share my work with you.

Let me know if you're interested.

defagos commented 5 years ago

Hi!

We are interested in seing the result, especially what it looks like in Letterbox, so that we can have a better understanding / estimate of the required UI work we might have to do. Thanks for the proposal!

crymscom commented 5 years ago

Ok so I will push my branch to your repository under feature/tvOS-cryms. It's ok for you?

I don't know if I've write permission, could you check?

defagos commented 5 years ago

You don't have write permissions on our repository (since you are not part of the core player development team), so your branch cannot be pushed there I am afraid.

I am not sure if you have noticed, but Letterbox is now entirely open source. So if there is nothing preventing you from doing it, couldn't you make your fork public as well and give us the link? Thanks!

crymscom commented 5 years ago

Ok no problem.

I've re-created the fork directly on GitHub so you can reach it more easily and I've sent to you the relative pull requests for theese projects:

As I wrote in the pull request description:

Due to time limits I didn't handled tvOS as a second target but I simply adapted the project removing or changing the conflicting parts of the code.

The best thing would be to create a new target and manage code blocks using #if TARGET_OS_IOS or #if TARGET_OS_TV as you made on your "tvOS branch" of SRGMediaPlayer

So I'me sorry if my solution it's not the cleanest one.

defagos commented 5 years ago

Thank you very much! I'll try to have a look at it in the upcoming days.

Don't be sorry if your solution is not clean, I think this is not your goal here. We'll hopefully able to deliver full tvOS support in a not so distant future anyway.

defagos commented 5 years ago

tvOS support is being added at the moment. Here is a checklist of what still needs to be done:

defagos commented 5 years ago

Issues with content proposal implementation:

Other issues remaining with the current implementation:

defagos commented 5 years ago

The two content proposal issues above have been fixed by setting the content proposal time to zero.

defagos commented 5 years ago

The Apple TV should respond to the user in a standard way according to the HIG.

In Apple and third-party apps (Youtube, Vimeo, Twitchy, Arte, TED, Netflix), tapping the Menu button once returns to the previous screen. This is also the behavior in Apple apps, except in the TV app, where tapping on this button on the player view displays an overlay for metadata (not displayed in the top info panel in this special case), requiring another tap to go back to the previous screen.

Long-pressing the Menu button returns to the Apple TV home screen. Playback is paused and is usually automatically resumed if the user returns to the app at a later time.

Single pressing the Home button is a standard action configured in the Apple TV settings Remote and Devices section. The only possible values are Apple TV home screen or TV app home screen. In both casses, playback is paused and is usually automatically resumed if the user returns to the app at a later time.

We should have similar behavior for SRGLetterboxViewController. This behavior must not be implemented in SRGMediaPlayerViewController, as this view controller can be freely presented or added as child view controller.

defagos commented 5 years ago

The 360° leak described above is not really a leak, merely an incorrect behavior we have on tvOS. I recommend we implement the following approach to ensure consistency with our iOS implementation and usual tvOS player behavior:

defagos commented 5 years ago

@crymscom We have made significant progress on Letterbox for tvOS. Most of the work will now be done within a few days. Before we officially publish a Letterbox release with tvOS support, we still need to receive dedicated TagCommander SDKs, and we would like to validate that the work we have done is actually compatible with AppStore validation rules (this should be the case since we didn't do anything prohibited, but you never know).

For this to succeed your assistance would be greatly appreciated. We discussed a strategy with @pyby , and though the details might slightly change, here is a first proposal I would like to share with you. We can discuss and refine it further with your input, of course, and you are perfectly free to refuse the overall idea or to propose something entirely different:

If this seems sound to you or if you have feedback, feel free to contact us. You might of course want to talk with RSI as well to plan things a bit ahead. If you want to discuss it directly over the phone, we of course stay at your disposal. Though building the Letterbox demo currently requires a trick because of the missing TagCommander SDKs, we can share instructions with you if you want to have a look at the result yourself.

Thanks in advance for your help!

defagos commented 4 years ago

The native content proposal mechanism cannot sadly be used to implement continuous playback. The issue is that the content proposal internal implementation changes the player state to directly resume content at the beginning (see official documentation).

Since we might want the next item in a playlist to resume at a precise location, not at the beginning (e.g. resume playback, next content is a segment from a full-length), the player changes conflict with ours and in most cases force the player to restart at the beginning.

For this reason, we need to display our own user interface for continuous playback.

pyby commented 4 years ago

On tvOS 12.4, we should test again:

defagos commented 4 years ago

There is still a minor issue with the tvOS Letterbox view controller: If playback is paused, then resumed, and the player closed afterwards (even after a while), audio playback continues in the background for a little while.

Doing the same with SRG Media Player tvOS view controller works fine, and there is no issue on iOS devices.

Update

The issue is related to AVPlayerViewController which, if pause has been triggered once (and thus the standard controls) will setup some accessibility stuff retaining the controller for a while longer, thus the issue. In fact, the issue affects all platforms, though less visible on iOS (you can see that the SRGMediaPlayerController dealloc method is called much later by setting up a breakpoint).

To fix the issue, it should suffice to call -reset on the controller when the view disappears

defagos commented 4 years ago

The issue discussed above has been fixed on feature/early-deallocation branches, ~both~ on ~SRG Media Player and~ SRG Letterbox repositories. These are ready for code review.

Update

The fix in SRGMediaPlayerViewController must not be made, as it would conflict with PiP. Moreover, sound does not continue in background in this case. For the moment, it is best to perform the fix only in Letterbox tvOS view controller.

defagos commented 4 years ago

Another issue was found: There should be automatic page view tracking for Letterbox view controller on tvOS.

This is pretty much standard and after giving it some thought I recommend we implement automatic SRGMediaPlayerViewController tracking in SRG Analytics. This way the behavior is inherited by Letterbox automatically, as its tvOS view controller embeds a media player view controller as child.

The simplest approach is to conform to SRGAnalyticsViewTracking, and to use a fixed page title (I simply propose player). I doubt there is a need for customization, and this avoids unnecessary complicated logic, while ensuring measurements are made according to our standards when the view appear for the first time.

An implementation proposal is available on SRG Analytics feature/tvOS-player-view-event branch.

pyby commented 4 years ago

To fix the issue, it should suffice to call -reset on the controller when the view disappears

For now, we don't have a feature request to keep the controller alive when closing the SRGLetterboxViewController but on SRGMediaPlayerViewController, we must not reset it if it disappears because Picture in Picture started.

Update

@defagos and me kept only the fix on SRGLetterboxViewController~tvOS version, that has no PiP.

pyby commented 4 years ago
pyby commented 4 years ago

@svenduvoisin reported an UX experience issue with Letterbox demo:

With the Apple remote, click (click and hold) on the right side to seek forward.

After displaying one time the control bar, the "native default" behaviour is as expected.

Tested on 2 AppleTV with tvOS13.x at the office:

defagos commented 4 years ago

The user interaction issue has been fixed. It was due to userInteractionEnabled being toggled on AVPlayerViewController view, which seems not to be supported well enough.

The price to pay is that the UI can be toggled in situations where the UI is not so useful (error, countdown, end of playback), but this is probably the price to pay for having a good UX, and is not really a problem from a usability point of view.

defagos commented 4 years ago

🍾