Creating a multiview video playback experience in visionOS. There is no back button on the player.

Function Introduction "https://developer.apple.com/documentation/avkit/creating-a-multiview-video-playback-experience-in-visionos/"

When I use this function, my videoPlayer has no back Action in player. And we did not find any method provided by the system "addChildViewControllerAndView(form)"

"https://developer.apple.com/documentation/avkit/adopting-the-system-player-interface-in-visionos" Referencing this document also did not work

As long as you enter this line of code

let playerController = AVPlayerViewController()
// Enable the multiview experience along with the default recommended set.
playerController.experienceController.allowedExperiences = .recommended(including: [.multiview])

there is no back button, only full screen and zoom out

Hey @Liangmu,

The addChildViewControllerAndView function is not a system provided function but rather a convenience function that encapsulates the steps required to add a child view controller. To learn more on the steps required to do this see Creating a custom container view controller.

Could you provide more information on when you are expecting a back button? There is no such button when the video player is playing in the embedded state. When the video is playing in full screen mode there is a button that closes the video player which returns you to the embedded state and/or your content. Do you not have such a button?

Let me know if that helps. Michael

Hi Michael, Could you try adding this code in the "DestinationVideo" demo:

controller.experienceController.allowedExperiences = .recommended(excluding: [.multiview])

I couldn’t find the addChildViewControllerAndView method. However, my implementation matches the example from the link you provided. I originally thought this method might include options for setting the video to full screen, but it seems it’s only for handling UI.

Also, I found an issue in the “DestinationVideo” demo with versions before visionOS 2.1. In the video playback page, when opening the playlist and selecting a video to play, the playlist doesn’t close automatically, which makes it impossible to interact. I tried using dismiss() in selectionAction, but it didn’t work either. It works fine in visionOS 2.1.

When I enable the multi-screen functionality, the back button disappears…

Hey @Liangmu,

Using the experienceController is mutually exclusive with the view controller’s existing API for managing the experience. Once you start using the experienceController, you must call .transition(to: .expanded) to transition the video to the expanded state. This is why you see the video presented in the embedded state with the controls contained within the window rather than seeing the video shown in the expanded state with the controls presented in an ornament.

DestinationVideo showcases the video playback APIs that use the view controller's API for managing the experience, it does not highlight the use of experience controller that is used for multiview playback.

Please let me know if you have additional questions,
Michael

I want this kind of display

The effect shown now

hi Apple

I want this back button, but because mutileView is set, this back button is gone, there are only full screen and zoom out buttons, and I can't operate the playback page back

Hey @Liangmu,

I'm sorry you're having difficulties using the multiview API. DestinationVideo does not showcase the use of the multiview API. As you've discovered, you can enable the multiview button with a single line of code by editing the allowedExperiences. However, if you perform this change on Destination Video and play a video, you become stuck in video playback where you can transition from playing the video in the embedded state or the expanded state, but you cannot leave the video player. This is not an issue with the multiview API, but this is due to the fact that there is no view to go back to. In DestinationVideo, player.presentation is set to .fullWindow causing the ContentView to only display the player view. The .presentation value is reset when the AVPlayerViewControllerDelegate receives the willEndFullScreenPresentationWithAnimationCoordinator call.

Once you start using the ExperienceController you can no longer use the AVPlayerViewControllerDelegate as called out the in docs. Instead you should use the AVExperienceController.Delegate. The multiview API is designed in a way in which your application starts video playback in the embedded state, preferable with additional content around the embedded video and then the user can use the buttons to either enter the expanded state or multiview states to add additional video. It is possible to design your application in such a way that mimics the behavior of DestinationVideo – showing a video in the expanded state and not supporting the embedded case. In order to do this, you will need to add the video player to the view hierarchy and call .transition(to : .expanded) to display the video full screen. Additionally, when the video transitions back to the embedded state you'll want to remove the video from the view hierarchy.

You can still file an enhancement request through Feedback Assistant with information on how this design impacts you. Bug Reporting: How and Why? explains how you can do that.

Please let me know if you have additional questions,
Michael

Creating a multiview video playback experience in visionOS. There is no back button on the player.
 
 
Q