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
210ad2e5
Commit
210ad2e5
authored
Sep 29, 2020
by
zhangzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
处理音频问题
parent
7ceb0c54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
19 deletions
+30
-19
project.pbxproj
ShorthandMaster.xcodeproj/project.pbxproj
+6
-6
SHInputController.swift
ShorthandMaster/Input/Controller/SHInputController.swift
+9
-9
SHInputBottomView.swift
ShorthandMaster/Input/View/SHInputBottomView.swift
+8
-1
SHInputView.swift
ShorthandMaster/Input/View/SHInputView.swift
+7
-3
No files found.
ShorthandMaster.xcodeproj/project.pbxproj
View file @
210ad2e5
...
...
@@ -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
;
...
...
ShorthandMaster/Input/Controller/SHInputController.swift
View file @
210ad2e5
...
...
@@ -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()
//
...
...
ShorthandMaster/Input/View/SHInputBottomView.swift
View file @
210ad2e5
...
...
@@ -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
)
...
...
ShorthandMaster/Input/View/SHInputView.swift
View file @
210ad2e5
...
...
@@ -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
());
}
}
...
...
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