If you need to play multiple videos in the same view, there are seemingly two approaches: (1) create new AVPlayerLayers and AVPlayers each time; or (2) reuse the same ones.
Assume your class is designed to play multiple videos, and the following code is used to load a new video:
var player = AVPlayer()
var playerItem:AVPlayerItem?
var playerLayer:AVPlayerLayer?
// Get file path to <videoURL>
videoURL = getFilePath(videoURL)
// Create player & layer
playerItem = AVPlayerItem(URL: NSURL(fileURLWithPath: videoURL))
player = AVPlayer(playerItem: playerItem!)
playerLayer = AVPlayerLayer(player: player)
The second option, after creating a AVPlayerLayer and AVPlayer, is to reuse them. So you could replace the last two lines with this:
player.replaceCurrentItemWithPlayerItem(playerItem!)
What are the pros/cons of each option? Is it okay to use option 1, or is that considered wasteful?