had to edit this because I wrote it in a confused way.
I'm looking to create an Array, where each entry can be used to replace a function's parameters like this:
func playMe(inputfile: String, inputtype: String)
with
playMe(videoArray[0])
and that would then replace
inputfile: String, inputtype: String
with
inputfile: "file", inputtype: "mp4"
How would I go about creating it? I've tried
var videoArray = [""Nameofvideo", inputtype: "mp4"", ""Nameofvideo2", inputtype: "mp4""]
but it simply does not want to work. What am I missing? Am I trying to do this in a too complex fashion? I was hoping to emerge with
playMe(videoArray[1])
and then follow it with audioArray[1] for the followup mp3. Hmm?
Here is my playMe code:
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: "itemDidFinishPlaying:", name: AVPlayerItemDidPlayToEndTimeNotification, object: nil)
}
func playMe(inputfile: String, inputtype: String) {
let path = NSBundle.mainBundle().pathForResource(inputfile, ofType:inputtype)!
let videoURL = NSURL(fileURLWithPath: path)
let playerItem = AVPlayerItem(URL: videoURL)
let player = AVPlayer(playerItem: playerItem)
playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = self.view.bounds
self.view.layer.addSublayer(playerLayer)
player.play()
}
func itemDidFinishPlaying(notification: NSNotification) {
playerLayer.removeFromSuperlayer()
}