How to disable seeking within AVPlayer's native airplay controller (requiresLinearPlayback)?

We are using a custom player (AVPlayer) for our app, however when air-playing we default back to the native tvOS player.

Is there a way to disable seeking like there is on AVPlayerViewController with requiresLinearPlayback?
Answered by Media Engineer in 675656022
Aha, I see what you're saying now. The question is about the playback UI that is shown on the receiver, not the sender. I don't know for sure whether there is a way to do what you would like to do, so I think the best way forward is for you to file an enhancement request describing your use case. If there is already a way to do it, we can communicate that through the request.
I take this to mean that you have built your own UI around AVPlayer for the "custom" case. Assuming this is correct, couldn't you just tweak your UI to have no seek functionality?
Correct, we do have our own UI built around AVPlayer, but when air-playing the app defaults back to the native apple player instead of using our UI. With this in mind, I suppose there is two possible solutions here:
  1. Replace the native airplay player with our custom one so that we can control seek functionality

  2. Or, figure out a way to disable seeking on the native airplay player

For #1, can you offer some guidance on how we'd use our own UI for airplay? I haven't been able to find any code examples of this, nor have I seen it done by any popular media apps (Hulu, HBOMax, etc..)

If this isn't possible, then I'd be curious how to go about solving #2
Can you clarify exactly what API you refer to as "native airplay player?"
As far as preparing your own UI for AirPlay, it would help if you could describe why you are abandoning your custom UI in the first place for this case. AVPlayer supports AirPlay as-is, so if you already have a UI built around AirPlay it's not clear why you don't use the same UI for all cases.
When I say "native airplay player" I'm referring to the one that comes built in on the receiver end. For example, our app uses a custom player UI on iPhone (lets call this the sender) and when I cast to tvOS (the receiver) it defaults to the native tvOS UI rather than our own.

This is where the confusion may lie for me - we have a custom UI for iOS and tvOS, but when air-playing specifically from iPhone to tvOS it does not use the custom one. So, I suppose the first step here is learning how to force airplay to use our UI instead of the native one.

I know there's lots of "hand-waving" going on as I try to describe this situation, so please don't hesitate to ask for more clarification.

To give you a bit more context, we support playback with advertisements, and the ultimate goal is to prevent the ability to skip ads when airplaying. In its current state, if a user is solely watching on their iPhone or tvOS device (not casting), its easy enough for us to block seeking with our custom UI. However, as soon as they start casting from iPhone to tvOS, the native controls take over on tvOS and the user is able to skip ads with the tvOS remote.

I should make an important distinction in that there are two ways to watch on tvOS:
  1. By downloading the app on the tvOS device (uses our custom UI)

  2. By airplaying from the iphone app to the tvOS device (uses the native apple UI)

I think what it comes down to is - How do I ensure that airplay is using the custom UI? Is there some flag I need to set to tell it to use the UI we built around AVPlayer? Should it be happening automatically?


A follow up - can we listen for remote or seek events from airplay? I've been working to attach MPRemoteCommandCenter to the AVPlayer, but it just doesn't want to pick up any remote events while I'm airplaying.


>>>EDIT: This is the exact issue I'm having https://developer.apple.com/forums/thread/110322
Accepted Answer
Aha, I see what you're saying now. The question is about the playback UI that is shown on the receiver, not the sender. I don't know for sure whether there is a way to do what you would like to do, so I think the best way forward is for you to file an enhancement request describing your use case. If there is already a way to do it, we can communicate that through the request.
Great appreciate the help on this - I'll go ahead a file an enhancement request.
How to disable seeking within AVPlayer's native airplay controller (requiresLinearPlayback)?
 
 
Q