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,
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