adamzarn / AZVideoPlayer

An alternative to SwiftUI's VideoPlayer that includes an overlay button that will transition the player to be presented full screen.
26 stars 5 forks source link

Heads up, it doesn't work in iOS 16. #1

Open SoloUnity opened 1 year ago

SoloUnity commented 1 year ago

As the title says, other than that I love it!

adamzarn commented 1 year ago

@SoloUnity Can you explain what's not working in iOS 16? I just tested and the only difference seems to be that the AZVideoPlayer view takes up the full safe area by default. It should work the same as iOS 15 if you add .aspectRatio(16/9, contentMode: .fit):

Simulator Screen Recording - iPhone 13 Pro - 2022-07-30 at 16 11 57

SoloUnity commented 1 year ago

Hi, it does not work for me except I use AZVideoPlayer with a couple of additional modifiers. Attached is a video and the relevant code, which worked fine in iOS 15.

https://user-images.githubusercontent.com/77747704/182028416-a3d2c3fd-fa8d-4316-a7aa-72a11957ac16.mp4

image

adamzarn commented 1 year ago

@SoloUnity Now that I try it in the context of my project I'm also seeing issues. For me the overlay buttons just don't appear at all. I'll have to look into this.

adamzarn commented 1 year ago

@SoloUnity Something I have realized is that on iOS 16 the overlay buttons will not appear if the player is in a List (that goes for the SwiftUI provided VideoPlayer as well - must be a bug). I think I'll have to start using a LazyVStack inside of a ScrollView.

I can't reproduce the issue you're having, can you share the entire file? My best guess is that there's not enough available space in your design to show all of the overlay buttons. iOS will automatically remove buttons depending on the available space.

adamzarn commented 1 year ago

@SoloUnity Based on your code snippet, I was able to figure out that it will work in a List if you add .shadow(radius: 0). I'm going to update the README with that tip.

SoloUnity commented 1 year ago

Unfortunately, even with .shadow(radius: 0), the problem still persists on my end. In my case, the video is not in a list but in a poppet sheet / view. I have attached the file as well as the link to the project where I am using it. SkinCardDetailView.swift.zip

https://github.com/SoloUnity/Valorant-Store-Checker-iOS-App

adamzarn commented 1 year ago

@SoloUnity I think the root of your problem is that you're presenting it in a sheet. When you present it in a sheet, all of the buttons are inset a bit more and the full screen button becomes a close (x) button, probably because the @Environment variable isPresented is true and that conflicts with the video players @Environment variable. This might be why SwiftUI doesn't include the full screen button by default:

simulator_screenshot_DB5C9BB3-6B63-45D8-9F2E-E279955AB183

adamzarn commented 1 year ago

@SoloUnity All that to say, I'm not sure how to fix it. I'd be interested to hear of any solutions you can come up with.