1.2.2 广告最终策略调整
This commit is contained in:
parent
6ea3f5943c
commit
c48641fc10
Binary file not shown.
@ -74,7 +74,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
MP_DownloadManager.shared.session.completionHandler = completionHandler
|
MP_DownloadManager.shared.session.completionHandler = completionHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//设置播放器会话状态
|
///设置播放器会话
|
||||||
func setAudioSupport(){
|
func setAudioSupport(){
|
||||||
//设置会话
|
//设置会话
|
||||||
let session = AVAudioSession.sharedInstance()
|
let session = AVAudioSession.sharedInstance()
|
||||||
@ -90,19 +90,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
//响应后台控制
|
//响应后台控制
|
||||||
UIApplication.shared.beginReceivingRemoteControlEvents()
|
UIApplication.shared.beginReceivingRemoteControlEvents()
|
||||||
}
|
}
|
||||||
func setAudioResume() {
|
///终止播放器会话
|
||||||
//设置会话
|
|
||||||
let session = AVAudioSession.sharedInstance()
|
|
||||||
do {
|
|
||||||
try session.setCategory(.playAndRecord, mode: .default, options: [ .allowAirPlay, .allowBluetoothA2DP,.defaultToSpeaker])
|
|
||||||
//恢复会话
|
|
||||||
try session.setActive(true)
|
|
||||||
print("恢复会话")
|
|
||||||
} catch {
|
|
||||||
print("Failed to set type:\(error.localizedDescription)")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
///停止播放器会话
|
|
||||||
func setAudioStop() {
|
func setAudioStop() {
|
||||||
//设置会话
|
//设置会话
|
||||||
let session = AVAudioSession.sharedInstance()
|
let session = AVAudioSession.sharedInstance()
|
||||||
@ -114,18 +102,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
|||||||
print("Failed to set type:\(error.localizedDescription)")
|
print("Failed to set type:\(error.localizedDescription)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
///激活播放器会话
|
///重新激活播放器会话
|
||||||
func setAudioActive() {
|
func setAudioActive() {
|
||||||
//设置会话
|
//设置会话
|
||||||
let session = AVAudioSession.sharedInstance()
|
let session = AVAudioSession.sharedInstance()
|
||||||
do {
|
do {
|
||||||
//中止会话
|
if session.category != .playAndRecord || session.categoryOptions != [ .allowAirPlay, .allowBluetoothA2DP,.defaultToSpeaker] {
|
||||||
|
if session.category != .playAndRecord {
|
||||||
|
print("音频会话状态发生变动")
|
||||||
|
}else {
|
||||||
|
print("音频会话类型发生变动")
|
||||||
|
}
|
||||||
try session.setCategory(.playAndRecord, mode: .default, options: [ .allowAirPlay, .allowBluetoothA2DP,.defaultToSpeaker])
|
try session.setCategory(.playAndRecord, mode: .default, options: [ .allowAirPlay, .allowBluetoothA2DP,.defaultToSpeaker])
|
||||||
|
try session.setActive(true)
|
||||||
|
print("重新设置音频会话模型")
|
||||||
|
}else {
|
||||||
try session.setActive(true)
|
try session.setActive(true)
|
||||||
print("恢复会话")
|
print("恢复会话")
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
print("Failed to set type:\(error.localizedDescription)")
|
print("Failed to set type:\(error.localizedDescription)")
|
||||||
}
|
}
|
||||||
|
//发送一个通知,询问当前音乐是否播放中
|
||||||
|
NotificationCenter.notificationKey.post(notificationName: .player_is_continua)
|
||||||
}
|
}
|
||||||
//活跃天数计算
|
//活跃天数计算
|
||||||
private func ActiveDaysCalculation() {
|
private func ActiveDaysCalculation() {
|
||||||
|
|||||||
@ -121,6 +121,8 @@ extension NotificationCenter{
|
|||||||
case search_gride_reload
|
case search_gride_reload
|
||||||
///曲库原生广告加载成功
|
///曲库原生广告加载成功
|
||||||
case library_native_success
|
case library_native_success
|
||||||
|
///询问播放器是否继续播放音乐
|
||||||
|
case player_is_continua
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -567,7 +567,7 @@ func postUpdateReminder(_ observe:UIViewController) {
|
|||||||
observe.present(alter, animated: true)
|
observe.present(alter, animated: true)
|
||||||
}
|
}
|
||||||
///从离线第一首开始播放
|
///从离线第一首开始播放
|
||||||
func playOfflineSongs() {
|
func playOfflineSongs(_ videoId:String) {
|
||||||
if MPPositive_LoadCoreModel.shared.loadViewModels.isEmpty == false {
|
if MPPositive_LoadCoreModel.shared.loadViewModels.isEmpty == false {
|
||||||
MP_HUD.text("You are in offline mode".localizableString(), delay: 2.0, completion: nil)
|
MP_HUD.text("You are in offline mode".localizableString(), delay: 2.0, completion: nil)
|
||||||
//获取离线的歌曲
|
//获取离线的歌曲
|
||||||
@ -594,7 +594,15 @@ func playOfflineSongs() {
|
|||||||
item.relatedID = song.loadItem.relatedID
|
item.relatedID = song.loadItem.relatedID
|
||||||
array.append(item)
|
array.append(item)
|
||||||
}
|
}
|
||||||
if let currentVideo = MPPositive_LoadCoreModel.shared.loadViewModels.first {
|
//检索videoId是否在loadModels中存在
|
||||||
|
if let currentVideo = MPPositive_LoadCoreModel.shared.loadViewModels.first(where: {$0.loadItem.videoId == videoId}) {
|
||||||
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: currentVideo.loadItem.videoId ?? "")
|
||||||
|
lodaViewModel.improveData(currentVideo.loadItem.videoId ?? "")
|
||||||
|
//更改播放器播放类型
|
||||||
|
MP_PlayerManager.shared.setPlayType(.normal)
|
||||||
|
MP_PlayerManager.shared.loadPlayer = lodaViewModel
|
||||||
|
MP_AnalyticsManager.shared.player_b_listAction()
|
||||||
|
}else if let currentVideo = MPPositive_LoadCoreModel.shared.loadViewModels.first {
|
||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: currentVideo.loadItem.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: currentVideo.loadItem.videoId ?? "")
|
||||||
lodaViewModel.improveData(currentVideo.loadItem.videoId ?? "")
|
lodaViewModel.improveData(currentVideo.loadItem.videoId ?? "")
|
||||||
//更改播放器播放类型
|
//更改播放器播放类型
|
||||||
|
|||||||
@ -81,6 +81,9 @@ class MP_ADSimpleManager: NSObject {
|
|||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_:)), notificationName: .net_switch_reachable)
|
NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_:)), notificationName: .net_switch_reachable)
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
deinit{
|
deinit{
|
||||||
NotificationCenter.default.removeObserver(self)
|
NotificationCenter.default.removeObserver(self)
|
||||||
@ -89,11 +92,15 @@ class MP_ADSimpleManager: NSObject {
|
|||||||
func isAdMuted() {
|
func isAdMuted() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if MP_PlayerManager.shared.getPlayState() == .Playing {
|
if MP_PlayerManager.shared.getPlayState() == .Playing {
|
||||||
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = true
|
if GADMobileAds.sharedInstance().applicationMuted == false {
|
||||||
GADMobileAds.sharedInstance().applicationMuted = true
|
GADMobileAds.sharedInstance().applicationMuted = true
|
||||||
|
GADMobileAds.sharedInstance().applicationVolume = 0.1
|
||||||
|
print("播放中,静音广告")
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = false
|
|
||||||
GADMobileAds.sharedInstance().applicationMuted = false
|
GADMobileAds.sharedInstance().applicationMuted = false
|
||||||
|
GADMobileAds.sharedInstance().applicationVolume = 1
|
||||||
|
print("没有播放,不需要静音广告")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,8 +108,8 @@ class MP_ADSimpleManager: NSObject {
|
|||||||
func isAdSounded() {
|
func isAdSounded() {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if GADMobileAds.sharedInstance().applicationMuted == true {
|
if GADMobileAds.sharedInstance().applicationMuted == true {
|
||||||
GADMobileAds.sharedInstance().audioVideoManager.audioSessionIsApplicationManaged = false
|
|
||||||
GADMobileAds.sharedInstance().applicationMuted = false
|
GADMobileAds.sharedInstance().applicationMuted = false
|
||||||
|
print("加载广告时恢复广告声音配置")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1544,11 +1544,11 @@ class MP_AdMobManager: NSObject, GADAudioVideoManagerDelegate, GADFullScreenCont
|
|||||||
//MARK: - 广告音频代理 GADAudioVideoManagerDelegate
|
//MARK: - 广告音频代理 GADAudioVideoManagerDelegate
|
||||||
//广告将会播放视频
|
//广告将会播放视频
|
||||||
func audioVideoManagerWillPlayVideo(_ audioVideoManager: GADAudioVideoManager) {
|
func audioVideoManagerWillPlayVideo(_ audioVideoManager: GADAudioVideoManager) {
|
||||||
print("广告将会播放视频")
|
// print("广告将会播放视频")
|
||||||
}
|
}
|
||||||
//广告将会暂停播放所有视频
|
//广告将会暂停播放所有视频
|
||||||
func audioVideoManagerDidPauseAllVideo(_ audioVideoManager: GADAudioVideoManager) {
|
func audioVideoManagerDidPauseAllVideo(_ audioVideoManager: GADAudioVideoManager) {
|
||||||
print("广告暂停播放视频")
|
// print("广告暂停播放视频")
|
||||||
}
|
}
|
||||||
//广告将要播放音频
|
//广告将要播放音频
|
||||||
func audioVideoManagerWillPlayAudio(_ audioVideoManager: GADAudioVideoManager) {
|
func audioVideoManagerWillPlayAudio(_ audioVideoManager: GADAudioVideoManager) {
|
||||||
|
|||||||
@ -251,6 +251,8 @@ class MP_PlayerManager:NSObject{
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying(_ :)), name: .AVPlayerItemDidPlayToEndTime, object: player.currentItem)
|
NotificationCenter.default.addObserver(self, selector: #selector(playerDidFinishPlaying(_ :)), name: .AVPlayerItemDidPlayToEndTime, object: player.currentItem)
|
||||||
//监听用户切换了音乐
|
//监听用户切换了音乐
|
||||||
NotificationCenter.notificationKey.add(observer: self, selector: #selector(userSwitchCurrentVideoAction(_ :)), notificationName: .positive_player_reload)
|
NotificationCenter.notificationKey.add(observer: self, selector: #selector(userSwitchCurrentVideoAction(_ :)), notificationName: .positive_player_reload)
|
||||||
|
//当音频会话被重新激活后
|
||||||
|
NotificationCenter.notificationKey.add(observer: self, selector: #selector(sessionIsActiveAction(_ :)), notificationName: .player_is_continua)
|
||||||
//监听网络状态恢复可用
|
//监听网络状态恢复可用
|
||||||
NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_ :)), notificationName: .net_switch_reachable)
|
NotificationCenter.notificationKey.add(observer: self, selector: #selector(netWorkReachableAction(_ :)), notificationName: .net_switch_reachable)
|
||||||
//监听蓝牙设备的状态
|
//监听蓝牙设备的状态
|
||||||
@ -489,6 +491,18 @@ class MP_PlayerManager:NSObject{
|
|||||||
videoLayer.player = player
|
videoLayer.player = player
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//当音频会话被重新激活后
|
||||||
|
@objc private func sessionIsActiveAction(_ sender:Notification) {
|
||||||
|
//音频会话被重新激活后,检索播放器是否具备当前播放音乐,以及是否处于播放中
|
||||||
|
if let current = loadPlayer?.currentVideo, playState == .Playing, player.timeControlStatus == .paused {
|
||||||
|
//现在应该播放音乐,但是播放器播放状态被某些因素强制暂停了,需要恢复播放
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
[weak self] in
|
||||||
|
self?.player.play()
|
||||||
|
print("播放器播放状态被某些因素强制暂停了,需要恢复播放")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///网络状态恢复正常
|
///网络状态恢复正常
|
||||||
@objc private func netWorkReachableAction(_ sender:Notification) {
|
@objc private func netWorkReachableAction(_ sender:Notification) {
|
||||||
|
|||||||
@ -513,10 +513,11 @@ extension MPPositive_LoveSongsViewController: UITableViewDataSource, UITableView
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
// guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
let currentVideo = isSearchStyle ? searchSongs[indexPath.row]:showSongs[indexPath.row]
|
||||||
// MP_HUD.text("Bad connection~".localizableString(), delay: 2.0, completion: nil)
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
// return
|
playOfflineSongs(currentVideo.collectionSong.videoId ?? "")
|
||||||
// }
|
return
|
||||||
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("Love Song")
|
MP_AnalyticsManager.shared.song_clickAction("Love Song")
|
||||||
//优先清除数据
|
//优先清除数据
|
||||||
MP_PlayerManager.shared.loadPlayer = nil
|
MP_PlayerManager.shared.loadPlayer = nil
|
||||||
@ -537,7 +538,6 @@ extension MPPositive_LoveSongsViewController: UITableViewDataSource, UITableView
|
|||||||
item.relatedID = song.collectionSong.relatedID
|
item.relatedID = song.collectionSong.relatedID
|
||||||
array.append(item)
|
array.append(item)
|
||||||
}
|
}
|
||||||
let currentVideo = isSearchStyle ? searchSongs[indexPath.row]:showSongs[indexPath.row]
|
|
||||||
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: currentVideo.collectionSong.videoId ?? "")
|
let lodaViewModel = MPPositive_PlayerLoadViewModel(array, currentVideoId: currentVideo.collectionSong.videoId ?? "")
|
||||||
lodaViewModel.improveData(currentVideo.collectionSong.videoId ?? "")
|
lodaViewModel.improveData(currentVideo.collectionSong.videoId ?? "")
|
||||||
//更改播放器播放类型
|
//更改播放器播放类型
|
||||||
|
|||||||
@ -592,7 +592,7 @@ extension MPPositive_HomeViewController: UITableViewDataSource, UITableViewDeleg
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("Home")
|
MP_AnalyticsManager.shared.song_clickAction("Home")
|
||||||
|
|||||||
@ -249,7 +249,7 @@ class MPPositive_ListShowViewController: MPPositive_BaseViewController, UIViewCo
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self, let item = listOrAlbum.items.first else {return}
|
guard let self = self, let item = listOrAlbum.items.first else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("List")
|
MP_AnalyticsManager.shared.song_clickAction("List")
|
||||||
@ -277,7 +277,7 @@ class MPPositive_ListShowViewController: MPPositive_BaseViewController, UIViewCo
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self, let item = listOrAlbum.items.randomElement() else {return}
|
guard let self = self, let item = listOrAlbum.items.randomElement() else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("List")
|
MP_AnalyticsManager.shared.song_clickAction("List")
|
||||||
@ -394,16 +394,15 @@ extension MPPositive_ListShowViewController: UITableViewDataSource, UITableViewD
|
|||||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self, let item = listOrAlbum?.items[indexPath.row] else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("List")
|
MP_AnalyticsManager.shared.song_clickAction("List")
|
||||||
//弹出播放器
|
//弹出播放器
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
MP_AnalyticsManager.shared.player_b_impAction()
|
MP_AnalyticsManager.shared.player_b_impAction()
|
||||||
let item = listOrAlbum.items[indexPath.row]
|
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? "", clickTrackingParams: item.browseItem.clickTrackingParams){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? "", clickTrackingParams: item.browseItem.clickTrackingParams){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
|||||||
@ -137,9 +137,9 @@ extension MPPositive_MoreContentViewController: UICollectionViewDataSource, UICo
|
|||||||
//单曲/视频跳转
|
//单曲/视频跳转
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self, let item = browseModuleList?.items[indexPath.row] else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("MoreContent")
|
MP_AnalyticsManager.shared.song_clickAction("MoreContent")
|
||||||
@ -148,7 +148,6 @@ extension MPPositive_MoreContentViewController: UICollectionViewDataSource, UICo
|
|||||||
//弹出播放器
|
//弹出播放器
|
||||||
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
|
||||||
MP_AnalyticsManager.shared.player_b_impAction()
|
MP_AnalyticsManager.shared.player_b_impAction()
|
||||||
let item = browseModuleList.items[indexPath.row]
|
|
||||||
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
//触发next请求,优先获取列表全部单曲基础数据(不完善)
|
||||||
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? "", clickTrackingParams: item.browseItem.clickTrackingParams){ [weak self] listSongs in
|
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? "", clickTrackingParams: item.browseItem.clickTrackingParams){ [weak self] listSongs in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
|
|||||||
@ -144,7 +144,7 @@ extension MPPositive_GrideMoodViewController: UITableViewDataSource, UITableView
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("Mood")
|
MP_AnalyticsManager.shared.song_clickAction("Mood")
|
||||||
|
|||||||
@ -273,12 +273,11 @@ extension MPPositive_ArtistShowTypeView:UITableViewDataSource, UITableViewDelega
|
|||||||
if let first = sectionList?.itemViews.first {
|
if let first = sectionList?.itemViews.first {
|
||||||
switch first.browseItem.itemType {
|
switch first.browseItem.itemType {
|
||||||
case .single:
|
case .single:
|
||||||
let item = sectionList.itemViews[indexPath.row]
|
|
||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self, let item = sectionList?.itemViews[indexPath.row] else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("Artist")
|
MP_AnalyticsManager.shared.song_clickAction("Artist")
|
||||||
|
|||||||
@ -166,11 +166,11 @@ extension MPPositive_HomeSinglesTableViewCell:UICollectionViewDataSource, UIColl
|
|||||||
MPPositive_Debouncer.shared.call {
|
MPPositive_Debouncer.shared.call {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard let item = (self.browseViewModel?.items[indexPath.row] ?? self.personlViewModel?.items[indexPath.row]) else {
|
||||||
playOfflineSongs()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
guard let item = (self.browseViewModel?.items[indexPath.row] ?? self.personlViewModel?.items[indexPath.row]) else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.home_b_module_clickAction(item.browseItem.pageType ?? "")
|
MP_AnalyticsManager.shared.home_b_module_clickAction(item.browseItem.pageType ?? "")
|
||||||
|
|||||||
@ -197,7 +197,7 @@ class MPPositive_PersonalisedRecommendationsTableViewCell: UITableViewCell, UIVi
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.home_b_module_clickAction(titleLabel.text ?? "")
|
MP_AnalyticsManager.shared.home_b_module_clickAction(titleLabel.text ?? "")
|
||||||
@ -328,7 +328,7 @@ extension MPPositive_PersonalisedRecommendationsTableViewCell:UICollectionViewDa
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.browseItem.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.home_b_module_clickAction(item.browseItem.pageType ?? "")
|
MP_AnalyticsManager.shared.home_b_module_clickAction(item.browseItem.pageType ?? "")
|
||||||
|
|||||||
@ -76,16 +76,16 @@ class MPPositive_SearchResultPreviewShowView: MPPositive_BaseShowView, JXSegment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func chooseItemClick(_ item:MPPositive_SearchResultItemViewModel) {
|
func chooseItemClick(_ item:MPPositive_SearchResultItemViewModel) {
|
||||||
switch item.item.itemType {
|
switch item.item?.itemType {
|
||||||
case .artist:
|
case .artist:
|
||||||
//用户查看艺术家
|
//用户查看艺术家
|
||||||
let artistVC = MPPositive_ArtistShowViewController(item.item.artistId ?? "", clickTrackingParams: item.item.clickTrackingParams ?? "")
|
let artistVC = MPPositive_ArtistShowViewController(item.item?.artistId ?? "", clickTrackingParams: item.item?.clickTrackingParams ?? "")
|
||||||
if let vc = self.parentController(ofType: MPPositive_SearchResultShowViewController.self) {
|
if let vc = self.parentController(ofType: MPPositive_SearchResultShowViewController.self) {
|
||||||
vc.navigationController?.pushViewController(artistVC, animated: true)
|
vc.navigationController?.pushViewController(artistVC, animated: true)
|
||||||
}
|
}
|
||||||
case .list:
|
case .list:
|
||||||
//列表专辑
|
//列表专辑
|
||||||
let listVC = MPPositive_ListShowViewController(item.item.browseId ?? "", params: "", title: item.title ?? "", subtitle: item.subtitle ?? "", clickTrackingParams: item.item.clickTrackingParams ?? "")
|
let listVC = MPPositive_ListShowViewController(item.item?.browseId ?? "", params: "", title: item.title ?? "", subtitle: item.subtitle ?? "", clickTrackingParams: item.item?.clickTrackingParams ?? "")
|
||||||
if let vc = self.parentController(ofType: MPPositive_SearchResultShowViewController.self) {
|
if let vc = self.parentController(ofType: MPPositive_SearchResultShowViewController.self) {
|
||||||
vc.navigationController?.pushViewController(listVC, animated: true)
|
vc.navigationController?.pushViewController(listVC, animated: true)
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ class MPPositive_SearchResultPreviewShowView: MPPositive_BaseShowView, JXSegment
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.item?.videoId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("Search")
|
MP_AnalyticsManager.shared.song_clickAction("Search")
|
||||||
|
|||||||
@ -45,10 +45,13 @@ class MPPositive_SearchResultTypeShowView: MPPositive_BaseShowView, JXSegmentedL
|
|||||||
sectionList.requestSearchType()
|
sectionList.requestSearchType()
|
||||||
}
|
}
|
||||||
sectionList.completionBlock = {
|
sectionList.completionBlock = {
|
||||||
|
[weak self] in
|
||||||
|
DispatchQueue.main.async {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
self?.tableView.reloadData()
|
self?.tableView.reloadData()
|
||||||
self?.tableView.mj_footer?.endRefreshing()
|
self?.tableView.mj_footer?.endRefreshing()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}else {
|
}else {
|
||||||
tableView.reloadData()
|
tableView.reloadData()
|
||||||
}
|
}
|
||||||
@ -94,7 +97,7 @@ class MPPositive_SearchResultTypeShowView: MPPositive_BaseShowView, JXSegmentedL
|
|||||||
}
|
}
|
||||||
//上拉刷新
|
//上拉刷新
|
||||||
@objc private func footerRefresh() {
|
@objc private func footerRefresh() {
|
||||||
guard sectionList.continuation != nil, sectionList.itct != nil else {
|
guard sectionList?.continuation != nil, sectionList?.itct != nil else {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
@ -102,7 +105,7 @@ class MPPositive_SearchResultTypeShowView: MPPositive_BaseShowView, JXSegmentedL
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sectionList.requestSearchContinuation()
|
sectionList?.requestSearchContinuation()
|
||||||
}
|
}
|
||||||
func chooseItemClick(_ item:MPPositive_SearchResultItemViewModel) {
|
func chooseItemClick(_ item:MPPositive_SearchResultItemViewModel) {
|
||||||
switch item.item.itemType {
|
switch item.item.itemType {
|
||||||
@ -123,7 +126,7 @@ class MPPositive_SearchResultTypeShowView: MPPositive_BaseShowView, JXSegmentedL
|
|||||||
[weak self] in
|
[weak self] in
|
||||||
guard let self = self else {return}
|
guard let self = self else {return}
|
||||||
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
|
||||||
playOfflineSongs()
|
playOfflineSongs(item.item?.browseId ?? "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
MP_AnalyticsManager.shared.song_clickAction("Search")
|
MP_AnalyticsManager.shared.song_clickAction("Search")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user