From 6f7f02d5c8880ff670b2c694fe61f5af5a6e3e36 Mon Sep 17 00:00:00 2001 From: 无故事王国 <841720330@qq.com> Date: 星期四, 06 六月 2024 18:56:52 +0800 Subject: [PATCH] fix --- DolphinEnglishLearnStudent/Other/UIView/StudyHandleView.swift | 37 ++++++++++++++++++++++++++++++++++--- 1 files changed, 34 insertions(+), 3 deletions(-) diff --git a/DolphinEnglishLearnStudent/Other/UIView/StudyHandleView.swift b/DolphinEnglishLearnStudent/Other/UIView/StudyHandleView.swift index e9922d4..425f138 100644 --- a/DolphinEnglishLearnStudent/Other/UIView/StudyHandleView.swift +++ b/DolphinEnglishLearnStudent/Other/UIView/StudyHandleView.swift @@ -7,6 +7,7 @@ import UIKit import JQTools +import AVFoundation class StudyHandleView: UIView,JQNibView{ @IBOutlet weak var btn_choose: UIButton! @@ -17,15 +18,28 @@ var listenType:ListenType? private var clouse:((UIButton)->Void)? + private var playComplete:(()->Void)? + private var playAtClouse:((Int)->Void)? + + private var voicePlayer = VoicePlayer.share() + var vioceSoundUrl:String? override func awakeFromNib() { super.awakeFromNib() btn_state.alpha = 0 view_choose.alpha = 0 + + voicePlayer.playEnd {[weak self] in + self?.reset() + } } func chooseClouse(callback:@escaping (UIButton)->Void){ clouse = callback + } + + func playAt(_ clouse:@escaping(Int)->Void){ + self.playAtClouse = clouse } func copyView()->StudyHandleView{ @@ -34,9 +48,26 @@ return copyV } - @IBAction func payAction(_ sender: UIButton) { + func reset(){ switch listenType { - case .lesson1: + case .lesson1,.lesson5: + btn_state.setImage(UIImage(named: "icon_play"), for: .normal) + btn_voice.alpha = 1 + btn_pay.alpha = 1 + btn_state.alpha = 0 + case .lesson2: + view_choose.alpha = 1 + default:break + } + self.superview?.layoutIfNeeded() + } + + @IBAction func payAction(_ sender: UIButton) { + guard let v = vioceSoundUrl else {return} + voicePlayer.playerAt(url: v) + playAtClouse?(self.tag) + switch listenType { + case .lesson1,.lesson5: btn_state.setImage(UIImage(named: "icon_playing"), for: .normal) btn_voice.alpha = 0 btn_pay.alpha = 0 @@ -46,7 +77,7 @@ default:break } } - + @IBAction func chooseAction(_ sender: UIButton) { sender.isSelected = !sender.isSelected clouse?(sender) -- Gitblit v1.7.1