> For the complete documentation index, see [llms.txt](https://sagar-r-kothari.gitbook.io/blog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sagar-r-kothari.gitbook.io/blog/_posts/2020-01-30-playvideo.md).

# 2020-01-30-PlayVideo

```swift
import UIKit
import AVKit
import AVFoundation

extension YourViewController {
    func playVideo() {
        guard 
            let path = Bundle.main.path(forResource: "Animation", ofType:"mov") 
            else {
                debugPrint("ConnectAnimation.mov not found")
                return
        }
        player = AVPlayer(url: URL(fileURLWithPath: path))
        guard let player = player else { return }
        playerLayer = AVPlayerLayer(player: player)
        guard let playerLayer = playerLayer else { return }
        playerLayer.frame = videoContainerView.bounds
        videoContainerView.layer.addSublayer(playerLayer)
        player.actionAtItemEnd = .none
        player.play()
    }
}
```
