Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
ShorthandMaster
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lmj
ShorthandMaster
Commits
1daaf8c8
Commit
1daaf8c8
authored
Sep 29, 2020
by
zhangzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改bug
parent
6f7db351
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
257 additions
and
68 deletions
+257
-68
SHInputController.swift
ShorthandMaster/Input/Controller/SHInputController.swift
+253
-64
SHInputAudioPlayView.swift
ShorthandMaster/Input/View/SHInputAudioPlayView.swift
+1
-1
SHInputBottomView.swift
ShorthandMaster/Input/View/SHInputBottomView.swift
+1
-1
SHInputView.swift
ShorthandMaster/Input/View/SHInputView.swift
+2
-2
No files found.
ShorthandMaster/Input/Controller/SHInputController.swift
View file @
1daaf8c8
...
@@ -37,6 +37,13 @@ class SHInputController: SHBaseViewController
...
@@ -37,6 +37,13 @@ class SHInputController: SHBaseViewController
/// 播放计时器
/// 播放计时器
let
playTimer
=
DispatchSource
.
makeTimerSource
(
flags
:
[],
queue
:
DispatchQueue
.
global
())
let
playTimer
=
DispatchSource
.
makeTimerSource
(
flags
:
[],
queue
:
DispatchQueue
.
global
())
/// 播放计算器是否正在计时
var
playTimerCounting
=
false
/// 播放完成
var
playFinished
=
false
/// 是否是编辑
/// 是否是编辑
var
isEdited
=
false
var
isEdited
=
false
...
@@ -81,21 +88,27 @@ class SHInputController: SHBaseViewController
...
@@ -81,21 +88,27 @@ class SHInputController: SHBaseViewController
}
}
// 初始化播放计时器
// 初始化播放计时器
self
.
playTimer
.
schedule
(
deadline
:
.
now
(),
repeating
:
0.03
)
self
.
initPlayTimer
()
self
.
playTimer
.
setEventHandler
{
DispatchQueue
.
main
.
sync
{
self
.
shInputView
.
bottomView
.
progressView
.
slider
.
value
=
Float
(
self
.
audioPlayer
?
.
currentTime
??
0
)
/
Float
(
self
.
audioPlayer
?
.
duration
??
0
)
self
.
shInputView
.
bottomView
.
progressView
.
timeLabel
.
text
=
self
.
viewModel
.
getTimeStringWithSeconds
(
seconds
:
NSInteger
(
self
.
audioPlayer
?
.
currentTime
??
0
))
}
}
self
.
addSubviews
()
self
.
addSubviews
()
self
.
setUpSubviewsLocation
()
self
.
setUpSubviewsLocation
()
}
}
override
func
viewWillAppear
(
_
animated
:
Bool
)
{
super
.
viewWillAppear
(
animated
)
// 禁用右滑返回
self
.
navigationController
?
.
interactivePopGestureRecognizer
?
.
isEnabled
=
false
}
override
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
// 恢复右滑返回
self
.
navigationController
?
.
interactivePopGestureRecognizer
?
.
isEnabled
=
true
}
override
func
viewDidDisappear
(
_
animated
:
Bool
)
{
override
func
viewDidDisappear
(
_
animated
:
Bool
)
{
super
.
viewDidDisappear
(
animated
)
super
.
viewDidDisappear
(
animated
)
...
@@ -195,7 +208,23 @@ class SHInputController: SHBaseViewController
...
@@ -195,7 +208,23 @@ class SHInputController: SHBaseViewController
// MARK: 点击navigationBar左侧按钮
// MARK: 点击navigationBar左侧按钮
override
func
goback
()
override
func
goback
()
{
{
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
let
alert
=
UIAlertController
(
title
:
"确认退出编辑?"
,
message
:
nil
,
preferredStyle
:
.
alert
)
let
leftAction
=
UIAlertAction
(
title
:
"直接退出"
,
style
:
.
destructive
)
{
(
action
)
in
self
.
navigationController
?
.
popViewController
(
animated
:
true
)
}
alert
.
addAction
(
leftAction
)
let
rightAction
=
UIAlertAction
(
title
:
"保存并退出"
,
style
:
.
default
)
{
(
action
)
in
self
.
didSelectedNavRightButton
()
}
alert
.
addAction
(
rightAction
)
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
}
}
// MARK: 点击navigationBar右侧按钮
// MARK: 点击navigationBar右侧按钮
...
@@ -394,6 +423,20 @@ class SHInputController: SHBaseViewController
...
@@ -394,6 +423,20 @@ class SHInputController: SHBaseViewController
extension
SHInputController
:
UITextViewDelegate
,
SHInputTextViewDelegate
extension
SHInputController
:
UITextViewDelegate
,
SHInputTextViewDelegate
{
{
// MARK: - UITextView代理
// MARK: - UITextView代理
// MARK: 滑动
func
scrollViewDidScroll
(
_
scrollView
:
UIScrollView
)
{
let
vel
=
scrollView
.
panGestureRecognizer
.
velocity
(
in
:
scrollView
)
if
vel
.
y
>
20
{
if
self
.
shInputView
.
textView
.
canResignFirstResponder
{
self
.
shInputView
.
textView
.
resignFirstResponder
()
}
}
}
// MARK: 文字发生了变化
// MARK: 文字发生了变化
func
textViewDidChange
(
_
textView
:
UITextView
)
func
textViewDidChange
(
_
textView
:
UITextView
)
{
{
...
@@ -768,8 +811,69 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
...
@@ -768,8 +811,69 @@ extension SHInputController: UIImagePickerControllerDelegate, UINavigationContro
// MARK: - 录音
// MARK: - 录音
extension
SHInputController
extension
SHInputController
{
{
// MARK: 点击添加录音按钮
// MARK: 点击添加录音按钮
, 先判断麦克风权限
@objc
func
didSelectedAddAudioButton
(
sender
:
SHInputAudioButton
)
@objc
func
didSelectedAddAudioButton
(
sender
:
SHInputAudioButton
)
{
let
status
:
AVAuthorizationStatus
=
AVCaptureDevice
.
authorizationStatus
(
for
:
.
audio
)
switch
status
{
// MARK: 此应用程序未被授权, 可能是家长控制权限。
case
AVAuthorizationStatus
.
restricted
:
let
alert
=
UIAlertController
(
title
:
nil
,
message
:
"此应用程序未被授权, 可能是家长控制权限。"
,
preferredStyle
:
UIAlertController
.
Style
.
alert
)
let
sureAction
=
UIAlertAction
(
title
:
"确定"
,
style
:
UIAlertAction
.
Style
.
default
,
handler
:
nil
)
alert
.
addAction
(
sureAction
)
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
break
// MARK: 用户拒绝当前应用访问麦克风
case
AVAuthorizationStatus
.
denied
:
let
alert
=
UIAlertController
(
title
:
"此功能需要麦克风授权"
,
message
:
"请您在设置系统中打开授权开关"
,
preferredStyle
:
UIAlertController
.
Style
.
alert
)
let
cancelAction
=
UIAlertAction
(
title
:
"取消"
,
style
:
UIAlertAction
.
Style
.
cancel
,
handler
:
nil
)
alert
.
addAction
(
cancelAction
)
let
settingAction
=
UIAlertAction
(
title
:
"前往设置"
,
style
:
UIAlertAction
.
Style
.
default
)
{
(
action
)
in
UIApplication
.
shared
.
open
(
URL
(
string
:
UIApplication
.
openSettingsURLString
)
!
,
options
:
[:],
completionHandler
:
nil
)
}
alert
.
addAction
(
settingAction
)
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
break
// MARK: 用户允许当前应用访问麦克风
case
AVAuthorizationStatus
.
authorized
:
if
UIImagePickerController
.
isSourceTypeAvailable
(
UIImagePickerController
.
SourceType
.
camera
)
{
self
.
beginAddAudio
()
}
break
// MARK: 用户还没有做出选择
case
AVAuthorizationStatus
.
notDetermined
:
AVCaptureDevice
.
requestAccess
(
for
:
.
audio
)
{
(
flag
)
in
if
flag
{
DispatchQueue
.
main
.
async
{
self
.
beginAddAudio
()
}
}
}
break
default
:
break
}
}
// MARK: 开始录音
func
beginAddAudio
()
{
{
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
audioTimeBgView
.
isHidden
=
false
self
.
shInputView
.
bottomView
.
audioTimeBgView
.
isHidden
=
false
...
@@ -836,44 +940,110 @@ extension SHInputController
...
@@ -836,44 +940,110 @@ extension SHInputController
// MARK: 点击结束录制按钮
// MARK: 点击结束录制按钮
@objc
func
didSelectedStopAudioButton
(
sender
:
SHInputAudioButton
)
@objc
func
didSelectedStopAudioButton
(
sender
:
SHInputAudioButton
)
{
{
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
recorder_mp3
.
pause
()
self
.
shInputView
.
bottomView
.
audioTimeBgView
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
pauseAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
goOnAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
stopAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
playView
.
isHidden
=
false
self
.
shInputView
.
bottomView
.
setUpSubviewsLocation
()
recorder_mp3
.
stop
()
self
.
timer
.
cancel
()
self
.
shInputView
.
bottomView
.
timer
.
cancel
()
self
.
initPlayer
()
self
.
timer
.
suspend
()
self
.
shInputView
.
bottomView
.
playView
.
timeLabel
.
text
=
self
.
viewModel
.
getTimeStringWithSeconds
(
seconds
:
NSInteger
(
self
.
audioPlayer
?
.
duration
??
0
)
)
self
.
shInputView
.
bottomView
.
audioTimePointViewAnimation
(
animation
:
false
)
self
.
shInputView
.
setNeedsUpdateConstraints
(
)
let
alert
=
UIAlertController
(
title
:
"提示"
,
message
:
"结束录音后,不能再进行续录。"
,
preferredStyle
:
.
alert
)
UIView
.
animate
(
withDuration
:
0.3
)
{
let
leftAction
=
UIAlertAction
(
title
:
"结束录音"
,
style
:
.
destructive
)
{
(
action
)
in
self
.
shInputView
.
bottomView
.
addAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
audioTimeBgView
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
pauseAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
goOnAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
stopAudioButton
.
isHidden
=
true
self
.
shInputView
.
bottomView
.
playView
.
isHidden
=
false
self
.
shInputView
.
bottomView
.
setUpSubviewsLocation
()
self
.
recorder_mp3
.
stop
()
self
.
shInputView
.
bottomView
.
mas_updateConstraints
{
(
make
)
in
self
.
timer
.
cancel
()
self
.
shInputView
.
bottomView
.
timer
.
cancel
()
self
.
initPlayer
()
self
.
shInputView
.
bottomView
.
playView
.
timeLabel
.
text
=
self
.
viewModel
.
getTimeStringWithSeconds
(
seconds
:
NSInteger
(
self
.
audioPlayer
?
.
duration
??
0
))
self
.
shInputView
.
setNeedsUpdateConstraints
()
UIView
.
animate
(
withDuration
:
0.3
)
{
self
.
shInputView
.
bottomView
.
mas_updateConstraints
{
(
make
)
in
make
?
.
height
.
mas_equalTo
()(
100
+
SafeAreaBottomHeight
())
}
make
?
.
height
.
mas_equalTo
()(
100
+
SafeAreaBottomHeight
())
self
.
shInputView
.
bottomView
.
progressView
.
alpha
=
1
;
self
.
shInputView
.
bottomView
.
superview
!.
layoutIfNeeded
()
}
}
self
.
shInputView
.
bottomView
.
progressView
.
alpha
=
1
;
}
alert
.
addAction
(
leftAction
)
self
.
shInputView
.
bottomView
.
superview
!.
layoutIfNeeded
()
let
rightAction
=
UIAlertAction
(
title
:
"暂不结束"
,
style
:
.
default
)
{
(
action
)
in
}
}
alert
.
addAction
(
rightAction
)
self
.
present
(
alert
,
animated
:
true
,
completion
:
nil
)
}
}
}
}
// MARK: - 播放
// MARK: - 播放
extension
SHInputController
:
AVAudioPlayerDelegate
{
extension
SHInputController
:
AVAudioPlayerDelegate
{
// MARK: 初始化播放计时器
func
initPlayTimer
()
{
self
.
playTimer
.
schedule
(
deadline
:
.
now
(),
repeating
:
0.03
)
self
.
playTimer
.
setEventHandler
{
DispatchQueue
.
main
.
sync
{
print
(
"计时中"
+
String
(
self
.
audioPlayer
?
.
currentTime
??
0
))
if
Float
(
self
.
audioPlayer
?
.
duration
??
0
)
-
Float
(
self
.
audioPlayer
?
.
currentTime
??
0
)
<=
0.1
{
self
.
playFinished
=
true
}
if
!
self
.
playFinished
{
self
.
shInputView
.
bottomView
.
progressView
.
slider
.
value
=
min
(
Float
(
self
.
audioPlayer
?
.
currentTime
??
0
)
/
Float
(
self
.
audioPlayer
?
.
duration
??
0
),
1
)
self
.
shInputView
.
bottomView
.
progressView
.
timeLabel
.
text
=
self
.
viewModel
.
getTimeStringWithSeconds
(
seconds
:
NSInteger
(
self
.
audioPlayer
?
.
currentTime
??
0
))
}
}
}
}
// MARK: 播放计时器开始计时
func
startPlayTimer
()
{
if
!
playTimerCounting
{
self
.
playTimer
.
resume
()
playTimerCounting
=
true
}
}
// MARK: 播放计时器暂停计时
func
pausePlayTimer
()
{
if
playTimerCounting
{
self
.
playTimer
.
suspend
()
playTimerCounting
=
false
}
}
// MARK: 初始化播放器
// MARK: 初始化播放器
func
initPlayer
()
func
initPlayer
()
{
{
...
@@ -894,6 +1064,8 @@ extension SHInputController: AVAudioPlayerDelegate {
...
@@ -894,6 +1064,8 @@ extension SHInputController: AVAudioPlayerDelegate {
self
.
audioPlayer
?
.
enableRate
=
true
// 允许变速播放
self
.
audioPlayer
?
.
enableRate
=
true
// 允许变速播放
self
.
audioPlayer
?
.
delegate
=
self
self
.
audioPlayer
?
.
delegate
=
self
self
.
dataModel
.
during
=
NSInteger
(
self
.
audioPlayer
?
.
duration
??
0
)
// 后台播放
// 后台播放
let
session
=
AVAudioSession
.
sharedInstance
()
let
session
=
AVAudioSession
.
sharedInstance
()
try
?
session
.
setCategory
(
AVAudioSession
.
Category
.
playAndRecord
,
options
:
.
defaultToSpeaker
)
try
?
session
.
setCategory
(
AVAudioSession
.
Category
.
playAndRecord
,
options
:
.
defaultToSpeaker
)
...
@@ -907,17 +1079,24 @@ extension SHInputController: AVAudioPlayerDelegate {
...
@@ -907,17 +1079,24 @@ extension SHInputController: AVAudioPlayerDelegate {
// 暂停
// 暂停
self
.
audioPlayer
?
.
pause
()
self
.
audioPlayer
?
.
pause
()
self
.
p
layTimer
.
suspend
()
self
.
p
ausePlayTimer
()
sender
.
setImage
(
UIImage
(
named
:
"input_audio_play"
),
for
:
.
normal
)
sender
.
setImage
(
UIImage
(
named
:
"input_audio_play"
),
for
:
.
normal
)
}
}
else
else
{
{
// 播放
// 播放
self
.
playTimer
.
resume
()
if
self
.
playFinished
{
self
.
audioPlayer
?
.
currentTime
=
0
;
self
.
playFinished
=
false
}
self
.
audioPlayer
?
.
play
()
self
.
audioPlayer
?
.
play
()
self
.
startPlayTimer
()
sender
.
setImage
(
UIImage
(
named
:
"input_audio_pause"
),
for
:
.
normal
)
sender
.
setImage
(
UIImage
(
named
:
"input_audio_pause"
),
for
:
.
normal
)
}
}
}
}
...
@@ -925,33 +1104,38 @@ extension SHInputController: AVAudioPlayerDelegate {
...
@@ -925,33 +1104,38 @@ extension SHInputController: AVAudioPlayerDelegate {
// MARK: 后退10s
// MARK: 后退10s
@objc
func
didSelectedBeforeButton
(
sender
:
UIButton
)
@objc
func
didSelectedBeforeButton
(
sender
:
UIButton
)
{
{
// self.playTimer.suspend()
self
.
playFinished
=
false
//
// self.audioPlayer.pause()
self
.
audioPlayer
?
.
pause
()
//
self
.
pausePlayTimer
()
self
.
audioPlayer
?
.
currentTime
=
max
((
self
.
audioPlayer
?
.
currentTime
??
0
)
-
10
,
0
)
self
.
audioPlayer
?
.
currentTime
=
max
((
self
.
audioPlayer
?
.
currentTime
??
0
)
-
10
,
0
)
// self.playTimer.resume
()
self
.
audioPlayer
?
.
play
()
//
// self.audioPlayer.play
()
self
.
startPlayTimer
()
//
// self.shInputView.bottomView.playView.playButton.setImage(UIImage(named: "input_audio_play
"), for: .normal)
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_pause
"
),
for
:
.
normal
)
}
}
// MARK: 前进10s
// MARK: 前进10s
@objc
func
didSelectedLaterButton
(
sender
:
UIButton
)
@objc
func
didSelectedLaterButton
(
sender
:
UIButton
)
{
{
// self.playTimer.suspend()
self
.
playFinished
=
false
//
// self.audioPlayer.pause()
//
self
.
audioPlayer
?
.
currentTime
=
min
((
self
.
audioPlayer
?
.
currentTime
??
0
)
+
10
,
TimeInterval
(
self
.
audioPlayer
?
.
duration
??
0
))
// self.playTimer.resume()
self
.
audioPlayer
?
.
pause
()
//
// self.audioPlayer.play()
self
.
pausePlayTimer
()
//
// self.shInputView.bottomView.playView.playButton.setImage(UIImage(named: "input_audio_play"), for: .normal)
// 最大时间直接等于self.audioPlayer?.duration音频会从第1s重新开始播放
self
.
audioPlayer
?
.
currentTime
=
min
((
self
.
audioPlayer
?
.
currentTime
??
0
)
+
10
,
TimeInterval
(
self
.
audioPlayer
?
.
duration
??
0
)
-
0.03
)
self
.
audioPlayer
?
.
play
()
self
.
startPlayTimer
()
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_pause"
),
for
:
.
normal
)
}
}
// MARK: 开始拖动进度条
// MARK: 开始拖动进度条
...
@@ -960,7 +1144,7 @@ extension SHInputController: AVAudioPlayerDelegate {
...
@@ -960,7 +1144,7 @@ extension SHInputController: AVAudioPlayerDelegate {
// 暂停
// 暂停
self
.
audioPlayer
?
.
pause
()
self
.
audioPlayer
?
.
pause
()
self
.
p
layTimer
.
suspend
()
self
.
p
ausePlayTimer
()
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_play"
),
for
:
.
normal
)
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_play"
),
for
:
.
normal
)
}
}
...
@@ -976,33 +1160,36 @@ extension SHInputController: AVAudioPlayerDelegate {
...
@@ -976,33 +1160,36 @@ extension SHInputController: AVAudioPlayerDelegate {
// MARK: 结束拖动进度条
// MARK: 结束拖动进度条
@objc
func
sliderTouchEnd
(
sender
:
UISlider
)
@objc
func
sliderTouchEnd
(
sender
:
UISlider
)
{
{
// 播放
self
.
playFinished
=
false
self
.
audioPlayer
?
.
currentTime
=
min
(
TimeInterval
(
Double
(
sender
.
value
)
*
Double
(
self
.
audioPlayer
?
.
duration
??
0
)),
Double
(
self
.
audioPlayer
?
.
duration
??
0
))
self
.
playTimer
.
resume
()
// 播放
// 最大时间直接等于self.audioPlayer?.duration音频会从第1s重新开始播放
self
.
audioPlayer
?
.
currentTime
=
min
(
TimeInterval
(
Double
(
sender
.
value
)
*
Double
(
self
.
audioPlayer
?
.
duration
??
0
)),
Double
(
self
.
audioPlayer
?
.
duration
??
0
)
-
0.03
)
self
.
audioPlayer
?
.
play
()
self
.
audioPlayer
?
.
play
()
self
.
startPlayTimer
()
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_pause"
),
for
:
.
normal
)
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_pause"
),
for
:
.
normal
)
}
}
// MARK: 切换倍速
// MARK: 切换倍速
@objc
func
didSelectedSpeedButton
(
sender
:
UIButton
)
@objc
func
didSelectedSpeedButton
(
sender
:
UIButton
)
{
{
if
sender
.
titleLabel
!.
text
!.
isEqualTo
(
"x1
.5
"
)
if
sender
.
titleLabel
!.
text
!.
isEqualTo
(
"x1"
)
{
{
self
.
audioPlayer
?
.
rate
=
1.5
self
.
audioPlayer
?
.
rate
=
1.5
sender
.
setTitle
(
"x
2
"
,
for
:
.
normal
)
sender
.
setTitle
(
"x
1.5
"
,
for
:
.
normal
)
}
}
else
if
sender
.
titleLabel
!.
text
!.
isEqualTo
(
"x
2
"
)
else
if
sender
.
titleLabel
!.
text
!.
isEqualTo
(
"x
1.5
"
)
{
{
self
.
audioPlayer
?
.
rate
=
2
self
.
audioPlayer
?
.
rate
=
2
sender
.
setTitle
(
"x
1
"
,
for
:
.
normal
)
sender
.
setTitle
(
"x
2
"
,
for
:
.
normal
)
}
}
else
if
sender
.
titleLabel
!.
text
!.
isEqualTo
(
"x
1
"
)
else
if
sender
.
titleLabel
!.
text
!.
isEqualTo
(
"x
2
"
)
{
{
self
.
audioPlayer
?
.
rate
=
1
self
.
audioPlayer
?
.
rate
=
1
sender
.
setTitle
(
"x1
.5
"
,
for
:
.
normal
)
sender
.
setTitle
(
"x1"
,
for
:
.
normal
)
}
}
}
}
...
@@ -1010,10 +1197,12 @@ extension SHInputController: AVAudioPlayerDelegate {
...
@@ -1010,10 +1197,12 @@ extension SHInputController: AVAudioPlayerDelegate {
// MARK: 播放完成
// MARK: 播放完成
func
audioPlayerDidFinishPlaying
(
_
player
:
AVAudioPlayer
,
successfully
flag
:
Bool
)
{
func
audioPlayerDidFinishPlaying
(
_
player
:
AVAudioPlayer
,
successfully
flag
:
Bool
)
{
print
(
"播放完成"
)
player
.
currentTime
=
player
.
duration
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_play"
),
for
:
.
normal
)
self
.
shInputView
.
bottomView
.
playView
.
playButton
.
setImage
(
UIImage
(
named
:
"input_audio_play"
),
for
:
.
normal
)
self
.
shInputView
.
bottomView
.
progressView
.
slider
.
value
=
1
;
self
.
shInputView
.
bottomView
.
progressView
.
slider
.
value
=
1
;
self
.
shInputView
.
bottomView
.
progressView
.
timeLabel
.
text
=
self
.
viewModel
.
getTimeStringWithSeconds
(
seconds
:
NSInteger
(
self
.
audioPlayer
?
.
duration
??
0
))
self
.
shInputView
.
bottomView
.
progressView
.
timeLabel
.
text
=
self
.
viewModel
.
getTimeStringWithSeconds
(
seconds
:
NSInteger
(
self
.
audioPlayer
?
.
duration
??
0
))
self
.
p
layTimer
.
suspend
()
self
.
p
ausePlayTimer
()
}
}
}
}
ShorthandMaster/Input/View/SHInputAudioPlayView.swift
View file @
1daaf8c8
...
@@ -64,7 +64,7 @@ class SHInputAudioPlayView: UIView {
...
@@ -64,7 +64,7 @@ class SHInputAudioPlayView: UIView {
// 播放速度按钮
// 播放速度按钮
self
.
speedButton
=
UIButton
(
type
:
.
system
)
self
.
speedButton
=
UIButton
(
type
:
.
system
)
self
.
speedButton
.
setTitle
(
"x1
.5
"
,
for
:
.
normal
)
self
.
speedButton
.
setTitle
(
"x1"
,
for
:
.
normal
)
self
.
speedButton
.
setTitleColor
(
UIColor
(
r
:
65
,
g
:
131
,
b
:
244
),
for
:
.
normal
)
self
.
speedButton
.
setTitleColor
(
UIColor
(
r
:
65
,
g
:
131
,
b
:
244
),
for
:
.
normal
)
self
.
speedButton
.
titleLabel
?
.
font
=
UIFont
(
name
:
SHPingFangMedium
,
size
:
14
)
self
.
speedButton
.
titleLabel
?
.
font
=
UIFont
(
name
:
SHPingFangMedium
,
size
:
14
)
self
.
addSubview
(
self
.
speedButton
)
self
.
addSubview
(
self
.
speedButton
)
...
...
ShorthandMaster/Input/View/SHInputBottomView.swift
View file @
1daaf8c8
...
@@ -198,7 +198,7 @@ class SHInputBottomView: UIView {
...
@@ -198,7 +198,7 @@ class SHInputBottomView: UIView {
// 箭头图片
// 箭头图片
self
.
directionImageView
=
UIImageView
()
self
.
directionImageView
=
UIImageView
()
self
.
directionImageView
.
image
=
UIImage
(
named
:
"input_
down
"
)
self
.
directionImageView
.
image
=
UIImage
(
named
:
"input_
up
"
)
self
.
addSubview
(
self
.
directionImageView
)
self
.
addSubview
(
self
.
directionImageView
)
self
.
directionImageView
.
isHidden
=
self
.
isEdited
self
.
directionImageView
.
isHidden
=
self
.
isEdited
...
...
ShorthandMaster/Input/View/SHInputView.swift
View file @
1daaf8c8
...
@@ -103,7 +103,7 @@ class SHInputView: UIView {
...
@@ -103,7 +103,7 @@ class SHInputView: UIView {
// MARK: 监听键盘出现
// MARK: 监听键盘出现
@objc
func
keyboardWillShow
(
note
:
Notification
)
@objc
func
keyboardWillShow
(
note
:
Notification
)
{
{
self
.
bottomView
.
directionImageView
.
image
=
UIImage
(
named
:
"input_
up
"
)
self
.
bottomView
.
directionImageView
.
image
=
UIImage
(
named
:
"input_
down
"
)
let
info
:
Dictionary
=
note
.
userInfo
!
as
Dictionary
let
info
:
Dictionary
=
note
.
userInfo
!
as
Dictionary
let
value
=
info
[
UIResponder
.
keyboardFrameEndUserInfoKey
]
let
value
=
info
[
UIResponder
.
keyboardFrameEndUserInfoKey
]
...
@@ -132,7 +132,7 @@ class SHInputView: UIView {
...
@@ -132,7 +132,7 @@ class SHInputView: UIView {
// MARK: 监听键盘消失
// MARK: 监听键盘消失
@objc
func
keyboardWillHide
(
note
:
Notification
)
@objc
func
keyboardWillHide
(
note
:
Notification
)
{
{
self
.
bottomView
.
directionImageView
.
image
=
UIImage
(
named
:
"input_
down
"
)
self
.
bottomView
.
directionImageView
.
image
=
UIImage
(
named
:
"input_
up
"
)
weak
var
weakSelf
=
self
weak
var
weakSelf
=
self
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment