Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e520aa3c
由
cgx
编写于
2022-05-10 11:26:56 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化音频播放列表
1 个父辈
12dcca73
显示空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
114 行增加
和
37 行删除
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioCourseCell.m
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.h
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerView.m
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/Contents.json
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/dk_ic_list_playing_normal.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/dk_ic_list_playing_normal@2x.png
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/dk_ic_list_playing_normal@3x.png
DreamSleep/DreamSleep/Class/HomeModule/Home/AudioCourseCell.m
查看文件 @
e520aa3
...
...
@@ -125,6 +125,9 @@
}
-
(
void
)
updateUI
:(
SubAudioModel
*
)
model
indexPath
:(
NSIndexPath
*
)
indexPath
{
self
.
numberLb
.
hidden
=
NO
;
self
.
playVedioImgV
.
hidden
=
!
self
.
numberLb
.
hidden
;
self
.
numberLb
.
text
=
[
NSString
stringWithFormat
:
@"%ld"
,
indexPath
.
row
+
1
];
self
.
timeLb
.
text
=
model
.
play_time
;
self
.
titleLb
.
text
=
model
.
audio_name
;
...
...
@@ -145,11 +148,11 @@
-
(
void
)
updatePlayingAudio
{
self
.
numberLb
.
hidden
=
YES
;
#warning 需要提供夜间模式图标
self
.
playVedioImgV
.
image
=
[
UIImage
imageNamed
:
@"ic_list_playing_normal"
];
self
.
playVedioImgV
.
hidden
=
!
self
.
numberLb
.
hidden
;
self
.
tryLab
.
hidden
=
YES
;
self
.
pleyerBtn
.
hidden
=
!
self
.
tryLab
.
hidden
;
[
self
.
playVedioImgV
dk_setImagePicker
:
DKImagePickerWithNames
(
@"ic_list_playing_normal"
,
@"dk_ic_list_playing_normal"
,
@"ic_list_playing_normal"
)];
[
self
.
pleyerBtn
setImage
:[
UIImage
imageNamed
:
@"ic_list_suspend_normal"
]
forState
:
UIControlStateNormal
];
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.h
查看文件 @
e520aa3
...
...
@@ -11,7 +11,10 @@
NS_ASSUME_NONNULL_BEGIN
@protocol
CourseDetailControllerDelegate
<
NSObject
>
-
(
void
)
didSelectAudioWithIndex
:
(
NSInteger
)
index
;
/// 用户点击音频
/// @param index 当前点击的音频下标
/// @param audios 已解锁的最新音频数据
-
(
void
)
didSelectAudioWithIndex
:
(
NSInteger
)
index
latestAudios
:
(
NSArray
*
)
audios
;
@end
/// 课程详情页(音频列表)
...
...
@@ -19,8 +22,15 @@ NS_ASSUME_NONNULL_BEGIN
@property
(
nonatomic
,
strong
)
CourseModel
*
courseModel
;
@property
(
nonatomic
,
weak
)
id
<
CourseDetailControllerDelegate
>
delegate
;
@property
(
nonatomic
,
assign
)
NSInteger
playingIndex
;
/*
用于标记从哪个页面进入到音频列表界面
YES:播放页面点击播放列表;
NO:课程页面点击UICollectionViewCell;
*/
@property
(
nonatomic
,
assign
)
BOOL
isFromPlayer
;
/// 正在播放的音频索引(-1:没有正在播放的音频,0,1,2...:有正在播放的音频)
@property
(
nonatomic
,
assign
)
NSInteger
playingIndex
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/Home/CourseDetailController.m
查看文件 @
e520aa3
...
...
@@ -35,6 +35,17 @@
self
.
titleLab
.
text
=
self
.
courseModel
.
audio_name
;
[
self
getAudiosData
];
if
(
self
.
isFromPlayer
==
NO
)
{
// 给音频列表页面添加通知(从播放页面跳转到音频列表),通知发送时机:音频列表(从播放页面跳转到音频列表)登录成功后
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
refreshOriAudioList
)
name
:
@"UnlockAudioSuccessNoti"
object
:
nil
];
}
}
-
(
void
)
dealloc
{
if
(
self
.
isFromPlayer
==
NO
)
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
@"UnlockAudioSuccessNoti"
object
:
nil
];
}
}
-
(
void
)
getAudiosData
{
...
...
@@ -61,21 +72,61 @@
return
NO
;
}
#pragma mark - Actions
-
(
void
)
backAction
{
[
super
backAction
];
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
}
-
(
void
)
unlockAction
{
// 开始第一节
if
([
LoginUtils
getUserLoginData
])
{
[
self
jumpToMusicPlayerControllerWithIndex
:
0
];
}
else
{
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
selector
:
@selector
(
updateAfterLoginSuccess
)];
}
}
#pragma mark - 跳转到播放页面
-
(
void
)
jumpToMusicPlayerControllerWithIndex
:
(
NSInteger
)
index
{
// 筛选已经解锁的音频
NSMutableArray
*
tmpArr
=
[
NSMutableArray
array
];
[
self
.
subAudioArr
enumerateObjectsUsingBlock
:
^
(
SubAudioModel
*
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
obj
.
is_lock
==
0
)
{
[
tmpArr
addObject
:
obj
];
}
}];
// 播放页面点击播放列表进入
if
(
self
.
isFromPlayer
)
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSelectAudioWithIndex
:
latestAudios
:
)])
{
[
self
.
delegate
didSelectAudioWithIndex
:
index
latestAudios
:[
tmpArr
copy
]];
}
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
return
;
}
// 课程列表跳转过来的(跳转到播放页面)
MusicPlayerController
*
playerVC
=
[[
MusicPlayerController
alloc
]
init
];
playerVC
.
currentIndex
=
index
;
playerVC
.
playAudios
=
[
tmpArr
copy
];
playerVC
.
courseModel
=
self
.
courseModel
;
UINavigationController
*
naviVC
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
playerVC
];
[
self
presentViewController
:
naviVC
animated
:
YES
completion
:
nil
];
}
#pragma mark - 登录成功后刷新
-
(
void
)
updateAfterLoginSuccess
{
[
self
.
unlockBtn
setTitle
:
@"开始第一节"
forState
:
UIControlStateNormal
];
[
self
getAudiosData
];
if
(
self
.
isFromPlayer
)
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
@"UnlockAudioSuccessNoti"
object
:
nil
];
}
}
#pragma mark - 刷新最开始的音频列表
-
(
void
)
refreshOriAudioList
{
[
self
.
unlockBtn
setTitle
:
@"开始第一节"
forState
:
UIControlStateNormal
];
[
self
getAudiosData
];
}
#pragma mark - UITableViewDelegate, UITableViewDataSource
...
...
@@ -92,13 +143,11 @@
if
(
self
.
subAudioArr
.
count
>
indexPath
.
row
)
{
SubAudioModel
*
model
=
self
.
subAudioArr
[
indexPath
.
row
];
[
cell
updateUI
:
model
indexPath
:
indexPath
];
// 标记已播放的音频
if
(
self
.
isFromPlayer
)
{
if
(
self
.
playingIndex
==
indexPath
.
row
)
{
// 从播放页面点击播放列表进入,标记正在播放的音频
if
(
self
.
isFromPlayer
&&
self
.
playingIndex
==
indexPath
.
row
)
{
[
cell
updatePlayingAudio
];
}
}
}
return
cell
;
}
...
...
@@ -114,29 +163,7 @@
[
LoginUtils
jumpToLoginControllerWithTarget
:
self
selector
:
@selector
(
updateAfterLoginSuccess
)];
}
}
else
{
// 播放页面点击播放列表进入
if
(
self
.
isFromPlayer
)
{
if
(
self
.
delegate
&&
[
self
.
delegate
respondsToSelector
:
@selector
(
didSelectAudioWithIndex
:)])
{
[
self
.
delegate
didSelectAudioWithIndex
:
indexPath
.
row
];
}
[
self
.
navigationController
popViewControllerAnimated
:
YES
];
return
;
}
// 课程列表跳转过来的(跳转到播放页面)
MusicPlayerController
*
playerVC
=
[[
MusicPlayerController
alloc
]
init
];
playerVC
.
currentIndex
=
indexPath
.
row
;
// 筛选已经解锁的音频
NSMutableArray
*
tmpArr
=
[
NSMutableArray
array
];
[
self
.
subAudioArr
enumerateObjectsUsingBlock
:
^
(
SubAudioModel
*
obj
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
obj
.
is_lock
==
0
)
{
[
tmpArr
addObject
:
obj
];
}
}];
playerVC
.
playAudios
=
[
tmpArr
copy
];
playerVC
.
courseModel
=
self
.
courseModel
;
UINavigationController
*
naviVC
=
[[
UINavigationController
alloc
]
initWithRootViewController
:
playerVC
];
[
self
presentViewController
:
naviVC
animated
:
YES
completion
:
nil
];
[
self
jumpToMusicPlayerControllerWithIndex
:
indexPath
.
row
];
}
}
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerController.m
查看文件 @
e520aa3
...
...
@@ -137,6 +137,10 @@
}
-
(
void
)
launchPlayer
{
// 不是正在播放的状态需要先停止
if
(
self
.
audioStream
.
isPlaying
==
NO
)
{
[
self
.
audioStream
stop
];
}
if
(
self
.
currentIndex
>=
self
.
playAudios
.
count
)
{
return
;
}
SubAudioModel
*
audioModel
=
self
.
playAudios
[
self
.
currentIndex
];
[
self
.
playerView
updatePlayerView
:
audioModel
];
[
self
.
audioStream
playFromURL
:[
NSURL
URLWithString
:
audioModel
.
audio_url
]];
...
...
@@ -211,15 +215,27 @@
-
(
void
)
jumpToPlaylistController
{
CourseDetailController
*
coureDetailVC
=
[[
CourseDetailController
alloc
]
init
];
coureDetailVC
.
courseModel
=
self
.
courseModel
;
coureDetailVC
.
playingIndex
=
self
.
currentIndex
;
coureDetailVC
.
playingIndex
=
self
.
audioStream
.
isPlaying
?
self
.
currentIndex
:
-
1
;
coureDetailVC
.
isFromPlayer
=
YES
;
coureDetailVC
.
delegate
=
self
;
[
self
.
navigationController
pushViewController
:
coureDetailVC
animated
:
YES
];
}
#pragma mark - CourseDetailControllerDelegate
-
(
void
)
didSelectAudioWithIndex
:
(
NSInteger
)
index
{
if
(
self
.
currentIndex
==
index
)
{
return
;
}
-
(
void
)
didSelectAudioWithIndex
:
(
NSInteger
)
index
latestAudios
:
(
NSArray
*
)
audios
{
// 更新音频数据
self
.
playAudios
=
audios
;
// 点击当前传过来音频
if
(
self
.
currentIndex
==
index
)
{
if
(
self
.
streamState
==
kFsAudioStreamStopped
)
{
[
self
.
audioStream
play
];
}
else
if
(
self
.
streamState
==
kFsAudioStreamPaused
)
{
// 恢复播放
[
self
.
audioStream
pause
];
}
return
;
}
self
.
currentIndex
=
index
;
[
self
launchPlayer
];
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/MusicPlayerView.m
查看文件 @
e520aa3
...
...
@@ -406,8 +406,6 @@
if
(
!
_timer
)
{
WS
(
weakSelf
);
_timer
=
[
NSTimer
timerWithTimeInterval
:
1
.
0
repeats
:
YES
block
:^
(
NSTimer
*
_Nonnull
timer
)
{
DSLog
(
@"============"
);
// 暂停播放
if
(
weakSelf
.
countTime
==
0
)
{
[
weakSelf
.
timer
setFireDate
:[
NSDate
distantFuture
]];
...
...
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/Contents.json
0 → 100644
查看文件 @
e520aa3
{
"images"
:
[
{
"filename"
:
"dk_ic_list_playing_normal.png"
,
"idiom"
:
"universal"
,
"scale"
:
"1x"
},
{
"filename"
:
"dk_ic_list_playing_normal@2x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"2x"
},
{
"filename"
:
"dk_ic_list_playing_normal@3x.png"
,
"idiom"
:
"universal"
,
"scale"
:
"3x"
}
],
"info"
:
{
"author"
:
"xcode"
,
"version"
:
1
}
}
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/dk_ic_list_playing_normal.png
0 → 100644
查看文件 @
e520aa3
365 字节
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/dk_ic_list_playing_normal@2x.png
0 → 100644
查看文件 @
e520aa3
753 字节
DreamSleep/DreamSleep/Resource/Assets.xcassets/SafeSleep/dk_ic_list_playing_normal.imageset/dk_ic_list_playing_normal@3x.png
0 → 100644
查看文件 @
e520aa3
1.2 KB
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论