1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import Foundation
- class NCViewerVideoToolBar: UIView {
-
- @IBOutlet weak var playButton: UIButton!
- @IBOutlet weak var muteButton: UIButton!
-
- var player: AVPlayer?
-
- override func willMove(toWindow newWindow: UIWindow?) {
- super.willMove(toWindow: newWindow)
- if newWindow != nil {
-
- let blurEffect = UIBlurEffect(style: .dark)
- let blurEffectView = UIVisualEffectView(effect: blurEffect)
-
- self.layer.cornerRadius = 15
- self.layer.masksToBounds = true
-
- blurEffectView.frame = self.bounds
- blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
- self.insertSubview(blurEffectView, at:0)
- }
- }
-
- func setPlayer(player: AVPlayer?) {
- self.player = player
- }
-
- func setToolBar() {
-
- let mute = CCUtility.getAudioMute()
-
- if player?.rate == 1 {
- playButton.setImage(NCUtility.shared.loadImage(named: "pause.fill", color: .white), for: .normal)
- } else {
- playButton.setImage(NCUtility.shared.loadImage(named: "play.fill", color: .white), for: .normal)
- }
-
- if mute {
- muteButton.setImage(NCUtility.shared.loadImage(named: "audioOff", color: .white), for: .normal)
- } else {
- muteButton.setImage(NCUtility.shared.loadImage(named: "audioOn", color: .white), for: .normal)
- }
- }
- @IBAction func playerPause(_ sender: Any) {
-
- if player?.timeControlStatus == .playing {
- player?.pause()
- } else if player?.timeControlStatus == .paused {
- player?.play()
- }
- }
-
- @IBAction func setMute(_ sender: Any) {
-
- let mute = CCUtility.getAudioMute()
-
- CCUtility.setAudioMute(!mute)
- player?.isMuted = !mute
- setToolBar()
- }
-
- }
|