149 lines
3.8 KiB
Swift
149 lines
3.8 KiB
Swift
//
|
|
// VideoInstrictionsViewController.swift
|
|
// Guibe
|
|
//
|
|
// Created by Max Hunt on 02/06/2019.
|
|
// Copyright © 2019 8. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import AVKit
|
|
|
|
class VideoInstrictionsViewController: UIViewController, AVAudioPlayerDelegate {
|
|
|
|
var player = AVAudioPlayer()
|
|
|
|
@IBOutlet weak var backBtn: UIButton!
|
|
|
|
@IBOutlet weak var b1: UIButton!
|
|
@IBOutlet weak var b2: UIButton!
|
|
@IBOutlet weak var b3: UIButton!
|
|
@IBOutlet weak var b4: UIButton!
|
|
@IBOutlet weak var b5: UIButton!
|
|
@IBOutlet weak var stopBtn: UIButton!
|
|
|
|
|
|
@IBAction func b1p(_ sender: Any) {
|
|
disableAllButtons()
|
|
audioPlay(fName: "i-connect")
|
|
}
|
|
|
|
@IBAction func b2p(_ sender: Any) {
|
|
disableAllButtons()
|
|
audioPlay(fName: "i-wear")
|
|
}
|
|
|
|
@IBAction func b3p(_ sender: Any) {
|
|
disableAllButtons()
|
|
audioPlay(fName: "i-language")
|
|
}
|
|
|
|
@IBAction func b4p(_ sender: Any) {
|
|
disableAllButtons()
|
|
audioPlay(fName: "i-interface")
|
|
}
|
|
|
|
@IBAction func b5p(_ sender: Any) {
|
|
disableAllButtons()
|
|
audioPlay(fName: "i-charging")
|
|
}
|
|
|
|
@IBAction func stopBtnPressed(_ sender: Any) {
|
|
self.player.stop()
|
|
enableAllButtons()
|
|
}
|
|
|
|
@IBAction func backBtnPressed(_ sender: Any) {
|
|
self.dismiss(animated: true, completion: nil)
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
b1.accessibilityLabel = "connecting your ghibe"
|
|
b2.accessibilityLabel = "wearing your ghibe"
|
|
b3.accessibilityLabel = "ghibe language"
|
|
b4.accessibilityLabel = "ghibe interface"
|
|
b5.accessibilityLabel = "charging your ghibe"
|
|
backBtn.accessibilityLabel = "back"
|
|
stopBtn.accessibilityLabel = "stop"
|
|
|
|
stopBtn.alpha = 0.5
|
|
stopBtn.isEnabled = false
|
|
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
func disableAllButtons() {
|
|
self.b1.isEnabled = false
|
|
self.b2.isEnabled = false
|
|
self.b3.isEnabled = false
|
|
self.b4.isEnabled = false
|
|
self.b5.isEnabled = false
|
|
self.stopBtn.isEnabled = true
|
|
|
|
UIView.animate(withDuration: 0.3, animations: {
|
|
self.b1.alpha = 0.5
|
|
self.b2.alpha = 0.5
|
|
self.b3.alpha = 0.5
|
|
self.b4.alpha = 0.5
|
|
self.b5.alpha = 0.5
|
|
self.stopBtn.alpha = 1.0
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
func enableAllButtons() {
|
|
self.b1.isEnabled = true
|
|
self.b2.isEnabled = true
|
|
self.b3.isEnabled = true
|
|
self.b4.isEnabled = true
|
|
self.b5.isEnabled = true
|
|
self.stopBtn.isEnabled = false
|
|
|
|
UIView.animate(withDuration: 0.3, animations: {
|
|
self.b1.alpha = 1.0
|
|
self.b2.alpha = 1.0
|
|
self.b3.alpha = 1.0
|
|
self.b4.alpha = 1.0
|
|
self.b5.alpha = 1.0
|
|
self.stopBtn.alpha = 0.5
|
|
})
|
|
}
|
|
|
|
func audioPlay (fName: String) {
|
|
let path = Bundle.main.path(forResource: fName, ofType : "mp3")!
|
|
let url = URL(fileURLWithPath : path)
|
|
do {
|
|
player = try AVAudioPlayer(contentsOf: url)
|
|
player.delegate = self
|
|
player.play()
|
|
} catch {
|
|
debugPrint("Error in playing sound file \(fName).mp3")
|
|
}
|
|
}
|
|
|
|
func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) {
|
|
enableAllButtons()
|
|
}
|
|
|
|
|
|
/*
|
|
// MARK: - Navigation
|
|
|
|
// In a storyboard-based application, you will often want to do a little preparation before navigation
|
|
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
|
|
// Get the new view controller using segue.destination.
|
|
// Pass the selected object to the new view controller.
|
|
}
|
|
*/
|
|
|
|
}
|