Learn Courses My Dashboard

SwiftUI Video Player Could you please help me to access a specific local video from my bundle of videos?

I have two video players in my detail view, shown per tab in my NavigationView List. The video players play videos just fine from the Bundle.main.url, as long as I only call one video for VideoPlayer1 and VideoPlayer2 in my code. No matter the tab selected in my NavigationView List, each detail view plays the same videos, e.g., TabAFirstVid and TabASecondVid. I cannot get the second tab to play TabBFirstVid and TabBSecondVid.

I have a folder in the main bundle called First Vids, and it has TabAFirstVid and TabBFirstVid.

I have a folder in the main bundle called Second Vids, and it has TabASecondVid and TabBSecondVid.

I also have a Video struct that has
let firstVidUrl: URL
let secondVidUrl: URL

struct VideoList {
static let features = [

Video(firstVidUrl: URL(string: “https://drive.google.com/file/dummydataToSeeIfXcodeWillPlaySomething”)!,
secondVidUrl: URL(string: “https://drive.google.com/file/anotherdummydata”)!)

but since these are local videos, stored in my iCloud Drive, I do not know what their URLs are.

Here is a code snippet that doesn’t work:

struct VideoPlayerMP4: View {

@State var player = AVPlayerItem(asset: video.demovidUrl) The error is "cannot find “video” in scope.

Here is a code snippet that does work, but does not let me have specific videos per item in my Navigation List:

@State var player = AVPlayer(url: Bundle.main.url(forResource: “TabAFirstVid”, withExtension: “mp4”)!)

I will truly appreciate any help you might give.
All the best!