Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
陈高翔
/
DreamSleep-iOS
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit c9f76e02
由
cgx
编写于
2022-07-13 16:11:07 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
完成白噪音数据同步
1 个父辈
848187e6
显示空白字符变更
内嵌
并排
正在显示
20 个修改的文件
包含
193 行增加
和
124 行删除
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.h
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.h
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.m
DreamSleep/DreamSleep/Class/AISleepModule/Controller/AISleepCoachController.m → DreamSleep/DreamSleep/Class/AISleepModule/SleepCoach/Controller/AISleepCoachController.m
DreamSleep/DreamSleep/Class/AISleepModule/SleepReady/SRMusicView.h
DreamSleep/DreamSleep/Class/AISleepModule/SleepReady/SRMusicView.m
DreamSleep/DreamSleep/Class/AISleepModule/SleepReady/SleepReadyController.m
DreamSleep/DreamSleep/Class/HomeModule/Home/Controller/HomeViewController.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Controller/NoiseListController.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Model/NoisePlayItem.h
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Model/NoisePlayerManager.h
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Model/NoisePlayerManager.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseAudioCell.h
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseAudioCell.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayBar.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayCell.h
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayCell.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayView.m
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseView.h
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseView.m
DreamSleep/DreamSleep/Basement/Category/UIView+Extras.h
查看文件 @
c9f76e0
...
...
@@ -38,11 +38,11 @@ NS_ASSUME_NONNULL_BEGIN
-
(
void
)
debugViewShowBorderWithColor
:(
UIColor
*
)
color
;
/// 设置圆角
/// 设置圆角
方法1
/// @param radius radius
-
(
void
)
cornerRadius
:(
CGFloat
)
radius
;
//
添加遮罩
//
设置圆角方法2
-
(
void
)
addMaskWithType
:(
MaskType
)
type
cornerRadius
:(
CGFloat
)
cornerRadius
;
// 添加遮罩
...
...
@@ -50,6 +50,7 @@ NS_ASSUME_NONNULL_BEGIN
// 移除遮罩
-
(
void
)
removeMask
;
// 设置圆角方法3
-
(
void
)
setCornerRadiusRect
:(
UIRectCorner
)
rectCorner
cornerRadius
:(
CGFloat
)
cornerRadius
;
// 生成渐变色
...
...
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.h
查看文件 @
c9f76e0
...
...
@@ -33,8 +33,12 @@ FOUNDATION_EXTERN NSString * const HasUpdateUserDataNoti;
FOUNDATION_EXTERN
NSString
*
const
NeedUpdateHomePage
;
// 需要暂停所有白噪音播放
FOUNDATION_EXTERN
NSString
*
const
NeedPauseAllNoise
;
//
首页
白噪音播放列表变化通知
// 白噪音播放列表变化通知
FOUNDATION_EXTERN
NSString
*
const
NoisePlaylistHasChange
;
// 白噪音音频状态变化通知
FOUNDATION_EXTERN
NSString
*
const
NoiseAudioStateHasChanged
;
// 首页白噪音播放按钮状态变化通知
FOUNDATION_EXTERN
NSString
*
const
PlayStatusHasChanged
;
// 首页白噪音定时器被点击通知
FOUNDATION_EXTERN
NSString
*
const
NoiseTimingDidClick
;
// Unity
...
...
DreamSleep/DreamSleep/Basement/Utils/DSConstUtil.m
查看文件 @
c9f76e0
...
...
@@ -24,6 +24,8 @@ NSString * const HasUpdateUserDataNoti = @"hasUpdateUserDataNoti";
NSString
*
const
NeedUpdateHomePage
=
@"NeedUpdateHomePageNoti"
;
NSString
*
const
NeedPauseAllNoise
=
@"NeedPauseAllNoiseNoti"
;
NSString
*
const
NoisePlaylistHasChange
=
@"NoisePlaylistHasChangeNoti"
;
NSString
*
const
NoiseAudioStateHasChanged
=
@"NoiseAudioStateHasChangedNoti"
;
NSString
*
const
PlayStatusHasChanged
=
@"PlayStatusHasChangedNoti"
;
NSString
*
const
NoiseTimingDidClick
=
@"NoiseTimingDidClickNoti"
;
NSString
*
const
ExitCoaxSleep
=
@"ExitCoaxSleepNoti"
;
NSString
*
const
NeedUpdateAICoach
=
@"NeedUpdateAICoachNoti"
;
...
...
DreamSleep/DreamSleep/Class/AISleepModule/Controller/AISleepCoachController.m
→
DreamSleep/DreamSleep/Class/AISleepModule/
SleepCoach/
Controller/AISleepCoachController.m
查看文件 @
c9f76e0
...
...
@@ -11,6 +11,7 @@
#import "DsMaskView.h"
#import "RelaxTrainController.h"
#import "UnityGameController.h"
#import "SleepReadyController.h"
@interface
AISleepCoachController
()
<
WKNavigationDelegate
,
WKScriptMessageHandler
,
DsWebControllerDelegate
,
RelaxTrainControllerDelegate
>
@property
(
strong
,
nonatomic
)
WKWebView
*
aiWebView
;
...
...
@@ -198,9 +199,13 @@
break
;
case
3
:
// 轻拍哄睡
{
UnityGameController
*
gameVC
=
[
UnityGameController
new
];
gameVC
.
gameType
=
GameTypeCoax
;
[
self
.
navigationController
pushViewController
:
gameVC
animated
:
YES
];
// UnityGameController *gameVC = [UnityGameController new];
// gameVC.gameType = GameTypeCoax;
// [self.navigationController pushViewController:gameVC animated:YES];
#warning - 临时测试
SleepReadyController
*
srVC
=
[
SleepReadyController
new
];
[
self
.
navigationController
pushViewController
:
srVC
animated
:
YES
];
}
break
;
case
4
:
// 安心记事本
...
...
@@ -216,6 +221,12 @@
[
self
.
navigationController
pushViewController
:
relaxVC
animated
:
YES
];
}
break
;
case
6
:
// 安睡准备
{
SleepReadyController
*
srVC
=
[
SleepReadyController
new
];
[
self
.
navigationController
pushViewController
:
srVC
animated
:
YES
];
}
break
;
default
:
break
;
}
...
...
DreamSleep/DreamSleep/Class/AISleepModule/SleepReady/SRMusicView.h
查看文件 @
c9f76e0
...
...
@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
-
(
void
)
refreshNoiseTypeData
:(
NSArray
*
)
data
;
-
(
void
)
showMusicView
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/AISleepModule/SleepReady/SRMusicView.m
查看文件 @
c9f76e0
...
...
@@ -10,7 +10,8 @@
#import "NoisePlayBar.h"
#import "GoodSleepHeadView.h"
@interface
SRMusicView
()
<
GoodSleepHeadViewDelegate
>
@interface
SRMusicView
()
<
GoodSleepHeadViewDelegate
,
UIGestureRecognizerDelegate
>
@property
(
nonatomic
,
strong
)
UIView
*
alertView
;
@property
(
nonatomic
,
strong
)
GoodSleepHeadView
*
goodSleepHeadView
;
@property
(
nonatomic
,
strong
)
NoiseView
*
noiseView
;
@property
(
nonatomic
,
strong
)
NoisePlayBar
*
noisePlayBar
;
...
...
@@ -19,19 +20,15 @@
@implementation
SRMusicView
-
(
instancetype
)
initWithFrame
:(
CGRect
)
frame
{
if
(
self
=
[
super
initWithFrame
:
frame
])
{
[
self
setCornerRadiusRect
:(
UIRectCornerTopLeft
|
UIRectCornerTopRight
)
cornerRadius
:
24
.
0
];
if
(
self
=
[
super
initWithFrame
:[
UIScreen
mainScreen
].
bounds
])
{
self
.
dk_backgroundColorPicker
=
DKColorPickerWithColors
(
ColorFromHex
(
0x6F7587
),
DSClearColor
,
DSWhite
);
self
.
backgroundColor
=
[
self
.
backgroundColor
colorWithAlphaComponent
:
0
.
6
];
[
self
addSubview
:
self
.
goodSleepHeadView
];
[
self
addSubview
:
self
.
noiseView
]
;
[
self
add
Subview
:
self
.
noisePlayBar
];
UITapGestureRecognizer
*
tapGR
=
[[
UITapGestureRecognizer
alloc
]
initWithTarget
:
self
action
:
@selector
(
tapAction
)
];
tapGR
.
delegate
=
self
;
[
self
add
GestureRecognizer
:
tapGR
];
[
self
.
noisePlayBar
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
self
).
offset
(
15
);
make
.
right
.
equalTo
(
self
).
offset
(
-
15
);
make
.
bottom
.
equalTo
(
self
).
offset
(
-
15
);
make
.
height
.
equalTo
(
@50
);
}];
[
self
addSubview
:
self
.
alertView
];
}
return
self
;
}
...
...
@@ -40,14 +37,61 @@
[
self
.
noiseView
refreshNoiseTypeData
:
data
];
}
#pragma mark - GoodSleepHeadViewDelegate
-
(
void
)
closeAction
{
-
(
void
)
showMusicView
{
[
DSKeyWindow
addSubview
:
self
];
[
UIView
animateWithDuration
:.
3
animations
:
^
{
self
.
alertView
.
y
=
kScreenHeight
-
self
.
alertView
.
height
;
}];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NoisePlaylistHasChange
object
:
nil
];
}
-
(
void
)
dismissMusicView
{
[
UIView
animateWithDuration
:.
3
animations
:
^
{
self
.
y
=
kScreenHeight
;
self
.
alertView
.
y
=
kScreenHeight
;
}
completion
:^
(
BOOL
finished
)
{
[
self
removeFromSuperview
];
}];
}
-
(
void
)
tapAction
{
[
self
dismissMusicView
];
}
#pragma mark - UIGestureRecognizerDelegate
-
(
BOOL
)
gestureRecognizer
:
(
UIGestureRecognizer
*
)
gestureRecognizer
shouldReceiveTouch
:
(
UITouch
*
)
touch
{
if
([
touch
.
view
isKindOfClass
:[
self
class
]])
{
return
YES
;
}
return
NO
;
}
#pragma mark - GoodSleepHeadViewDelegate
-
(
void
)
closeAction
{
[
self
dismissMusicView
];
}
#pragma mark - lazy
-
(
UIView
*
)
alertView
{
if
(
!
_alertView
)
{
_alertView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
kScreenHeight
,
kScreenWidth
,
68
+
40
+
327
+
70
+
Bottom_SafeArea_Height
)];
_alertView
.
dk_backgroundColorPicker
=
DKColorPickerWithKey
(
TabBarBG
);
[
_alertView
setCornerRadiusRect
:(
UIRectCornerTopLeft
|
UIRectCornerTopRight
)
cornerRadius
:
24
.
0
];
[
_alertView
addSubview
:
self
.
goodSleepHeadView
];
[
_alertView
addSubview
:
self
.
noiseView
];
[
_alertView
addSubview
:
self
.
noisePlayBar
];
[
self
.
noisePlayBar
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
left
.
equalTo
(
_alertView
).
offset
(
15
);
make
.
right
.
equalTo
(
_alertView
).
offset
(
-
15
);
make
.
bottom
.
equalTo
(
_alertView
).
offset
(
-
15
-
Bottom_SafeArea_Height
);
make
.
height
.
equalTo
(
@50
);
}];
}
return
_alertView
;
}
-
(
GoodSleepHeadView
*
)
goodSleepHeadView
{
if
(
!
_goodSleepHeadView
)
{
_goodSleepHeadView
=
[[
GoodSleepHeadView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
0
,
kScreenWidth
,
68
)
headType
:
GSHeadTypeSR
];
...
...
DreamSleep/DreamSleep/Class/AISleepModule/SleepReady/SleepReadyController.m
查看文件 @
c9f76e0
...
...
@@ -42,7 +42,6 @@
[
self
.
view
insertSubview
:
self
.
headIV
atIndex
:
0
];
[
self
.
view
addSubview
:
self
.
startBtn
];
[
self
.
view
addSubview
:
self
.
musicBtn
];
[
self
.
view
addSubview
:
self
.
musicView
];
[
self
.
tipsBtn
mas_makeConstraints
:
^
(
MASConstraintMaker
*
make
)
{
make
.
centerY
.
equalTo
(
self
.
titleLab
);
...
...
@@ -65,6 +64,9 @@
make
.
right
.
equalTo
(
self
.
view
).
offset
(
-
15
);
}];
// 暂停白噪音
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NeedPauseAllNoise
object
:
nil
];
[
self
queryRelaxWhiteNoiseType
];
}
...
...
@@ -79,8 +81,8 @@
}
-
(
void
)
backAction
{
//
重置白噪音播放
[[
N
oisePlayerManager
sharedNoisePlayerManager
]
removeAllNoiseAudioCel
l
];
//
暂停白噪音
[[
N
SNotificationCenter
defaultCenter
]
postNotificationName
:
NeedPauseAllNoise
object
:
ni
l
];
[
super
backAction
];
}
...
...
@@ -130,13 +132,11 @@
-
(
UIButton
*
)
startBtn
{
if
(
!
_startBtn
)
{
// WS(weakSelf);
_startBtn
=
[
UIButton
btnWithTitle
:
@"开始仪式"
font
:
BoldFont
(
16
.
0
)];
[
_startBtn
cornerRadius
:
20
.
0
];
[
_startBtn
dk_setBackgroundColorPicker
:
DKColorPickerWithColors
(
BrandColor
,
SubNaviDarkColor
,
DSWhite
)];
[
_startBtn
dk_setTitleColorPicker
:
DKColorPickerWithColors
(
DSWhite
,
DkTitleColor
,
DSWhite
)
forState
:
UIControlStateNormal
];
[
_startBtn
addTouchUpInsideHandler
:
^
(
NSInteger
tag
)
{
// [weakSelf dismissTipsAlertView];
}];
}
return
_startBtn
;
...
...
@@ -148,9 +148,7 @@
_musicBtn
=
[
UIButton
new
];
[
_musicBtn
setImage
:[
UIImage
imageNamed
:
@"ic_zhunbei_baizaoyin"
]
forState
:
UIControlStateNormal
];
[
_musicBtn
addTouchUpInsideHandler
:
^
(
NSInteger
tag
)
{
[
UIView
animateWithDuration
:.
3
animations
:
^
{
weakSelf
.
musicView
.
y
=
kScreenHeight
-
weakSelf
.
musicView
.
height
;
}];
[
weakSelf
.
musicView
showMusicView
];
}];
}
return
_musicBtn
;
...
...
@@ -158,7 +156,7 @@
-
(
SRMusicView
*
)
musicView
{
if
(
!
_musicView
)
{
_musicView
=
[[
SRMusicView
alloc
]
initWithFrame
:
CGRect
Make
(
0
,
kScreenHeight
,
kScreenWidth
,
68
+
40
+
327
+
70
)
];
_musicView
=
[[
SRMusicView
alloc
]
initWithFrame
:
CGRect
Zero
];
}
return
_musicView
;
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/Home/Controller/HomeViewController.m
查看文件 @
c9f76e0
...
...
@@ -182,7 +182,7 @@
[
self
.
homeTV
updateNoiseAllTypeData
:
self
.
noiseTypeArr
];
// 重置白噪音播放
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeAllNoise
AudioCell
];
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeAllNoise
PlayItem
];
});
});
}
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Controller/NoiseListController.m
查看文件 @
c9f76e0
...
...
@@ -8,6 +8,7 @@
#import "NoiseListController.h"
#import "WhiteNoiseRequestModel.h"
#import "NoisePlayerManager.h"
#import "NoiseAudioCell.h"
@interface
NoiseListController
()
<
UICollectionViewDelegate
,
UICollectionViewDataSource
>
@property
(
nonatomic
,
strong
)
UICollectionView
*
noiseAudioView
;
...
...
@@ -73,24 +74,24 @@
// 白噪音未被选择则添加到播放列表
if
(
cell
.
audioIV
.
selected
==
NO
)
{
if
([
NoisePlayerManager
sharedNoisePlayerManager
].
play
Cell
List
.
count
>=
8
)
{
if
([
NoisePlayerManager
sharedNoisePlayerManager
].
play
Item
List
.
count
>=
8
)
{
[
DSProgressHUD
showToast
:
@"音频最多同时播放8个"
];
return
;
}
NoisePlayItem
*
playItem
=
[[
NoisePlayItem
alloc
]
initWithUrl
:
model
.
audio_url
volume
:.
5
];
playItem
.
noise_audio_id
=
model
.
noise_audio_id
;
playItem
.
audio_name
=
model
.
audio_name
;
playItem
.
audio_pic
=
model
.
audio_pic
;
playItem
.
isSeamlessLoopPlayback
=
YES
;
cell
.
playItem
=
playItem
;
[[
NoisePlayerManager
sharedNoisePlayerManager
]
addNoiseAudioCell
:
cell
];
[[
NoisePlayerManager
sharedNoisePlayerManager
]
addNoisePlayItem
:
playItem
];
[
DataStatisticsUtil
event
:
White_Noise_Click
attributes
:@{
@"typeName"
:
self
.
sub_name
,
@"audioName"
:
model
.
audio_name
}];
// 执行白噪音点击任务
[
DsTaskManager
excuteGeneralTaskWithType
:
TaskTypeDaily
taskItem
:
TaskItemGood
];
}
else
{
cell
.
playItem
=
nil
;
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeNoiseAudioCell
:
cell
];
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeNoisePlayItemWithAudioID
:
model
.
noise_audio_id
];
}
cell
.
audioIV
.
selected
=
!
cell
.
audioIV
.
selected
;
}
#pragma mark - lazy
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Model/NoisePlayItem.h
查看文件 @
c9f76e0
...
...
@@ -11,6 +11,12 @@ NS_ASSUME_NONNULL_BEGIN
/// 白噪音播放对象
@interface
NoisePlayItem
:
NSObject
/// 白噪音音频id(用于标识cell)
@property
(
nonatomic
,
assign
)
int
noise_audio_id
;
/// 名称
@property
(
nonatomic
,
copy
)
NSString
*
audio_name
;
/// 选中图标
@property
(
nonatomic
,
copy
)
NSString
*
audio_pic
;
/// 播放状态(YES:正在播放中...,NO:未播放)
@property
(
nonatomic
,
assign
)
BOOL
isPlaying
;
/// 是否循环播放
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Model/NoisePlayerManager.h
查看文件 @
c9f76e0
...
...
@@ -6,7 +6,7 @@
//
#import <Foundation/Foundation.h>
#import "Noise
AudioCell
.h"
#import "Noise
PlayItem
.h"
NS_ASSUME_NONNULL_BEGIN
...
...
@@ -14,23 +14,22 @@ NS_ASSUME_NONNULL_BEGIN
@interface
NoisePlayerManager
:
NSObject
SingletonH
(
NoisePlayerManager
)
/// 播放列表,存放被选中的cell对象
@property
(
nonatomic
,
strong
,
readonly
)
NSArray
<
NoiseAudioCell
*>
*
playCellList
;
/// 播放列表,存放NoisePlayItem对象(数据共享)
@property
(
nonatomic
,
strong
,
readonly
)
NSArray
<
NoisePlayItem
*>
*
playItemList
;
/// 播放状态(所有播放列表中只要有1个在播放则为YES,全部暂停为NO)
@property
(
nonatomic
,
assign
)
BOOL
isPlaying
;
/// 一键播放
-
(
void
)
playAll
;
/// 一键暂停
-
(
void
)
pauseAll
;
/// 一键停止
-
(
void
)
stopAll
;
-
(
BOOL
)
addNoiseAudioCell
:(
NoiseAudioCell
*
)
cell
;
-
(
BOOL
)
removeNoiseAudioCell
:(
NoiseAudioCell
*
)
cell
;
-
(
void
)
removeAllNoise
AudioCell
;
-
(
void
)
addNoisePlayItem
:(
NoisePlayItem
*
)
item
;
-
(
void
)
removeNoisePlayItemWithAudioID
:(
int
)
noise_audio_id
;
-
(
void
)
removeAllNoise
PlayItem
;
@end
NS_ASSUME_NONNULL_END
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/Model/NoisePlayerManager.m
查看文件 @
c9f76e0
...
...
@@ -9,28 +9,33 @@
#import <AVFoundation/AVFoundation.h>
@interface
NoisePlayerManager
()
/// 临时操作使用的可变数组
@property
(
nonatomic
,
strong
)
NSMutableArray
*
tmpArry
;
@property
(
nonatomic
,
strong
)
NSMutableArray
*
tmpPlayItemArr
;
@end
@implementation
NoisePlayerManager
SingletonM
(
NoisePlayerManager
)
#pragma mark - setter/getter
-
(
void
)
setIsPlaying
:
(
BOOL
)
isPlaying
{
_isPlaying
=
isPlaying
;
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
@"playStatusNoti"
object
:
nil
userInfo
:
@{
@"isPlaying"
:
@
(
self
.
isPlaying
)}];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
PlayStatusHasChanged
object
:
nil
userInfo
:
@{
@"isPlaying"
:
@
(
self
.
isPlaying
)}];
[
self
addNoti
];
}
-
(
NSMutableArray
*
)
tmpArry
{
if
(
!
_tmpArry
)
{
_tmpArry
=
[
NSMutableArray
array
];
-
(
NSArray
<
NoisePlayItem
*>
*
)
playItemList
{
return
[
self
.
tmpPlayItemArr
copy
];
}
-
(
NSMutableArray
*
)
tmpPlayItemArr
{
if
(
!
_tmpPlayItemArr
)
{
_tmpPlayItemArr
=
[
NSMutableArray
array
];
}
return
_tmp
Arry
;
return
_tmp
PlayItemArr
;
}
#pragma mark - noti
-
(
void
)
addNoti
{
// 监听音频被其他APP打断通知
AVAudioSession
*
sessionInstance
=
[
AVAudioSession
sharedInstance
];
...
...
@@ -56,14 +61,15 @@ SingletonM(NoisePlayerManager)
self
.
isPlaying
=
NO
;
}
-
(
NSArray
<
NoiseAudioCell
*>
*
)
playCellList
{
return
[
self
.
tmpArry
copy
];
-
(
void
)
sendNoti
:
(
id
)
object
{
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NoiseAudioStateHasChanged
object
:
object
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NoisePlaylistHasChange
object
:
nil
];
}
#pragma mark - public
-
(
void
)
playAll
{
BOOL
isPlaying
=
NO
;
for
(
NoiseAudioCell
*
cell
in
self
.
playCellList
)
{
NoisePlayItem
*
item
=
cell
.
playItem
;
for
(
NoisePlayItem
*
item
in
self
.
playItemList
)
{
// 该状态存在不及时
isPlaying
=
item
.
isPlaying
;
[
item
play
];
...
...
@@ -74,8 +80,7 @@ SingletonM(NoisePlayerManager)
}
-
(
void
)
pauseAll
{
for
(
NoiseAudioCell
*
cell
in
self
.
playCellList
)
{
NoisePlayItem
*
item
=
cell
.
playItem
;
for
(
NoisePlayItem
*
item
in
self
.
playItemList
)
{
[
item
pause
];
}
self
.
isPlaying
=
NO
;
...
...
@@ -84,9 +89,7 @@ SingletonM(NoisePlayerManager)
}
-
(
void
)
stopAll
{
for
(
NoiseAudioCell
*
cell
in
self
.
playCellList
)
{
cell
.
audioIV
.
selected
=
NO
;
NoisePlayItem
*
item
=
cell
.
playItem
;
for
(
NoisePlayItem
*
item
in
self
.
playItemList
)
{
[
item
stop
];
}
self
.
isPlaying
=
NO
;
...
...
@@ -94,25 +97,26 @@ SingletonM(NoisePlayerManager)
[
self
removeNoti
];
}
-
(
BOOL
)
addNoiseAudioCell
:
(
NoiseAudioCell
*
)
cell
{
[
self
.
tmpArry
addObject
:
cell
];
[
cell
.
playItem
play
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NoisePlaylistHasChange
object
:
nil
];
return
YES
;
-
(
void
)
addNoisePlayItem
:
(
NoisePlayItem
*
)
item
{
[
self
.
tmpPlayItemArr
addObject
:
item
];
[
self
playAll
];
[
self
sendNoti
:
@
(
item
.
noise_audio_id
)];
}
-
(
BOOL
)
removeNoiseAudioCell
:
(
NoiseAudioCell
*
)
cell
{
if
(
!
[
self
.
tmpArry
containsObject
:
cell
])
{
return
NO
;
}
[
cell
.
playItem
stop
];
[
self
.
tmpArry
removeObject
:
cell
];
[[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NoisePlaylistHasChange
object
:
nil
];
return
YES
;
-
(
void
)
removeNoisePlayItemWithAudioID
:
(
int
)
noise_audio_id
{
[
self
.
tmpPlayItemArr
enumerateObjectsUsingBlock
:
^
(
NoisePlayItem
*
item
,
NSUInteger
idx
,
BOOL
*
_Nonnull
stop
)
{
if
(
noise_audio_id
==
item
.
noise_audio_id
)
{
[
item
stop
];
[
self
.
tmpPlayItemArr
removeObject
:
item
];
[
self
sendNoti
:
@
(
item
.
noise_audio_id
)];
}
}];
}
-
(
void
)
removeAllNoise
AudioCell
{
-
(
void
)
removeAllNoise
PlayItem
{
[
self
stopAll
];
[
self
.
tmp
Arry
removeAllObjects
];
[
[
NSNotificationCenter
defaultCenter
]
postNotificationName
:
NoisePlaylistHasChange
object
:
nil
];
[
self
.
tmp
PlayItemArr
removeAllObjects
];
[
self
sendNoti
:
nil
];
}
@end
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseAudioCell.h
查看文件 @
c9f76e0
...
...
@@ -7,7 +7,6 @@
#import <UIKit/UIKit.h>
#import "NoiseAudioModel.h"
#import "NoisePlayItem.h"
/// 白噪音小音频cell
@interface
NoiseAudioCell
:
UICollectionViewCell
...
...
@@ -15,6 +14,4 @@
@property
(
nonatomic
,
strong
)
UIButton
*
audioIV
;
/// 数据model
@property
(
nonatomic
,
strong
)
NoiseAudioModel
*
model
;
/// 播放器
@property
(
nonatomic
,
strong
)
NoisePlayItem
*
playItem
;
@end
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseAudioCell.m
查看文件 @
c9f76e0
...
...
@@ -6,6 +6,7 @@
//
#import "NoiseAudioCell.h"
#import "NoisePlayerManager.h"
@interface
NoiseAudioCell
()
/// 白噪音音频名称
...
...
@@ -24,10 +25,29 @@
make
.
top
.
equalTo
(
self
.
contentView
).
offset
(
5
);
make
.
size
.
mas_equalTo
(
CGSizeMake
(
30
,
30
));
}];
// 对每个白噪音cell进行监听
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
noiseAudioStateHasChanged
:
)
name
:
NoiseAudioStateHasChanged
object
:
nil
];
}
return
self
;
}
-
(
void
)
noiseAudioStateHasChanged
:(
NSNotification
*
)
noti
{
if
(
noti
.
object
)
{
int
noise_id
=
[
noti
.
object
intValue
];
if
(
noise_id
==
self
.
model
.
noise_audio_id
)
{
self
.
audioIV
.
selected
=
!
self
.
audioIV
.
selected
;
}
}
else
{
// 清除全部触发
self
.
audioIV
.
selected
=
NO
;
}
}
-
(
void
)
dealloc
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
NoiseAudioStateHasChanged
object
:
nil
];
}
-
(
void
)
setModel
:
(
NoiseAudioModel
*
)
model
{
_model
=
model
;
...
...
@@ -39,6 +59,12 @@
make
.
top
.
equalTo
(
self
.
audioIV
.
mas_bottom
).
offset
(
3
);
make
.
centerX
.
equalTo
(
self
.
audioIV
);
}];
for
(
NoisePlayItem
*
item
in
[
NoisePlayerManager
sharedNoisePlayerManager
].
playItemList
)
{
if
(
item
.
noise_audio_id
==
model
.
noise_audio_id
)
{
self
.
audioIV
.
selected
=
YES
;
}
}
}
#pragma mark - lazy
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayBar.m
查看文件 @
c9f76e0
...
...
@@ -71,7 +71,7 @@
// 添加对单例对象白噪音播放列表变化通知
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
noisePlaylistHasChange
:
)
name
:
NoisePlaylistHasChange
object
:
nil
];
// 监听播放按钮状态通知
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
playStatusNoti
:
)
name
:
@"playStatusNoti"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
playStatusNoti
:
)
name
:
PlayStatusHasChanged
object
:
nil
];
// 监听定时按钮被点击事件通知
[[
NSNotificationCenter
defaultCenter
]
addObserver
:
self
selector
:
@selector
(
openTimingView
)
name
:
NoiseTimingDidClick
object
:
nil
];
}
...
...
@@ -80,7 +80,7 @@
-
(
void
)
dealloc
{
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
NoisePlaylistHasChange
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
@"playStatusNoti"
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
PlayStatusHasChanged
object
:
nil
];
[[
NSNotificationCenter
defaultCenter
]
removeObserver
:
self
name
:
NoiseTimingDidClick
object
:
nil
];
[
_timer
invalidate
];
...
...
@@ -91,12 +91,12 @@
#pragma mark - noti
-
(
void
)
noisePlaylistHasChange
:
(
NSNotification
*
)
noti
{
NSArray
*
playList
=
[
NoisePlayerManager
sharedNoisePlayerManager
].
play
Cell
List
;
NSArray
*
playList
=
[
NoisePlayerManager
sharedNoisePlayerManager
].
play
Item
List
;
self
.
hidden
=
!
(
playList
.
count
>
0
);
NSMutableString
*
mStr
=
[
NSMutableString
string
];
for
(
int
i
=
0
;
i
<
playList
.
count
;
i
++
)
{
Noise
AudioCell
*
audioCell
=
playList
[
i
];
[
mStr
appendFormat
:
@"%@%@"
,
audioCell
.
model
.
audio_name
,
(
i
==
playList
.
count
-
1
)
?
@""
:
@","
];
Noise
PlayItem
*
item
=
playList
[
i
];
[
mStr
appendFormat
:
@"%@%@"
,
item
.
audio_name
,
(
i
==
playList
.
count
-
1
)
?
@""
:
@","
];
self
.
playBtn
.
selected
=
[
NoisePlayerManager
sharedNoisePlayerManager
].
isPlaying
;
}
self
.
audioLab
.
text
=
[
mStr
copy
];
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayCell.h
查看文件 @
c9f76e0
...
...
@@ -6,7 +6,7 @@
//
#import <UIKit/UIKit.h>
#import "Noise
AudioModel
.h"
#import "Noise
PlayItem
.h"
NS_ASSUME_NONNULL_BEGIN
...
...
@@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface
NoisePlayCell
:
UITableViewCell
@property
(
nonatomic
,
weak
)
id
<
NoisePlayCellDelegate
>
delegate
;
@property
(
nonatomic
,
strong
)
Noise
AudioModel
*
model
;
@property
(
nonatomic
,
strong
)
Noise
PlayItem
*
item
;
@property
(
nonatomic
,
assign
)
float
volumn
;
@property
(
nonatomic
,
strong
)
NSIndexPath
*
indexPath
;
@end
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayCell.m
查看文件 @
c9f76e0
...
...
@@ -68,16 +68,12 @@
return
self
;
}
-
(
void
)
set
Model
:
(
NoiseAudioModel
*
)
model
{
_
model
=
model
;
-
(
void
)
set
Item
:
(
NoisePlayItem
*
)
item
{
_
item
=
item
;
[
self
.
audioIcon
yy_setImageWithURL
:[
NSURL
URLWithString
:
model
.
audio_pic
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
self
.
nameLab
.
text
=
model
.
audio_name
;
}
-
(
void
)
setVolumn
:
(
float
)
volumn
{
_volumn
=
volumn
;
self
.
volumeSlider
.
value
=
volumn
;
[
self
.
audioIcon
yy_setImageWithURL
:[
NSURL
URLWithString
:
item
.
audio_pic
]
placeholder
:[
UIImage
imageNamed
:
@"basicPlaceholder"
]];
self
.
nameLab
.
text
=
item
.
audio_name
;
self
.
volumeSlider
.
value
=
item
.
volume
;
}
-
(
void
)
setIndexPath
:
(
NSIndexPath
*
)
indexPath
{
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoisePlayView.m
查看文件 @
c9f76e0
...
...
@@ -7,7 +7,6 @@
#import "NoisePlayView.h"
#import "NoisePlayCell.h"
#import "NoiseAudioCell.h"
#import "NoisePlayerManager.h"
@interface
NoisePlayView
()
<
UITableViewDelegate
,
UITableViewDataSource
,
NoisePlayCellDelegate
>
...
...
@@ -39,7 +38,7 @@
-
(
void
)
showNoisePlayViewWith
:
(
BOOL
)
selected
{
[
DSKeyWindow
addSubview
:
self
];
NSArray
*
playCellList
=
[
NoisePlayerManager
sharedNoisePlayerManager
].
play
Cell
List
;
NSArray
*
playCellList
=
[
NoisePlayerManager
sharedNoisePlayerManager
].
play
Item
List
;
if
(
playCellList
)
{
self
.
audioArr
=
playCellList
;
[
self
.
playListView
reloadData
];
...
...
@@ -64,7 +63,7 @@
}
-
(
void
)
clearAllAction
:
(
UIButton
*
)
sender
{
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeAllNoise
AudioCell
];
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeAllNoise
PlayItem
];
self
.
audioArr
=
@[];
[
self
.
playListView
reloadData
];
[
self
removeFromSuperview
];
...
...
@@ -86,9 +85,8 @@
cell
=
[[
NoisePlayCell
alloc
]
initWithStyle
:
UITableViewCellStyleDefault
reuseIdentifier
:
cellIdentifier
];
}
cell
.
delegate
=
self
;
NoiseAudioCell
*
audioCell
=
self
.
audioArr
[
indexPath
.
row
];
cell
.
model
=
audioCell
.
model
;
cell
.
volumn
=
audioCell
.
playItem
.
volume
;
NoisePlayItem
*
item
=
self
.
audioArr
[
indexPath
.
row
];
cell
.
item
=
item
;
cell
.
indexPath
=
indexPath
;
return
cell
;
}
...
...
@@ -115,14 +113,12 @@
#pragma mark - NoisePlayCellDelegate
-
(
void
)
didRemoveItem
:
(
NSIndexPath
*
)
indexPath
{
// 将要删除的音频停止播放并且设置为非选中状态
NoiseAudioCell
*
audioCell
=
self
.
audioArr
[
indexPath
.
row
];
audioCell
.
audioIV
.
selected
=
NO
;
NoisePlayItem
*
item
=
self
.
audioArr
[
indexPath
.
row
];
// 删除数据源
NSMutableArray
*
tmpArr
=
[
NSMutableArray
arrayWithArray
:
self
.
audioArr
];
[
tmpArr
removeObjectAtIndex
:
indexPath
.
row
];
self
.
audioArr
=
[
tmpArr
copy
];
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeNoise
AudioCell
:
audioCell
];
[[
NoisePlayerManager
sharedNoisePlayerManager
]
removeNoise
PlayItemWithAudioID
:
item
.
noise_audio_id
];
// 执行删除动画
[
self
.
playListView
deleteRowsAtIndexPaths
:@[
indexPath
]
withRowAnimation
:
UITableViewRowAnimationLeft
];
dispatch_after
(.
3
,
dispatch_get_main_queue
(),
^
{
...
...
@@ -132,8 +128,8 @@
}
-
(
void
)
didSetVolume
:
(
float
)
volume
indexPath
:
(
NSIndexPath
*
)
indexPath
{
Noise
AudioCell
*
audioCell
=
self
.
audioArr
[
indexPath
.
row
];
audioCell
.
playI
tem
.
volume
=
volume
;
Noise
PlayItem
*
item
=
self
.
audioArr
[
indexPath
.
row
];
i
tem
.
volume
=
volume
;
}
#pragma mark - lazy
...
...
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseView.h
查看文件 @
c9f76e0
DreamSleep/DreamSleep/Class/HomeModule/WhiteNoise/View/NoiseView.m
查看文件 @
c9f76e0
...
...
@@ -551,24 +551,6 @@ static float oldOffsetX;
}];
}
// if (_pageTitleColorChangeType == PageTitleColorChangeTypeScrolling) {
// NSArray *rgba0 = [self getRGBValueFromColor:_titleColor];
// NSArray *rgba1 = [self getRGBValueFromColor:_titleSelectedColor];
// CGFloat diffR = xInScreen / kScreenWidth * ([rgba1[0] floatValue] - [rgba0[0] floatValue]);
// CGFloat diffG = xInScreen / kScreenWidth * ([rgba1[1] floatValue] - [rgba0[1] floatValue]);
// CGFloat diffB = xInScreen / kScreenWidth * ([rgba1[2] floatValue] - [rgba0[2] floatValue]);
// CGFloat runingRed0 = [rgba0[0] floatValue] + diffR;
// CGFloat runingGreen0 = [rgba0[1] floatValue] + diffG;
// CGFloat runingBlue0 = [rgba0[2] floatValue] + diffB;
// CGFloat runingred1 = [rgba1[0] floatValue] - diffR;
// CGFloat runinGreen1 = [rgba1[1] floatValue] - diffG;
// CGFloat runingBlue1 = [rgba1[2] floatValue] - diffB;
// UIColor *runtimeColor0 = [UIColor colorWithRed:runingRed0 green:runingGreen0 blue:runingBlue0 alpha:1.0];
// UIColor *runtimeColor1 = [UIColor colorWithRed:runingred1 green:runinGreen1 blue:runingBlue1 alpha:1.0];
// oldCell.titleLabel.textColor = runtimeColor1;
// newCell.titleLabel.textColor = runtimeColor0;
// }
}
/** 系统API获取UIColor的RGBA值 */
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论