UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Get Array from json file

Forums > SwiftUI

I try to get data from array to play videos that array have names of files videos mp4

func saveImageArray(){
    imageArray = [Image]()
   videofileName = [String]()

    for i in datas.users{
        if(i.date == Self.DateCheck.string(from: date)){
            for x in i.name{
                if(UIImage(named: x)?.pngData() != UIImage(named: "")?.pngData()){
                imageArray.append(Image(x))

              videofileName.append(String(x))

                }
             }
        }
    }
}

......
.....

images name is same name videos 
Ihave error here I think I cant get name of videos Here from array 

       let videoURL1 = Bundle.main.url(forResource:   videofileName[0], withExtension: "mp4")!
  let videoURL2 = Bundle.main.url(forResource:   videofileName[1], withExtension: "mp4")!
  let videoURL3 = Bundle.main.url(forResource:   videofileName[2], withExtension: "mp4")!

let urls = [videoURL1, videoURL2, videoURL3]

   VideoPlayer(player: AVQueuePlayer(items: urls.map { AVPlayerItem(url: $0) }))

2      

Not sure how JSON fits into this, as you don't have anything involving JSON in the code you posted. Please post all of the code that pertains to what you are trying to do. It's almost impossible to help if we're only given disconnected fragments.

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.