HomeiOS Developmentios - SwiftUI: Expending video participant in sheet to full display

ios – SwiftUI: Expending video participant in sheet to full display


Is there a approach to increase the video fully to the highest of the protected space? Looks as if no matter I attempt is not increasing it absolutely to the highest, or transferring it to the very high.

https://i.stack.imgur.com/NVSvs.jpg

var physique: some View {
    ZStack {
        if isLoadingVideo || !isVideoAvailable {
            VideoPlaceholderView(isLoading: $isLoadingVideo, onRefresh: refreshButtonTapped)
                .body(width: 220, peak: 220 * (16/9))
                .edgesIgnoringSafeArea(.high)
        } else if let participant = videoPlayer {
            VideoPlayer(participant: participant)
                .body(width: UIScreen.predominant.bounds.width, peak: UIScreen.predominant.bounds.width * (16/9)) // Adjusted to full width with facet ratio
                .onAppear {
                    participant.play()
                }
                .onDisappear {
                    participant.pause()
                    NotificationCenter.default.removeObserver(self, title: .AVPlayerItemDidPlayToEndTime, object: participant.currentItem)
                }
                .edgesIgnoringSafeArea(.high) // Prolong to the highest fringe of the protected space
        } else {
            Colour.black.edgesIgnoringSafeArea(.all) // Placeholder for no video
        }
    }
    .onAppear {
        if let url = currentVideoURL {
            videoPlayer = AVPlayer(url: url)
            videoPlayer?.play()
            NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: videoPlayer?.currentItem, queue: .predominant) { _ in
                videoPlayer?.search(to: CMTime.zero)
                videoPlayer?.play()
            }
        }
    }
    .onChange(of: currentVideoURL) { newURL in
        if let url = newURL {
            videoPlayer = AVPlayer(url: url)
            videoPlayer?.play()
        }
    }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments