Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit c62bd710
由
cgx
编写于
2022-10-24 17:16:35 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完成睡前故事播放页
1 个父辈
9db30de9
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
292 行增加
和
8 行删除
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/PlayerManger.h
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/PlayerManger.m
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/SleepStoryCell.m
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/SleepStoryView.m
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/StoryPlayController.m
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/StoryPlayView.h
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/StoryPlayView.m
DreamSleep/DreamSleep.xcodeproj/project.pbxproj
查看文件 @
c62bd71
...
@@ -133,6 +133,7 @@
...
@@ -133,6 +133,7 @@
D07257F0286BE5510080F458 /* GoodSleepHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257EF286BE5510080F458 /* GoodSleepHeadView.m */; };
D07257F0286BE5510080F458 /* GoodSleepHeadView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257EF286BE5510080F458 /* GoodSleepHeadView.m */; };
D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F2286BF99F0080F458 /* DailyTaskView.m */; };
D07257F3286BF99F0080F458 /* DailyTaskView.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F2286BF99F0080F458 /* DailyTaskView.m */; };
D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F5286C2F110080F458 /* SignCollectionViewCell.m */; };
D07257F6286C2F110080F458 /* SignCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D07257F5286C2F110080F458 /* SignCollectionViewCell.m */; };
D077AF6629066D1100F41394 /* PlayerManger.m in Sources */ = {isa = PBXBuildFile; fileRef = D077AF6529066D1100F41394 /* PlayerManger.m */; };
D07827FC28FE424700C8D612 /* PraiseListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D07827FB28FE424700C8D612 /* PraiseListViewModel.m */; };
D07827FC28FE424700C8D612 /* PraiseListViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D07827FB28FE424700C8D612 /* PraiseListViewModel.m */; };
D078281628FE939400C8D612 /* OfficialNotiViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281528FE939400C8D612 /* OfficialNotiViewModel.m */; };
D078281628FE939400C8D612 /* OfficialNotiViewModel.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281528FE939400C8D612 /* OfficialNotiViewModel.m */; };
D078281C28FE94CA00C8D612 /* OfficialNotiCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281B28FE94CA00C8D612 /* OfficialNotiCell.m */; };
D078281C28FE94CA00C8D612 /* OfficialNotiCell.m in Sources */ = {isa = PBXBuildFile; fileRef = D078281B28FE94CA00C8D612 /* OfficialNotiCell.m */; };
...
@@ -572,6 +573,8 @@
...
@@ -572,6 +573,8 @@
D07257F2286BF99F0080F458 /* DailyTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyTaskView.m; sourceTree = "<group>"; };
D07257F2286BF99F0080F458 /* DailyTaskView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DailyTaskView.m; sourceTree = "<group>"; };
D07257F4286C2F110080F458 /* SignCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignCollectionViewCell.h; sourceTree = "<group>"; };
D07257F4286C2F110080F458 /* SignCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SignCollectionViewCell.h; sourceTree = "<group>"; };
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignCollectionViewCell.m; sourceTree = "<group>"; };
D07257F5286C2F110080F458 /* SignCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SignCollectionViewCell.m; sourceTree = "<group>"; };
D077AF6429066D1100F41394 /* PlayerManger.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlayerManger.h; sourceTree = "<group>"; };
D077AF6529066D1100F41394 /* PlayerManger.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PlayerManger.m; sourceTree = "<group>"; };
D07827FA28FE424700C8D612 /* PraiseListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PraiseListViewModel.h; sourceTree = "<group>"; };
D07827FA28FE424700C8D612 /* PraiseListViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PraiseListViewModel.h; sourceTree = "<group>"; };
D07827FB28FE424700C8D612 /* PraiseListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PraiseListViewModel.m; sourceTree = "<group>"; };
D07827FB28FE424700C8D612 /* PraiseListViewModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PraiseListViewModel.m; sourceTree = "<group>"; };
D078281428FE939400C8D612 /* OfficialNotiViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OfficialNotiViewModel.h; sourceTree = "<group>"; };
D078281428FE939400C8D612 /* OfficialNotiViewModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OfficialNotiViewModel.h; sourceTree = "<group>"; };
...
@@ -1615,6 +1618,8 @@
...
@@ -1615,6 +1618,8 @@
D06381A328D012420074515B /* SleepStoryController.m */,
D06381A328D012420074515B /* SleepStoryController.m */,
D0CCB09B2902A2E800B81141 /* StoryPlayController.h */,
D0CCB09B2902A2E800B81141 /* StoryPlayController.h */,
D0CCB09C2902A2E800B81141 /* StoryPlayController.m */,
D0CCB09C2902A2E800B81141 /* StoryPlayController.m */,
D077AF6429066D1100F41394 /* PlayerManger.h */,
D077AF6529066D1100F41394 /* PlayerManger.m */,
);
);
path = SleepStory;
path = SleepStory;
sourceTree = "<group>";
sourceTree = "<group>";
...
@@ -2941,6 +2946,7 @@
...
@@ -2941,6 +2946,7 @@
D091E665283F0C4800D3279E /* ScoreTaskRequestModel.m in Sources */,
D091E665283F0C4800D3279E /* ScoreTaskRequestModel.m in Sources */,
D01BD42B282C03FC00BA86B3 /* NoiseAudioModel.m in Sources */,
D01BD42B282C03FC00BA86B3 /* NoiseAudioModel.m in Sources */,
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */,
D01814EE28002DC700583D4E /* HeaderDataModel.m in Sources */,
D077AF6629066D1100F41394 /* PlayerManger.m in Sources */,
D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */,
D0506B1B2805500E00229278 /* SafeHelperCollectionViewCell.m in Sources */,
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */,
D0DB33A828224D5100E15914 /* PromotionModel.m in Sources */,
D055BECB28252E4000BC11A4 /* SubAudioModel.m in Sources */,
D055BECB28252E4000BC11A4 /* SubAudioModel.m in Sources */,
...
...
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/PlayerManger.h
0 → 100644
查看文件 @
c62bd71
//
// PlayerManger.h
// DreamSleep
//
// Created by peter on 2022/10/24.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/// 播放器管理者
@interface
PlayerManger
:
NSObject
/// 播放按钮状态变化(YES:正在播放,NO:其他)
@property
(
copy
)
void
(
^
playStateChange
)(
BOOL
playState
);
/// 播放进度变化
@property
(
copy
)
void
(
^
progressChange
)(
float
progress
,
NSString
*
curTime
,
NSString
*
totalTime
);
/// init
/// @param item 播放数据model
-
(
instancetype
)
initWithItem
:(
id
)
item
;
/// 启动播放
-
(
void
)
startPlay
;
/// 滑动进度条播放跳转
/// @param position 位置
-
(
void
)
seekToPosition
:(
float
)
position
;
/// 停止播放
-
(
void
)
stop
;
/// 播放暂停控制
-
(
void
)
playOrPause
;
/// 更新息屏播放控件
-
(
void
)
updatePlayingCenterInfo
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/PlayerManger.m
0 → 100644
查看文件 @
c62bd71
此文件的差异被折叠,
点击展开。
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/SleepStoryCell.m
查看文件 @
c62bd71
...
@@ -112,8 +112,9 @@
...
@@ -112,8 +112,9 @@
-
(
UIButton
*
)
playBtn
{
-
(
UIButton
*
)
playBtn
{
if
(
!
_playBtn
)
{
if
(
!
_playBtn
)
{
_playBtn
=
[
UIButton
btnWithTitle
:
@"播放"
font
:
BoldFont
(
16
)];
_playBtn
=
[
UIButton
btnWithTitle
:
@"播放"
font
:
BoldFont
(
16
)];
[
_playBtn
dk_setTitleColorPicker
:
DKColorPickerWithKey
(
Sub_Navi_TITLE
)
forState
:
UIControlStateNormal
];
_playBtn
.
size
=
(
CGSizeMake
(
64
,
34
));
_playBtn
.
size
=
(
CGSizeMake
(
64
,
34
));
_playBtn
.
userInteractionEnabled
=
NO
;
[
_playBtn
dk_setTitleColorPicker
:
DKColorPickerWithKey
(
Sub_Navi_TITLE
)
forState
:
UIControlStateNormal
];
[
_playBtn
cornerRadius
:
17
];
[
_playBtn
cornerRadius
:
17
];
CGPoint
start
=
CGPointMake
(
0
,
0
.
5
);
CGPoint
start
=
CGPointMake
(
0
,
0
.
5
);
CGPoint
end
=
CGPointMake
(
0
.
5
,
0
.
5
);
CGPoint
end
=
CGPointMake
(
0
.
5
,
0
.
5
);
...
...
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/SleepStoryView.m
查看文件 @
c62bd71
...
@@ -49,7 +49,7 @@
...
@@ -49,7 +49,7 @@
CellConfigureBlock
cellBlock
=
^
(
SleepStoryCell
*
cell
,
SubAudioModel
*
model
,
NSIndexPath
*
indexPath
)
{
CellConfigureBlock
cellBlock
=
^
(
SleepStoryCell
*
cell
,
SubAudioModel
*
model
,
NSIndexPath
*
indexPath
)
{
cell
.
storyModel
=
model
;
cell
.
storyModel
=
model
;
};
};
_dataSource
=
[[
DSDataSource
alloc
]
initWithIdentifier
:
NSStringFromClass
([
SleepStoryCell
class
])
datas
:@[]
isSection
:
YES
configureBlock
:
cellBlock
];
_dataSource
=
[[
DSDataSource
alloc
]
initWithIdentifier
:
NSStringFromClass
([
SleepStoryCell
class
])
datas
:@[]
isSection
:
NO
configureBlock
:
cellBlock
];
UITableView
*
storyListView
=
[[
UITableView
alloc
]
initWithFrame
:
CGRectZero
style
:
UITableViewStylePlain
];
UITableView
*
storyListView
=
[[
UITableView
alloc
]
initWithFrame
:
CGRectZero
style
:
UITableViewStylePlain
];
storyListView
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
storyListView
.
separatorStyle
=
UITableViewCellSeparatorStyleNone
;
...
...
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/StoryPlayController.m
查看文件 @
c62bd71
...
@@ -7,9 +7,13 @@
...
@@ -7,9 +7,13 @@
#import "StoryPlayController.h"
#import "StoryPlayController.h"
#import "StoryPlayView.h"
#import "StoryPlayView.h"
#import "PlayerManger.h"
@interface
StoryPlayController
()
<
StoryPlayViewDelegate
>
@interface
StoryPlayController
()
<
StoryPlayViewDelegate
>
@property
(
nonatomic
,
strong
)
StoryPlayView
*
storyPlayView
;
@property
(
nonatomic
,
strong
)
StoryPlayView
*
storyPlayView
;
@property
(
nonatomic
,
strong
)
PlayerManger
*
playerManger
;
/// 是否正在拖动滑块
@property
(
nonatomic
,
assign
)
BOOL
isDraging
;
@end
@end
@implementation
StoryPlayController
@implementation
StoryPlayController
...
@@ -21,17 +25,51 @@
...
@@ -21,17 +25,51 @@
-
(
void
)
viewDidLoad
{
-
(
void
)
viewDidLoad
{
[
super
viewDidLoad
];
[
super
viewDidLoad
];
[
self
.
storyPlayView
updatePlayerView
:
self
.
audioModel
];
[
self
launchPlayer
];
}
-
(
void
)
launchPlayer
{
WS
(
weakSelf
);
[
self
.
playerManger
startPlay
];
self
.
playerManger
.
playStateChange
=
^
(
BOOL
playState
)
{
[
weakSelf
.
storyPlayView
updatePlayingState
:
playState
];
};
self
.
playerManger
.
progressChange
=
^
(
float
progress
,
NSString
*
_Nonnull
curTime
,
NSString
*
_Nonnull
totalTime
)
{
if
(
weakSelf
.
isDraging
==
YES
)
return
;
[
weakSelf
.
storyPlayView
updateProgress
:
progress
currentTime
:
curTime
totalTime
:
totalTime
];
[
weakSelf
.
playerManger
updatePlayingCenterInfo
];
};
}
}
#pragma mark - StoryPlayViewDelegate
#pragma mark - StoryPlayViewDelegate
-
(
void
)
didSliderTouchBegan
:
(
float
)
value
{
self
.
isDraging
=
YES
;
}
-
(
void
)
didSliderTouchEnded
:
(
float
)
value
{
self
.
isDraging
=
NO
;
// 避免用户拖动进度条出现极值导致音频文件加载失败问题
if
(
value
==
0
)
value
=
0
.
001
;
if
(
value
==
1
)
value
=
0
.
999
;
[
self
.
playerManger
seekToPosition
:
value
];
}
-
(
void
)
didSliderValueChange
:
(
float
)
value
{
self
.
isDraging
=
YES
;
}
-
(
void
)
stopAudioAndDismiss
{
-
(
void
)
stopAudioAndDismiss
{
// if (self.streamState == kFsAudioStreamPlaying) {
[
self
.
playerManger
stop
];
// [self.audioStream pause];
// }
// [self.audioStream stop];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
[
self
dismissViewControllerAnimated
:
YES
completion
:
nil
];
}
}
-
(
void
)
playOrPauseControl
{
[
self
.
playerManger
playOrPause
];
}
#pragma mark - lazy
#pragma mark - lazy
-
(
StoryPlayView
*
)
storyPlayView
{
-
(
StoryPlayView
*
)
storyPlayView
{
if
(
!
_storyPlayView
)
{
if
(
!
_storyPlayView
)
{
...
@@ -40,6 +78,13 @@
...
@@ -40,6 +78,13 @@
return
_storyPlayView
;
return
_storyPlayView
;
}
}
-
(
PlayerManger
*
)
playerManger
{
if
(
!
_playerManger
)
{
_playerManger
=
[[
PlayerManger
alloc
]
initWithItem
:
self
.
audioModel
];
}
return
_playerManger
;
}
#pragma mark - 设置状态栏文字颜色
#pragma mark - 设置状态栏文字颜色
-
(
UIStatusBarStyle
)
preferredStatusBarStyle
{
-
(
UIStatusBarStyle
)
preferredStatusBarStyle
{
return
[
self
.
dk_manager
.
themeVersion
isEqualToString
:
DKThemeVersionNormal
]
?
UIStatusBarStyleDefault
:
UIStatusBarStyleLightContent
;
return
[
self
.
dk_manager
.
themeVersion
isEqualToString
:
DKThemeVersionNormal
]
?
UIStatusBarStyleDefault
:
UIStatusBarStyleLightContent
;
...
...
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/StoryPlayView.h
查看文件 @
c62bd71
...
@@ -6,18 +6,40 @@
...
@@ -6,18 +6,40 @@
//
//
#import <UIKit/UIKit.h>
#import <UIKit/UIKit.h>
#import "SubAudioModel.h"
NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_BEGIN
@protocol
StoryPlayViewDelegate
<
NSObject
>
@protocol
StoryPlayViewDelegate
<
NSObject
>
-
(
void
)
didSliderTouchBegan
:
(
float
)
value
;
-
(
void
)
didSliderTouchEnded
:(
float
)
value
;
-
(
void
)
didSliderValueChange
:(
float
)
value
;
/// 停止音频播放并且退出当前页
/// 停止音频播放并且退出当前页
-
(
void
)
stopAudioAndDismiss
;
-
(
void
)
stopAudioAndDismiss
;
/// 播放暂停控制
-
(
void
)
playOrPauseControl
;
@end
@end
@interface
StoryPlayView
:
UIView
@interface
StoryPlayView
:
UIView
@property
(
nonatomic
,
weak
)
id
<
StoryPlayViewDelegate
>
delegate
;
@property
(
nonatomic
,
weak
)
id
<
StoryPlayViewDelegate
>
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
StoryPlayViewDelegate
>
)
delegate
;
-
(
instancetype
)
initWithDelegate
:(
id
<
StoryPlayViewDelegate
>
)
delegate
;
/// 更新播放界面标题和图片
/// @param model model
-
(
void
)
updatePlayerView
:(
SubAudioModel
*
)
model
;
/// 更新播放按钮状态
/// @param isPlaying isPlaying
-
(
void
)
updatePlayingState
:(
BOOL
)
isPlaying
;
/// 更新进度条
/// @param progress progress
/// @param currentTime 当前时间
/// @param totalTime 总时间
-
(
void
)
updateProgress
:(
float
)
progress
currentTime
:(
NSString
*
)
currentTime
totalTime
:(
NSString
*
)
totalTime
;
@end
@end
NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/SleepStory/StoryPlayView.m
查看文件 @
c62bd71
...
@@ -6,9 +6,17 @@
...
@@ -6,9 +6,17 @@
//
//
#import "StoryPlayView.h"
#import "StoryPlayView.h"
#import "DSSlider.h"
@interface
StoryPlayView
()
@interface
StoryPlayView
()
<
UIGestureRecognizerDelegate
>
@property
(
nonatomic
,
strong
)
UIButton
*
dismissBtn
;
@property
(
nonatomic
,
strong
)
UIButton
*
dismissBtn
;
@property
(
nonatomic
,
strong
)
UIImageView
*
audioPicIV
;
@property
(
nonatomic
,
strong
)
UILabel
*
audioNameLab
;
@property
(
nonatomic
,
strong
)
DSSlider
*
progressV
;
@property
(
nonatomic
,
strong
)
UILabel
*
proLeftLb
;
@property
(
nonatomic
,
strong
)
UILabel
*
proRightLb
;
@property
(
nonatomic
,
strong
)
UIButton
*
playerBtn
;
@property
(
nonatomic
,
strong
)
UITapGestureRecognizer
*
tapGR
;
@end
@end
@implementation
StoryPlayView
@implementation
StoryPlayView
...
@@ -19,12 +27,68 @@
...
@@ -19,12 +27,68 @@
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
self
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
VCViewBG
);
[
self
addSubview
:
self
.
dismissBtn
];
[
self
addSubview
:
self
.
dismissBtn
];
[
self
addSubview
:
self
.
audioPicIV
];
[
self
addSubview
:
self
.
audioNameLab
];
[
self
addSubview
:
self
.
progressV
];
[
self
addSubview
:
self
.
proLeftLb
];
[
self
addSubview
:
self
.
proRightLb
];
[
self
addSubview
:
self
.
playerBtn
];
#warning 待开发...
[
self
.
audioPicIV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
);
make
.
width
.
height
.
equalTo
(
@144
);
make
.
top
.
equalTo
(
self
).
offset
(
198
);
}];
[
self
.
audioNameLab
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
top
.
equalTo
(
self
.
audioPicIV
.
mas_bottom
).
offset
(
18
);
make
.
centerX
.
equalTo
(
self
.
mas_centerX
);
make
.
left
.
equalTo
(
self
.
mas_left
);
make
.
right
.
equalTo
(
self
.
mas_right
);
}];
[
self
.
progressV
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
mas_left
).
offset
(
38
);
make
.
right
.
equalTo
(
self
.
mas_right
).
offset
(
-
37
);
make
.
height
.
equalTo
(
@15
);
make
.
top
.
equalTo
(
self
.
audioNameLab
.
mas_bottom
).
offset
(
160
);
}];
[
self
.
proLeftLb
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
.
progressV
.
mas_left
);
make
.
top
.
equalTo
(
self
.
progressV
.
mas_bottom
).
offset
(
6
);
make
.
height
.
equalTo
(
@17
);
make
.
width
.
equalTo
(
@100
);
}];
[
self
.
proRightLb
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
right
.
equalTo
(
self
.
progressV
.
mas_right
);
make
.
top
.
equalTo
(
self
.
progressV
.
mas_bottom
).
offset
(
6
);
make
.
height
.
equalTo
(
@17
);
make
.
width
.
equalTo
(
@100
);
}];
[
self
.
playerBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerX
.
equalTo
(
self
.
mas_centerX
);
make
.
width
.
equalTo
(
@50
);
make
.
height
.
equalTo
(
@50
);
make
.
top
.
equalTo
(
self
.
progressV
.
mas_bottom
).
offset
(
63
);
}];
}
}
return
self
;
return
self
;
}
}
#pragma mark - public
-
(
void
)
updatePlayerView
:(
SubAudioModel
*
)
model
{
[
self
.
audioPicIV
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
audio_pic
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
self
.
audioNameLab
.
text
=
model
.
audio_name
;
}
-
(
void
)
updatePlayingState
:(
BOOL
)
isPlaying
{
self
.
playerBtn
.
selected
=
isPlaying
;
}
-
(
void
)
updateProgress
:(
float
)
progress
currentTime
:(
NSString
*
)
currentTime
totalTime
:(
NSString
*
)
totalTime
{
self
.
progressV
.
value
=
progress
;
self
.
proLeftLb
.
text
=
currentTime
;
self
.
proRightLb
.
text
=
totalTime
;
}
#pragma mark - private
#pragma mark - private
-
(
void
)
dismiss
{
-
(
void
)
dismiss
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
stopAudioAndDismiss
)])
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
stopAudioAndDismiss
)])
{
...
@@ -32,6 +96,44 @@
...
@@ -32,6 +96,44 @@
}
}
}
}
-
(
void
)
playAction
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
playOrPauseControl
)])
{
[
self
.
delegate
playOrPauseControl
];
}
}
#pragma mark - 滑块事件
-
(
void
)
sliderValueChanged
:
(
UISlider
*
)
sender
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSliderValueChange
:)])
{
[
self
.
delegate
didSliderValueChange
:
sender
.
value
];
}
}
-
(
void
)
sliderTouchDown
:
(
UISlider
*
)
sender
{
self
.
tapGR
.
enabled
=
NO
;
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSliderTouchBegan
:)])
{
[
self
.
delegate
didSliderTouchBegan
:
sender
.
value
];
}
}
-
(
void
)
sliderTouchUpInSide
:
(
UISlider
*
)
sender
{
self
.
tapGR
.
enabled
=
YES
;
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSliderTouchEnded
:)])
{
[
self
.
delegate
didSliderTouchEnded
:
sender
.
value
];
}
}
#pragma mark - UIGestureRecognizerDelegate
-
(
void
)
actionTapGesture
:
(
UITapGestureRecognizer
*
)
sender
{
CGPoint
touchPoint
=
[
sender
locationInView
:
self
.
progressV
];
float
value
=
(
self
.
progressV
.
maximumValue
-
self
.
progressV
.
minimumValue
)
*
(
touchPoint
.
x
/
self
.
progressV
.
width
);
[
self
.
progressV
setValue
:
value
animated
:
YES
];
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSliderTouchEnded
:)])
{
[
self
.
delegate
didSliderTouchEnded
:
value
];
}
}
#pragma mark - lazy
#pragma mark - lazy
-
(
UIButton
*
)
dismissBtn
{
-
(
UIButton
*
)
dismissBtn
{
if
(
!
_dismissBtn
)
{
if
(
!
_dismissBtn
)
{
...
@@ -42,4 +144,70 @@
...
@@ -42,4 +144,70 @@
return
_dismissBtn
;
return
_dismissBtn
;
}
}
-
(
UIImageView
*
)
audioPicIV
{
if
(
!
_audioPicIV
)
{
_audioPicIV
=
[
UIImageView
new
];
[
_audioPicIV
cornerRadius
:
72
.
0
];
_audioPicIV
.
dk_alphaPicker
=
DKAlphaPickerWithAlphas
(
1
.
0
,
.
5
,
.
5
);
}
return
_audioPicIV
;
}
-
(
UILabel
*
)
audioNameLab
{
if
(
!
_audioNameLab
)
{
_audioNameLab
=
[
UILabel
labWithFont
:
BoldFont
(
16
)];
_audioNameLab
.
textAlignment
=
NSTextAlignmentCenter
;
_audioNameLab
.
dk_textColorPicker
=
DKColorPickerWithColors
(
MainTextColor
,
ColorFromHex
(
0xE8E9E9
),
DSWhite
);
}
return
_audioNameLab
;
}
-
(
DSSlider
*
)
progressV
{
if
(
!
_progressV
)
{
_progressV
=
[
DSSlider
new
];
[
_progressV
cornerRadius
:
2
.
0
];
_progressV
.
minimumTrackTintColor
=
BrandColor
;
_progressV
.
dk_maximumTrackTintColorPicker
=
DKColorPickerWithColors
(
ColorFromHex
(
0xE3E1E1
),
AlertDarkColor
,
DSWhite
);
[
_progressV
setThumbImage
:[
UIImage
imageNamed
:
@"muse_slider_thumbImage"
]
forState
:
UIControlStateNormal
];
[
_progressV
addTarget
:
self
action
:
@selector
(
sliderValueChanged
:
)
forControlEvents
:
UIControlEventValueChanged
];
[
_progressV
addTarget
:
self
action
:
@selector
(
sliderTouchDown
:
)
forControlEvents
:
UIControlEventTouchDown
];
[
_progressV
addTarget
:
self
action
:
@selector
(
sliderTouchUpInSide
:
)
forControlEvents
:
UIControlEventTouchUpInside
];
// 为UISlider添加点击事件
UITapGestureRecognizer
*
tapGesture
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
actionTapGesture
:
)];
tapGesture
.
delegate
=
self
;
[
_progressV
addGestureRecognizer
:
tapGesture
];
self
.
tapGR
=
tapGesture
;
}
return
_progressV
;
}
-
(
UILabel
*
)
proLeftLb
{
if
(
!
_proLeftLb
)
{
_proLeftLb
=
[
UILabel
labWithFont
:
SysFont
(
12
)];
_proLeftLb
.
textAlignment
=
NSTextAlignmentLeft
;
_proLeftLb
.
dk_textColorPicker
=
DKColorPickerWithColors
(
ColorFromHex
(
0xAAAAAA
),
ColorFromHex
(
0x5A6073
),
DSWhite
);
}
return
_proLeftLb
;
}
-
(
UILabel
*
)
proRightLb
{
if
(
!
_proRightLb
)
{
_proRightLb
=
[
UILabel
labWithFont
:
SysFont
(
12
)];
_proRightLb
.
textAlignment
=
NSTextAlignmentRight
;
_proRightLb
.
dk_textColorPicker
=
DKColorPickerWithColors
(
ColorFromHex
(
0xAAAAAA
),
ColorFromHex
(
0x5A6073
),
DSWhite
);
}
return
_proRightLb
;
}
-
(
UIButton
*
)
playerBtn
{
if
(
!
_playerBtn
)
{
_playerBtn
=
[
UIButton
new
];
[
_playerBtn
addTarget
:
self
action
:
@selector
(
playAction
)
forControlEvents
:
UIControlEventTouchUpInside
];
[
_playerBtn
dk_setBackgroundImage
:
DKImagePickerWithNames
(
@"audio_play_icon"
,
@"dk_audio_play_icon"
,
@"dk_audio_play_icon"
)
forState
:
UIControlStateNormal
];
[
_playerBtn
dk_setBackgroundImage
:
DKImagePickerWithNames
(
@"audio_pause"
,
@"dk_audio_pause"
,
@"dk_audio_pause"
)
forState
:
UIControlStateSelected
];
}
return
_playerBtn
;
}
@end
@end
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论