create-with-swift / custom-avplayer-swiftui

Project mentioned on the article "Custom video player with AVKit and SwiftUI supporting Picture-In-Picture" on the Create with Swift website.
MIT License
41 stars 7 forks source link

Great project, code looks sound, but just does not work #1

Open jalexromero opened 2 years ago

jalexromero commented 2 years ago

Hi! I'm doing an app that organizes videos and then enables user to view them. Sounds pretty simple enough. I worked all aspects of the app and work, except for the video playing part. I found your app and studied it and makes total sense. Tried running it pointing it to LOCAL files and it just wont play the mp4s no matter where or how I copy them, or what flags I turn or not. I then tried loading a few mp4s to a website so I would have external URLs, and it also does not work. I tried several things including modifying the plist.info file to Allow arbitrary loads, etc. - but no success. Now as I said, the code seems logical and very similar to the approach I was planning to follow. I tried coding similar on my own and failed to do so. All apps I've done using iOS and Swift have worked so far, but it seems video has it's secrets. would love to exchange notes on how you made it work!

joeldrotleff commented 2 years ago

Hmm it works fine for me. I just had to set the url using Bundle.main i.e.:

.init(title: "First video", url: Bundle.main.url(forResource: "my_local_video", withExtension: "MOV")!.absoluteString)