// // AppDelegate.swift // asgn // // Created by Hamza on 12/09/18. // Copyright © 2018 Hamza. All rights reserved. // import Cocoa import AVFoundation; import AVKit; @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var outletscroll: NSScrollView! var playView = AVPlayer(); var soundPlayer = AVAudioPlayer(); @IBOutlet var outletTextView: NSTextView! @IBOutlet weak var window: NSWindow! @IBOutlet weak var outletVideo: AVPlayerView! @IBOutlet weak var outletImage: NSImageView! @IBAction func play(_ sender: NSButtonCell) { print("playing") ; soundPlayer.play(); } func applicationDidFinishLaunching(_ aNotification: Notification) { // Insert code here to initialize your application // print("test"); let bundlePath = Bundle.main.resourcePath // print(bundlePath!) ; outletImage.image=NSImage(contentsOfFile: bundlePath!+"/test.png") if let filepath = Bundle.main.path(forResource: "readme", ofType: "txt"){ do { let contents = try String(contentsOfFile: filepath) // print(contents) outletTextView.string = contents; outletTextView.isEditable = false ; } catch { // contents could not be loaded } } else { print ("else"); } let fileURL = NSURL(fileURLWithPath: bundlePath!+"/test.mov"); playView = AVPlayer(url: fileURL as URL); outletVideo.player = playView ; print("video") do { soundPlayer = try AVAudioPlayer(contentsOf: URL.init(fileURLWithPath: Bundle.main.path(forResource: "test", ofType: "m4a")!)) soundPlayer.prepareToPlay(); print("playing") } catch { } outletscroll.isHidden=false; outletVideo.isHidden=false; outletImage.isHidden = false; } func applicationWillTerminate(_ aNotification: Notification) { // Insert code here to tear down your application } }