mercredi 21 février 2018

Random video generator in macOS app

I'd like to make a random video generator for macOS. I have four QuickTime video files with Apple ProRes 422 codec: 0001.mov, 0002.mov, 0003.mov, 0004.mov.

I've got a code for making a random photo generator. How to correct this code to get a video generator in my macOS app?

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!

    @IBOutlet weak var view1: NSImageView!
    @IBOutlet weak var view2: NSImageView!
    @IBOutlet weak var view3: NSImageView!
    @IBOutlet weak var view4: NSImageView!

    func applicationDidFinishLaunching(_ aNotification: Notification) {

        let arrayOfViews: [NSImageView] = [view1, view2, view3, view4]

        let photos = (1...4).map {
            NSImage(named: NSImage.Name(rawValue: "000\($0)"))
        }

        for view in arrayOfViews {
            let randex = Int(arc4random_uniform(UInt32(photos.count)))
            view.image = photos[randex]
        }
    }
}

enter image description here




Aucun commentaire:

Enregistrer un commentaire