Video Application to Play many Videos on iPhone

Hi, I’m new to this forum and Swift and Xcode, I need to know how to build a video app that can show many local videos on my iPhone. Some YouTube video tutorial shows how to do it for one video only but I tried to make it for using 10 videos (not in a folder but local) and none of them show how to do it. If anyone have a link or an exemple that shows how to do it it would be very appreciated. The videos need to be selected in a list or scrolling list. Nothing on this? Thank you!

Hi @rocote Welcome!!

You can create a list of objects as Chris has demonstrated and then place you video files in the bundle, and create a method with the name when the user taps on a record in the list it calls your play method.

Here is some code you could use to create such a method.

guard let path = Bundle.main.path(forResource: "SampleVideo", ofType: "mp4") else {
        let videoURL = NSURL(fileURLWithPath: path)

        // Create an AVPlayer, passing it the local video url path
        let player = AVPlayer(url: videoURL as URL)
        let controller = AVPlayerViewController()
        controller.player = player
        present(controller, animated: true) {

Just replace “SampleVideo” with the name variable. Oh, and you need to import AVKit too.

Good luck!

1 Like