Commit 210ad2e5 authored by zhangzhe's avatar zhangzhe

处理音频问题

parent 7ceb0c54
......@@ -1361,8 +1361,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "ShorthandMaster/速记大师.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 8F4PP38DC3;
......@@ -1381,7 +1381,7 @@
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ShorthandMaster.www;
PRODUCT_NAME = "速记大师";
PROVISIONING_PROFILE_SPECIFIER = "";
PROVISIONING_PROFILE_SPECIFIER = ShorthandMasterDevProfile;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/ShorthandMaster/ShorthandMaster-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "ShorthandMaster-Swift.h";
SWIFT_VERSION = 5.0;
......@@ -1395,8 +1395,8 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = "ShorthandMaster/速记大师.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 3;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 8F4PP38DC3;
......@@ -1415,7 +1415,7 @@
MARKETING_VERSION = 1.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.ShorthandMaster.www;
PRODUCT_NAME = "速记大师";
PROVISIONING_PROFILE_SPECIFIER = "";
PROVISIONING_PROFILE_SPECIFIER = ShorthandMasterDevProfile;
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/ShorthandMaster/ShorthandMaster-Bridging-Header.h";
SWIFT_OBJC_INTERFACE_HEADER_NAME = "ShorthandMaster-Swift.h";
SWIFT_VERSION = 5.0;
......
......@@ -40,7 +40,8 @@ class SHInputController: SHBaseViewController
/// 是否是编辑
var isEdited = false
/// 是否有音频
var haveAudio = false
private var shInputView: SHInputView!
......@@ -124,7 +125,7 @@ class SHInputController: SHBaseViewController
self.shInputView.bottomView.timer.cancel()
self.playTimer.suspend()
self.playTimer.cancel()
if ((self.audioPlayer?.isPlaying) != nil)
if self.audioPlayer != nil
{
self.audioPlayer!.stop()
}
......@@ -134,7 +135,7 @@ class SHInputController: SHBaseViewController
// MARK: - UI
func addSubviews()
{
self.shInputView = SHInputView.init(frame: .zero, isEdited: self.isEdited)
self.shInputView = SHInputView.init(frame: .zero, isEdited: self.isEdited, haveAudio: self.haveAudio)
self.shInputView.textView.delegate = self;
self.shInputView.textView.shDelegate = self;
self.view.addSubview(self.shInputView!)
......@@ -195,8 +196,6 @@ class SHInputController: SHBaseViewController
override func goback()
{
self.navigationController?.popViewController(animated: true)
UserDefaults.standard.removeObject(forKey: "InputRecord")
}
// MARK: 点击navigationBar右侧按钮
......@@ -887,7 +886,8 @@ extension SHInputController: AVAudioPlayerDelegate {
print(error)
return
}
// try self.audioPlayer = AVAudioPlayer(contentsOf: URL(fileURLWithPath: DocumentPath + self.dataModel.pathFile), fileTypeHint: AVFileType.mp3.rawValue)
self.haveAudio = true
self.audioPlayer?.prepareToPlay()
self.audioPlayer?.numberOfLoops = 0 // 循环播放次数
......@@ -902,7 +902,7 @@ extension SHInputController: AVAudioPlayerDelegate {
// MARK: 点击播放/暂停按钮
@objc func didSelectedPlayButton(sender: UIButton)
{
if ((self.audioPlayer?.isPlaying) != nil)
if (self.audioPlayer!.isPlaying)
{
// 暂停
self.audioPlayer?.pause()
......@@ -929,7 +929,7 @@ extension SHInputController: AVAudioPlayerDelegate {
//
// self.audioPlayer.pause()
//
self.audioPlayer?.currentTime = max(self.audioPlayer?.currentTime ?? 0 - 10, 0)
self.audioPlayer?.currentTime = max((self.audioPlayer?.currentTime ?? 0) - 10, 0)
// self.playTimer.resume()
//
......@@ -945,7 +945,7 @@ extension SHInputController: AVAudioPlayerDelegate {
//
// self.audioPlayer.pause()
//
self.audioPlayer?.currentTime = min(self.audioPlayer?.currentTime ?? 0 + 2, TimeInterval(self.audioPlayer?.duration ?? 0))
self.audioPlayer?.currentTime = min((self.audioPlayer?.currentTime ?? 0) + 10, TimeInterval(self.audioPlayer?.duration ?? 0))
// self.playTimer.resume()
//
......
......@@ -61,17 +61,22 @@ class SHInputBottomView: UIView {
/// 是否为编辑状态
var isEdited: Bool = Bool()
/// 是否有音频
var haveAudio: Bool = Bool()
/// 计时器控制小红点闪烁
let timer = DispatchSource.makeTimerSource(flags: [], queue: DispatchQueue.global())
// MARK: - func
init(frame:CGRect, isEdited: Bool)
init(frame: CGRect, isEdited: Bool, haveAudio: Bool)
{
super.init(frame: frame)
self.isEdited = isEdited
self.haveAudio = haveAudio
self.backgroundColor = UIColor.white
self.layer.masksToBounds = true
......@@ -177,11 +182,13 @@ class SHInputBottomView: UIView {
self.playView = SHInputAudioPlayView()
self.addSubview(self.playView)
self.playView.isHidden = !self.isEdited
self.playView.isHidden = !self.haveAudio
// 播放进度条
self.progressView = SHInputProgressView()
self.addSubview(self.progressView)
self.progressView.alpha = self.isEdited ? 1 : 0;
self.progressView.alpha = self.haveAudio ? 1 : 0;
// 键盘按钮
self.keyboardButton = UIButton(type: UIButton.ButtonType.custom)
......
......@@ -19,14 +19,18 @@ class SHInputView: UIView {
/// 是否为编辑状态
var isEdited: Bool = Bool()
/// 是否有音频
var haveAudio: Bool = Bool()
// MARK: - func
init(frame: CGRect, isEdited: Bool)
init(frame: CGRect, isEdited: Bool, haveAudio: Bool)
{
super.init(frame: frame)
self.isEdited = isEdited
self.haveAudio = haveAudio
self.addSubviews()
self.setUpSubviewsLocation()
......@@ -64,7 +68,7 @@ class SHInputView: UIView {
self.textView.addSubview(self.placeholder)
// 底部栏
self.bottomView = SHInputBottomView.init(frame: .zero, isEdited: isEdited)
self.bottomView = SHInputBottomView.init(frame: .zero, isEdited: isEdited, haveAudio: self.haveAudio)
self.addSubview(self.bottomView)
}
......@@ -90,7 +94,7 @@ class SHInputView: UIView {
self.bottomView.mas_makeConstraints { (make) in
make?.left.right()?.bottom().mas_equalTo()(0)
make?.height.mas_equalTo()((self.isEdited ? 100 : 50) + SafeAreaBottomHeight());
make?.height.mas_equalTo()((self.isEdited && self.haveAudio ? 100 : 50) + SafeAreaBottomHeight());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment