B面1.1.1 优化以及功能扩展

This commit is contained in:
Mr.zhou 2024-07-12 19:33:23 +08:00
parent 130fefd189
commit d3d3da4f6e
33 changed files with 1640 additions and 317 deletions

View File

@ -232,11 +232,18 @@
CBC2D6F82BFDF3D800E17703 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CBC2D6F72BFDF3D800E17703 /* Assets.xcassets */; };
CBC2D6FB2BFDF3D800E17703 /* Base in Resources */ = {isa = PBXBuildFile; fileRef = CBC2D6FA2BFDF3D800E17703 /* Base */; };
CBC2D7D42BFDF4B900E17703 /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = CBC2D7792BFDF4B900E17703 /* PrivacyInfo.xcprivacy */; };
CBC3F2B22C3E76160075DC74 /* MPPositive_AdModelModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBC3F2B12C3E76160075DC74 /* MPPositive_AdModelModel.swift */; };
CBC81FBA2C3694990028143B /* MPPositive_HomeSinglesTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBC81FB92C3694990028143B /* MPPositive_HomeSinglesTableViewCell.swift */; };
CBC81FBC2C3696230028143B /* MPPositive_HomeSingleCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBC81FBB2C3696230028143B /* MPPositive_HomeSingleCollectionViewCell.swift */; };
CBD344DA2C3FACB30095F18F /* MPPositive_JsonGenres.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBD344D92C3FACB30095F18F /* MPPositive_JsonGenres.swift */; };
CBD344DC2C3FCA270095F18F /* MPPositive_GridModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBD344DB2C3FCA270095F18F /* MPPositive_GridModel.swift */; };
CBD344DE2C3FD8230095F18F /* MPPositive_GridViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBD344DD2C3FD8230095F18F /* MPPositive_GridViewModel.swift */; };
CBD4570D2C2EC38400CE766D /* AppTrackingTransparency.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CBD4570C2C2EC38400CE766D /* AppTrackingTransparency.framework */; };
CBD5CAFD2C3BE9A90001E315 /* MP_MarQueeLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBD5CAFC2C3BE9A90001E315 /* MP_MarQueeLabel.swift */; };
CBDAC60E2C2BE1B6008B8D34 /* MPPositive_ChooseNewPlayListTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDAC60D2C2BE1B6008B8D34 /* MPPositive_ChooseNewPlayListTableViewCell.swift */; };
CBDBDDF22C40C40900767F0B /* MPPositive_GridLoadViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF12C40C40900767F0B /* MPPositive_GridLoadViewModel.swift */; };
CBDBDDF42C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */; };
CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */; };
CBF3AEDA2C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */; };
/* End PBXBuildFile section */
@ -465,11 +472,18 @@
CBC2D6FA2BFDF3D800E17703 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
CBC2D6FC2BFDF3D800E17703 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
CBC2D7792BFDF4B900E17703 /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
CBC3F2B12C3E76160075DC74 /* MPPositive_AdModelModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_AdModelModel.swift; sourceTree = "<group>"; };
CBC81FB92C3694990028143B /* MPPositive_HomeSinglesTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_HomeSinglesTableViewCell.swift; sourceTree = "<group>"; };
CBC81FBB2C3696230028143B /* MPPositive_HomeSingleCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_HomeSingleCollectionViewCell.swift; sourceTree = "<group>"; };
CBD344D92C3FACB30095F18F /* MPPositive_JsonGenres.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_JsonGenres.swift; sourceTree = "<group>"; };
CBD344DB2C3FCA270095F18F /* MPPositive_GridModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GridModel.swift; sourceTree = "<group>"; };
CBD344DD2C3FD8230095F18F /* MPPositive_GridViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GridViewModel.swift; sourceTree = "<group>"; };
CBD4570C2C2EC38400CE766D /* AppTrackingTransparency.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppTrackingTransparency.framework; path = System/Library/Frameworks/AppTrackingTransparency.framework; sourceTree = SDKROOT; };
CBD5CAFC2C3BE9A90001E315 /* MP_MarQueeLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MP_MarQueeLabel.swift; sourceTree = "<group>"; };
CBDAC60D2C2BE1B6008B8D34 /* MPPositive_ChooseNewPlayListTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_ChooseNewPlayListTableViewCell.swift; sourceTree = "<group>"; };
CBDBDDF12C40C40900767F0B /* MPPositive_GridLoadViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GridLoadViewModel.swift; sourceTree = "<group>"; };
CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_SearchGrideCollectionViewCell.swift; sourceTree = "<group>"; };
CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_GrideMoodViewController.swift; sourceTree = "<group>"; };
CBF3AED92C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MPPositive_PlayListsShowTypeView.swift; sourceTree = "<group>"; };
EE70E1FE424F9A64CCD389DD /* Pods-relax.offline.mp3.music.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-relax.offline.mp3.music.debug.xcconfig"; path = "Target Support Files/Pods-relax.offline.mp3.music/Pods-relax.offline.mp3.music.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -686,6 +700,7 @@
children = (
CBAFCA322C0A10500054500E /* MPPositive_JsonBrowse.swift */,
CBBAF8CC2C339CF200B3C838 /* MPPositive_JsonCharts.swift */,
CBD344D92C3FACB30095F18F /* MPPositive_JsonGenres.swift */,
CBAFCA302C0A10500054500E /* MPPositive_JsonArtist.swift */,
CBAFCA312C0A10500054500E /* MPPositive_JsonArtistMore.swift */,
CBAFCA332C0A10500054500E /* MPPositive_JsonListAlbum.swift */,
@ -705,7 +720,9 @@
isa = PBXGroup;
children = (
CBAFCA3D2C0A10500054500E /* MPPositive_ArtistHeaderModel.swift */,
CBC3F2B12C3E76160075DC74 /* MPPositive_AdModelModel.swift */,
CBAFCA3E2C0A10500054500E /* MPPositive_BrowseItemModel.swift */,
CBD344DB2C3FCA270095F18F /* MPPositive_GridModel.swift */,
CBAFCA3F2C0A10500054500E /* MPPositive_CollectionArtistModel.swift */,
CBAFCA402C0A10500054500E /* MPPositive_CollectionListModel.swift */,
CBAFCA412C0A10500054500E /* MPPositive_CollectionSongModel.swift */,
@ -727,6 +744,7 @@
CBAFCA492C0A10500054500E /* MPPositive_ArtistViewModel.swift */,
CBAFCA4A2C0A10500054500E /* MPPositive_BrowseItemViewModel.swift */,
CBAFCA4B2C0A10500054500E /* MPPositive_BrowseModuleListViewModel.swift */,
CBD344DD2C3FD8230095F18F /* MPPositive_GridViewModel.swift */,
CBAFCA4C2C0A10500054500E /* MPPositive_CollectionArtistViewModel.swift */,
CBAFCA4D2C0A10500054500E /* MPPositive_CollectionListViewModel.swift */,
CBAFCA4E2C0A10500054500E /* MPPositive_CollectionSongViewModel.swift */,
@ -751,6 +769,7 @@
CBAFCA5A2C0A10500054500E /* MPPositive_PlayerLoadViewModel.swift */,
CBAFCA5B2C0A10500054500E /* MPPositive_RecommendLoadViewModel.swift */,
CBAFCA5C2C0A10500054500E /* MPPositive_SearchResultsLoadViewModel.swift */,
CBDBDDF12C40C40900767F0B /* MPPositive_GridLoadViewModel.swift */,
);
path = LoadViewModels;
sourceTree = "<group>";
@ -825,6 +844,7 @@
isa = PBXGroup;
children = (
CBAFCA752C0A10500054500E /* MPPositive_SearchViewController.swift */,
CBDBDDF52C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift */,
CBAFCA742C0A10500054500E /* MPPositive_SearchResultShowViewController.swift */,
);
path = "Search搜索页";
@ -909,6 +929,7 @@
isa = PBXGroup;
children = (
CBAFCA9E2C0A10500054500E /* MPPositive_SearchTagCollectionViewCell.swift */,
CBDBDDF32C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift */,
CBAFCA9D2C0A10500054500E /* MPPositive_SearchSuggestionsView.swift */,
CBAFCA9A2C0A10500054500E /* MPPositive_SearchResultsShowView.swift */,
CBAFCA982C0A10500054500E /* MPPositive_SearchResultPreviewShowView.swift */,
@ -1353,6 +1374,7 @@
CBAFCB652C0A10500054500E /* MPPositive_HomeListThirdCollectionViewCell.swift in Sources */,
CBAFCB472C0A10500054500E /* MPPositive_LoveArtistsViewController.swift in Sources */,
CBAFCAF62C0A10500054500E /* InstanceFromNib.swift in Sources */,
CBD344DE2C3FD8230095F18F /* MPPositive_GridViewModel.swift in Sources */,
CBAFCB622C0A10500054500E /* MPPositive_HomeListFirstCollectionViewCell.swift in Sources */,
CBAFCB112C0A10500054500E /* MP_PlayerManager.swift in Sources */,
CBAFCB582C0A10500054500E /* MPPositive_LibraryTableViewCell.swift in Sources */,
@ -1365,12 +1387,14 @@
CBAFCB632C0A10500054500E /* MPPositive_HomeListFourthCollectionViewCell.swift in Sources */,
CB1E3B682C23E09100071DEA /* MPPositive_CustomVideoModel.swift in Sources */,
CBAFCB3E2C0A10500054500E /* MPPositive_PlayerLoadViewModel.swift in Sources */,
CBD344DC2C3FCA270095F18F /* MPPositive_GridModel.swift in Sources */,
CBC81FBA2C3694990028143B /* MPPositive_HomeSinglesTableViewCell.swift in Sources */,
CBAFCB252C0A10500054500E /* MPPositive_CollectionArtistModel.swift in Sources */,
CBAFCB702C0A10500054500E /* MPPositive_SearchResultShowTableViewCell.swift in Sources */,
CBAFCB662C0A10500054500E /* MPPositive_HomeShowTableViewCell.swift in Sources */,
CBAFCB352C0A10500054500E /* MPPositive_ListAlbumListViewModel.swift in Sources */,
CBAFCB7C2C0A10500054500E /* MPSideA_NavigationController.swift in Sources */,
CBDBDDF62C40FFC600767F0B /* MPPositive_GrideMoodViewController.swift in Sources */,
CBAFCB932C0A10500054500E /* MPSideA_PlayerViewController.swift in Sources */,
CBAFCB512C0A10500054500E /* MPPositive_SearchResultShowViewController.swift in Sources */,
CBAFCB4C2C0A10500054500E /* MPPositive_ListShowViewController.swift in Sources */,
@ -1441,12 +1465,14 @@
CBAFCB832C0A10500054500E /* MPSideA_DeleteViewController.swift in Sources */,
CBAFCAF22C0A10500054500E /* String.swift in Sources */,
CBAFCB0E2C0A10500054500E /* MP_HUD.swift in Sources */,
CBD344DA2C3FACB30095F18F /* MPPositive_JsonGenres.swift in Sources */,
CB0033F02C290AC200B18FD3 /* MPPositive_CustomPlayListViewModel.swift in Sources */,
CBAFCB4B2C0A10500054500E /* MPPositive_HomeViewController.swift in Sources */,
CBAFCB2A2C0A10500054500E /* MPPositive_SearchSuggestionItemModel.swift in Sources */,
CBAFCB372C0A10500054500E /* MPPositive_RecommendListViewModel.swift in Sources */,
CBAFCB282C0A10500054500E /* MPPositive_DownloadItemModel.swift in Sources */,
CBAFCB152C0A10500054500E /* MPSideA_MediaCenterManager.swift in Sources */,
CBDBDDF22C40C40900767F0B /* MPPositive_GridLoadViewModel.swift in Sources */,
CBAFCAEB2C0A10500054500E /* relax.offline.mp3.xcdatamodeld in Sources */,
CBAFCB192C0A10500054500E /* MPPositive_JsonBrowse.swift in Sources */,
CBAFCB912C0A10500054500E /* MPSideA_HomeViewController.swift in Sources */,
@ -1468,6 +1494,7 @@
CBAFCB442C0A10500054500E /* MPPositive_PresentationController.swift in Sources */,
CB0968752C2121410045E55B /* GADTSmallTemplateView.m in Sources */,
CBAFCB9B2C0A10500054500E /* MPSideA_CenterTableViewCell.swift in Sources */,
CBC3F2B22C3E76160075DC74 /* MPPositive_AdModelModel.swift in Sources */,
CBAFCB412C0A10500054500E /* MPPositive_BaseViewController.swift in Sources */,
CBAFCB4E2C0A10500054500E /* MPPositive_PlayerListShowViewController.swift in Sources */,
CBAFCB8B2C0A10500054500E /* MPSideA_ServiceViewController.swift in Sources */,
@ -1499,6 +1526,7 @@
CBAFCB532C0A10500054500E /* MPPositive_BottomShowView.swift in Sources */,
CBF3AEDA2C255B1200947AFC /* MPPositive_PlayListsShowTypeView.swift in Sources */,
CBC2D6EC2BFDF3D700E17703 /* AppDelegate.swift in Sources */,
CBDBDDF42C40D03F00767F0B /* MPPositive_SearchGrideCollectionViewCell.swift in Sources */,
CBAFCB322C0A10500054500E /* MPPositive_CollectionListViewModel.swift in Sources */,
CBC81FBC2C3696230028143B /* MPPositive_HomeSingleCollectionViewCell.swift in Sources */,
CBAFCB812C0A10500054500E /* MPSideA_CenterViewController.swift in Sources */,

View File

@ -25,6 +25,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private var backgroundEntryTime:Date?
//B
private var positiceVC:MPPositive_TabBarController!
//
private let notificationHandler = NotificationHandler()
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//
UNUserNotificationCenter.current()
@ -34,8 +36,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
print("Users are not allowed to be notified of messages.")
}
}
//
UNUserNotificationCenter.current().delegate = notificationHandler
//广ID
coreAdMosIDs()
coreDefaultValues()
ActiveDaysCalculation()
//FireBase
FirebaseApp.configure()
@ -82,56 +86,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
//
UIApplication.shared.beginReceivingRemoteControlEvents()
}
//
func coreAdMosIDs() {
if UserDefaults.standard.string(forKey: "OpenICEID") == nil {
print("第一次启动添加广告ID")
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/5575463023", forKey: "OpenICEID")
}
if UserDefaults.standard.string(forKey: "OpenHOSTID") == nil {
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/5575463023", forKey: "OpenHOSTID")
}
if UserDefaults.standard.string(forKey: "SearchINSERTID") == nil {
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/4411468910", forKey: "SearchINSERTID")
}
if UserDefaults.standard.string(forKey: "SearchNATIVEID") == nil {
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/3986624511", forKey: "SearchNATIVEID")
}
if UserDefaults.standard.string(forKey: "PlayerINSERTID") == nil {
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/4411468910", forKey: "PlayerINSERTID")
}
if UserDefaults.standard.string(forKey: "SwitchINSERTID") == nil {
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/4411468910", forKey: "SwitchINSERTID")
}
if UserDefaults.standard.string(forKey: "LoadINSERTID") == nil {
//广ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/4411468910", forKey: "LoadINSERTID")
}
if UserDefaults.standard.string(forKey: "LibraryINSERTID") == nil {
//ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/4411468910", forKey: "LibraryINSERTID")
}
if UserDefaults.standard.string(forKey: "LibraryNATIVEID") == nil {
//ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/3986624511", forKey: "LibraryNATIVEID")
}
if UserDefaults.standard.string(forKey: "GlobalINSERTID") == nil {
//ID
UserDefaults.standard.set("ca-app-pub-3940256099942544/4411468910", forKey: "GlobalINSERTID")
}
if UserDefaults.standard.string(forKey: "ClientVersion") == nil {
UserDefaults.standard.set("1.20240618.01.00", forKey: "ClientVersion")
}
if UserDefaults.standard.string(forKey: "PlayerVersion") == nil {
UserDefaults.standard.set("6.18.1", forKey: "PlayerVersion")
}
}
//
private func ActiveDaysCalculation() {
//
@ -279,6 +233,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
}
func adManagerDidShowInterstitial() {
window?.rootViewController?.setNeedsStatusBarAppearanceUpdate()
}
}
///访appDelegate
let accessAppdelegate = ( UIApplication.shared.delegate as! AppDelegate)
///
class NotificationHandler: NSObject, UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler:
@escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert, .sound, .badge])
// options completionHandler:
// completionHandler([])
}
}

View File

@ -12,7 +12,7 @@
<string>fetch</string>
</array>
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<string>ca-app-pub-1371732277241593~3881310073</string>
<key>SKAdNetworkItems</key>
<array>
<dict>

View File

@ -17,7 +17,7 @@ class MP_BaseViewController: UIViewController {
// MP_NetWorkManager.shared.requestStatusToYouTube()
//
// NotificationCenter.default.addObserver(self, selector: #selector(appWillEnterForegroundAction), name:UIApplication.willEnterForegroundNotification, object: nil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
@ -39,7 +39,7 @@ class MP_BaseViewController: UIViewController {
UserDefaults.standard.set(true, forKey: "isNetWorkUsage")
}
// private func triggerLocalNetworkPrivacyAlert() {
// let sock4 = socket(AF_INET, SOCK_DGRAM, 0)
// guard sock4 >= 0 else { return }

View File

@ -30,7 +30,7 @@
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Five-Star Review" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ChX-fu-2sj">
<rect key="frame" x="59" y="90" width="164.5" height="24"/>
<fontDescription key="fontDescription" type="system" weight="heavy" pointSize="20"/>
<color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="lt'd be awesomeif you wrote us a 5 star review" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="iz5-RV-Ild">

View File

@ -102,6 +102,7 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
}else {
//
timer.isPaused = true
MP_AnalyticsManager.shared.launch_progress_endAction()
//广
if adShowBlock != nil {
adShowBlock!()
@ -129,27 +130,11 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
}
//广
MP_AdMobManager.shared.loadMoreAdMobs()
MP_AdMobManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] ad in
MP_AdMobManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad, isOpen) in
guard let self = self else {return}
//广
adShowBlock = {
DispatchQueue.main.async {
//
MP_AdMobManager.shared.setInterstitialSwitch(true)
MP_AdMobManager.shared.isShowingOpenAd = true
//
ad.fullScreenContentDelegate = self
do{
try ad.canPresent(fromRootViewController: self)
ad.present(fromRootViewController: self)
}catch{
print("开屏广告展示失败,失败原因:\(error)")
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
}
}
self.adPresent(ad: ad, isOpen: isOpen)
}
}
//B
@ -180,27 +165,11 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
if open {
//ID广
MP_AdMobManager.shared.loadMoreAdMobs()
MP_AdMobManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] ad in
MP_AdMobManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad,isOpen) in
guard let self = self else {return}
//广
adShowBlock = {
DispatchQueue.main.async {
//
MP_AdMobManager.shared.setInterstitialSwitch(true)
MP_AdMobManager.shared.isShowingOpenAd = true
//
ad.fullScreenContentDelegate = self
do{
try ad.canPresent(fromRootViewController: self)
ad.present(fromRootViewController: self)
}catch{
print("开屏广告展示失败,失败原因:\(error)")
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
}
}
self.adPresent(ad: ad, isOpen: isOpen)
}
}
//ip
@ -278,27 +247,11 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
}else {
//ID广
MP_AdMobManager.shared.loadMoreAdMobs()
MP_AdMobManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] ad in
MP_AdMobManager.shared.showOpenAdIfAvailable(.ICE) { [weak self] (ad,isOpen) in
guard let self = self else {return}
//广
adShowBlock = {
DispatchQueue.main.async {
//
MP_AdMobManager.shared.setInterstitialSwitch(true)
MP_AdMobManager.shared.isShowingOpenAd = true
//
ad.fullScreenContentDelegate = self
do{
try ad.canPresent(fromRootViewController: self)
ad.present(fromRootViewController: self)
}catch{
print("开屏广告展示失败,失败原因:\(error)")
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
}
}
self.adPresent(ad: ad, isOpen: isOpen)
}
}
print("ALog")
@ -330,13 +283,52 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
}
}
}
//广
private func adPresent(ad: GADFullScreenPresentingAd, isOpen:Bool) {
DispatchQueue.main.async {
//
MP_AdMobManager.shared.setInterstitialSwitch(true)
MP_AdMobManager.shared.isShowingOpenAd = true
if isOpen {
let new = ad as? GADAppOpenAd
//
new?.fullScreenContentDelegate = self
do{
try new?.canPresent(fromRootViewController: self)
new?.present(fromRootViewController: self)
}catch{
print("开屏广告展示失败,失败原因:\(error)")
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
}
}else {
let new = ad as? GADInterstitialAd
//
new?.fullScreenContentDelegate = self
do{
try new?.canPresent(fromRootViewController: self)
new?.present(fromRootViewController: self)
}catch{
print("开屏广告展示失败,失败原因:\(error)")
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
}
}
}
}
//MARK: - 广 GADFullScreenContentDelegate
//广
func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = true
MP_AnalyticsManager.shared.cold_ads_showSuccessAction()
}
//广
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = false
//广广
if switchBlock != nil {
switchBlock!()
@ -344,10 +336,15 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
//广
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
// UIApplication.shared.isStatusBarHidden = false
MP_AnalyticsManager.shared.cold_ads_showFailureAction(error.localizedDescription)
//广广
if switchBlock != nil {
@ -356,6 +353,10 @@ class MP_LunchViewController: UIViewController, GADFullScreenContentDelegate {
if MP_AdMobManager.shared.completeOpenAdBlock != nil {
MP_AdMobManager.shared.completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
}

View File

@ -8,6 +8,18 @@
import Foundation
//MARK: - Color
extension UIColor {
convenience init?(string: UInt64, alpha: CGFloat = 1.0) {
// 1. 8
let hexValue = string >> 8
// 2. 8 RGB
let red = CGFloat((hexValue >> 16) & 0xFF) / 255.0
let green = CGFloat((hexValue >> 8) & 0xFF) / 255.0
let blue = CGFloat((hexValue) & 0xFF) / 255.0
// 3. 使 UIColor
self.init(red: red, green: green, blue: blue, alpha: alpha)
}
/// String -> UIColor
convenience init(hex: String,alpha:CGFloat? = 1) {
let string = hex.trimmingCharacters(in: .whitespacesAndNewlines)

View File

@ -113,6 +113,8 @@ extension NotificationCenter{
case download_progress_source
///b
case dowload_end_source
///b
case search_gride_reload
}
}
}

View File

@ -11,6 +11,7 @@ import AppTrackingTransparency
import AdSupport
import MessageUI
import MarqueeLabel
import UserNotifications
@_exported import JXSegmentedView
@_exported import JXPagingView
//JXPagingListContainerViewextensionJXSegmentedViewListContainer
@ -70,6 +71,135 @@ let privacyUrl:URL = .init(string: "https://musiclax.mystrikingly.com/privacy")!
let serviceUrl:URL = .init(string: "https://musiclax.mystrikingly.com/terms")!
//MARK: -
//
func coreDefaultValues() {
if UserDefaults.standard.object(forKey: "OpenICEID") == nil {
print("第一次启动添加广告ID")
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/2126815630", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/8500652294", ad: "AdMob", type: .Open),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/4561407280", ad: "AdMob", type: .Insert),
.init(level: 0, identifier: "ca-app-pub-1371732277241593/1926543650", ad: "AdMob", type: .Open)]) {
//广ID
UserDefaults.standard.set(array, forKey: "OpenICEID")
}
}
if UserDefaults.standard.object(forKey: "OpenHOSTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/9262752398", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/6536516707", ad: "AdMob", type: .Open),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/9239018894", ad: "AdMob", type: .Insert),
.init(level: 0, identifier: "ca-app-pub-1371732277241593/3299335073", ad: "AdMob", type: .Open)]) {
//广ID
UserDefaults.standard.set(array, forKey: "OpenHOSTID")
}
}
if UserDefaults.standard.object(forKey: "SearchINSERTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/5323507386", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/6877962328", ad: "AdMob", type: .Insert),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/4251798981", ad: "AdMob", type: .Insert),
.init(level: 0, identifier: "ca-app-pub-1371732277241593/8622500865", ad: "AdMob", type: .Insert)]) {
//广ID
UserDefaults.standard.set(array, forKey: "SearchINSERTID")
}
}
if UserDefaults.standard.object(forKey: "SearchNATIVEID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/5674216970", ad: "AdMob", type: .Native)]) {
//广ID
UserDefaults.standard.set(array, forKey: "SearchNATIVEID")
}
}
if UserDefaults.standard.object(forKey: "PlayerINSERTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/9569874154", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/8256792481", ad: "AdMob", type: .Insert),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/8031261896", ad: "AdMob", type: .Insert),
.init(level: 0, identifier: "ca-app-pub-1371732277241593/4182802216", ad: "AdMob", type: .Insert)]) {
//广ID
UserDefaults.standard.set(array, forKey: "PlayerINSERTID")
}
}
if UserDefaults.standard.object(forKey: "SwitchINSERTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/4990165586", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/5247485769", ad: "AdMob", type: .Insert),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/1050920574", ad: "AdMob", type: .Insert),
.init(level: 0, identifier: "ca-app-pub-1371732277241593/8439981117", ad: "AdMob", type: .Insert)]) {
//广ID
UserDefaults.standard.set(array, forKey: "SwitchINSERTID")
}
}
if UserDefaults.standard.object(forKey: "LoadINSERTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/4335559460", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/2398278378", ad: "AdMob", type: .Insert),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/3107763383", ad: "AdMob", type: .Insert)]) {
//广ID
UserDefaults.standard.set(array, forKey: "LoadINSERTID")
}
}
if UserDefaults.standard.object(forKey: "LibraryINSERTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/4607022200", ad: "AdMob", type: .Insert),
.init(level: 2, identifier: "ca-app-pub-1371732277241593/3104538158", ad: "AdMob", type: .Insert),
.init(level: 1, identifier: "ca-app-pub-1371732277241593/8931897131", ad: "AdMob", type: .Insert),
.init(level: 0, identifier: "ca-app-pub-1371732277241593/5298812459", ad: "AdMob", type: .Insert)]) {
//广ID
UserDefaults.standard.set(array, forKey: "LibraryINSERTID")
}
}
if UserDefaults.standard.object(forKey: "LibraryNATIVEID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/4683255855", ad: "AdMob", type: .Native)]) {
//广ID
UserDefaults.standard.set(array, forKey: "LibraryNATIVEID")
}
}
if UserDefaults.standard.object(forKey: "GlobalINSERTID") == nil {
if let array = coreAdModelforJson([.init(level: 3, identifier: "ca-app-pub-1371732277241593/9449223728", ad: "AdMob", type: .Insert)]) {
//广ID
UserDefaults.standard.set(array, forKey: "GlobalINSERTID")
}
}
//
if UserDefaults.standard.string(forKey: "ClientVersion") == nil {
UserDefaults.standard.set("1.20240618.01.00", forKey: "ClientVersion")
}
if UserDefaults.standard.string(forKey: "PlayerVersion") == nil {
UserDefaults.standard.set("6.18.1", forKey: "PlayerVersion")
}
if UserDefaults.standard.object(forKey: "NotificationBodyTexts") == nil {
UserDefaults.standard.set(["✅ Enjoy your favorite offline music.Your new playlist is ready! Enjoy your favorite offline music.",
"🕛 Now is the time to enjoy non-stop music!",
"🚀 Boost your day with new offline music selections!",
"🎵 Ready for a music adventure? Download latest tracks for offline fun!",
"❤️ Your favorite songs are available for offline playback now.",
"😍 New recommendations tailored for you. Add them to your library.",
"👉 Touch the music journey, start now",
"🔥 Summer hits ready for download. Enjoy offline!",
"🙌 Your music, your way. 💎💎💎",
"💡 Discover today's music,enjoy the moment!"
], forKey: "NotificationBodyTexts")
}
}
///广Data
func coreAdModelforJson(_ array:[MPPositive_AdModelModel]) -> Data? {
guard array.isEmpty != true else {return nil}
do{
let jsonData = try JSONEncoder().encode(array)
return jsonData
}catch {
//
print("用户默认广告配置设置失败,失败原因:\(error.localizedDescription)")
return nil
}
}
///data广
func jsonforCoreAdModel(_ data:Data) -> [MPPositive_AdModelModel]? {
do{
let array:[MPPositive_AdModelModel] = try JSONDecoder().decode([MPPositive_AdModelModel].self, from: data)
return array
}catch{
//
print("用户默认广告配置设置失败,失败原因:\(error.localizedDescription)")
return nil
}
}
///
typealias ActionBlock = () -> Void?
///A
@ -246,7 +376,7 @@ func saveLoadVideoItem(_ song:MPPositive_SongItemModel, completion:(() -> Void)?
item.videoId = song.videoId
item.relatedID = song.relatedID
//
MPPositive_DownloadItemModel.save(true)
MPPositive_DownloadItemModel.save()
completion?()
DispatchQueue.main.async {
//
@ -257,3 +387,51 @@ func saveLoadVideoItem(_ song:MPPositive_SongItemModel, completion:(() -> Void)?
}
}
}
///
func scheduleDailyNotifications() {
UNUserNotificationCenter.current().getNotificationSettings {
settings in
switch settings.authorizationStatus {
case .authorized:
DispatchQueue.main.async {
guard let texts = UserDefaults.standard.object(forKey: "NotificationBodyTexts") as? [String], texts.isEmpty != true else {return}
//
let center = UNUserNotificationCenter.current()
//body
let firstContent = UNMutableNotificationContent()
firstContent.title = ""
firstContent.body = texts.randomElement() ?? ""
firstContent.sound = UNNotificationSound.default
//-10
var firstDateComponents = DateComponents()
firstDateComponents.hour = 10
let firstTrigger = UNCalendarNotificationTrigger(dateMatching: firstDateComponents, repeats: true)
//body
let secondContent = UNMutableNotificationContent()
secondContent.title = ""
secondContent.body = texts.randomElement() ?? ""
secondContent.sound = UNNotificationSound.default
//-2
var secondDateComponents = DateComponents()
secondDateComponents.hour = 14
let secondTrigger = UNCalendarNotificationTrigger(dateMatching: secondDateComponents, repeats: true)
//
let firstRequest = UNNotificationRequest(identifier: "relax.offline.mp3.morningNotification", content: firstContent, trigger: firstTrigger)
let secondRequest = UNNotificationRequest(identifier: "relax.offline.mp3.afternoonNotification", content: secondContent, trigger: secondTrigger)
//
center.add(firstRequest) { error in
if let error = error {
print("更新上午通知失败,失败原因: \(error)")
}
}
center.add(secondRequest) { error in
if let error = error {
print("更新下午通知失败,失败原因: \(error)")
}
}
}
default:
break
}
}
}

View File

@ -79,7 +79,22 @@ extension MP_CoreDataOperationDelegate {
/// ()
/// - Parameter completion: 线
static func fetchAll(completion: @escaping ([ManagedObject]) -> Void) {
fetch(predicate: nil, completion: completion)
let fetchRequest = ManagedObject.fetchRequest
// 使 perform
MP_CoreDataHandlerManager.shared.context.perform {
do {
let results = try MP_CoreDataHandlerManager.shared.context.fetch(fetchRequest)
// 线 completion
DispatchQueue.main.async {
completion(results)
}
} catch {
print("Failed to fetch \(ManagedObject.entityName): \(error)")
DispatchQueue.main.async {
completion([]) //
}
}
}
}
///
/// - Parameter object:
@ -93,6 +108,10 @@ extension MP_CoreDataOperationDelegate {
///
static func save(_ isBackTheard:Bool = false) {
MP_CoreDataHandlerManager.shared.saveContext()
if isBackTheard {
MP_CoreDataHandlerManager.shared.saveContextInBackground()
}else {
MP_CoreDataHandlerManager.shared.saveContext()
}
}
}

View File

@ -14,7 +14,7 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
static let shared = MP_AdMobManager()
private let sharedInstance = GADMobileAds.sharedInstance()
///广
private var openAdStatus:Bool = false
private var openAdStatus:Bool = true
///广(50)
private let expirationTime:TimeInterval = 3000
@ -64,6 +64,7 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
guard let self = self, interstitialSwitch == true else {return}
//广
appOpenAd = nil
appInterstitialAd = nil
isShowingOpenAd = false
loadOpenAdTime = nil
//广
@ -216,36 +217,36 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
///ID
func reloadAdMobIDs() {
//广ID
if let str = UserDefaults.standard.string(forKey: "OpenICEID") {
if let data = UserDefaults.standard.object(forKey: "OpenICEID") as? Data, let array = jsonforCoreAdModel(data) {
print("成功提取ID")
OpenICEID = str
OpenICEID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "OpenHOSTID") {
OpenHOSTID = str
if let data = UserDefaults.standard.object(forKey: "OpenHOSTID") as? Data, let array = jsonforCoreAdModel(data) {
OpenHOSTID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "SearchINSERTID") {
SearchINSERTID = str
if let data = UserDefaults.standard.object(forKey: "SearchINSERTID") as? Data, let array = jsonforCoreAdModel(data) {
SearchINSERTID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "SearchNATIVEID") {
SearchNATIVEID = str
if let data = UserDefaults.standard.object(forKey: "SearchNATIVEID") as? Data, let array = jsonforCoreAdModel(data) {
SearchNATIVEID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "PlayerINSERTID") {
PlayerINSERTID = str
if let data = UserDefaults.standard.object(forKey: "PlayerINSERTID") as? Data, let array = jsonforCoreAdModel(data) {
PlayerINSERTID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "SwitchINSERTID") {
SwitchINSERTID = str
if let data = UserDefaults.standard.object(forKey: "SwitchINSERTID") as? Data, let array = jsonforCoreAdModel(data) {
SwitchINSERTID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "LoadINSERTID") {
LoadINSERTID = str
if let data = UserDefaults.standard.object(forKey: "LoadINSERTID") as? Data, let array = jsonforCoreAdModel(data) {
LoadINSERTID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "LibraryINSERTID") {
LibraryINSERTID = str
if let data = UserDefaults.standard.object(forKey: "LibraryINSERTID") as? Data, let array = jsonforCoreAdModel(data) {
LibraryINSERTID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "LibraryNATIVEID") {
LibraryNATIVEID = str
if let data = UserDefaults.standard.object(forKey: "LibraryNATIVEID") as? Data, let array = jsonforCoreAdModel(data) {
LibraryNATIVEID = array.sorted(by: {$0.level > $1.level})
}
if let str = UserDefaults.standard.string(forKey: "GlobalINSERTID") {
GlobalINSERTID = str
if let data = UserDefaults.standard.object(forKey: "GlobalINSERTID") as? Data, let array = jsonforCoreAdModel(data) {
GlobalINSERTID = array.sorted(by: {$0.level > $1.level})
}
}
///广
@ -318,9 +319,9 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
//MARK: -
//广ID
private var OpenICEID:String!
private var OpenICEID:[MPPositive_AdModelModel] = []
//广ID
private var OpenHOSTID:String!
private var OpenHOSTID:[MPPositive_AdModelModel] = []
//广
enum OpenType:Int {
//
@ -336,8 +337,10 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
}
}
}
//广
//广
private var appOpenAd:GADAppOpenAd?
//广
private var appInterstitialAd:GADInterstitialAd?
//广
private var isLoadingOpenAd:Bool = false
//广
@ -358,8 +361,26 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
var completeOpenAdBlock:(() -> Void)?
///广
func loadOpenAd(_ type:OpenType,completion: @escaping (Bool) -> Void) {
func loadOpenAd(_ type:OpenType, level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
//id
var item:MPPositive_AdModelModel
switch type {
case .ICE:
guard level <= (OpenICEID.count-1) else {
print("冷启动广告组已经全部加载失败,停止继续加载")
completion(false)
return
}
item = OpenICEID[level]
case .HOST:
guard level <= (OpenHOSTID.count-1) else {
print("热启动广告组已经全部加载失败,停止继续加载")
completion(false)
return
}
item = OpenHOSTID[level]
}
// 广广
if isLoadingOpenAd || isOpenAdAvailable() {
// 广广
@ -367,35 +388,54 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingOpenAd = true
var UUID:String
switch type {
case .ICE:
UUID = OpenICEID
case .HOST:
UUID = OpenHOSTID
}
// 使 GADAppOpenAd load completion handler广
GADAppOpenAd.load(withAdUnitID: UUID, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载开屏广告失败,失败原因: \(error.localizedDescription)")
self.isLoadingOpenAd = false
completion(false)
} else {
self.appOpenAd = ad
self.isLoadingOpenAd = false
//
self.appOpenAd?.fullScreenContentDelegate = self
//
self.loadOpenAdTime = Date()
completion(true)
//广
if item.type == .Open {
//广
// 使 GADAppOpenAd load completion handler广
GADAppOpenAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载开屏广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingOpenAd = false
loadOpenAd(type, level: level+1, completion: completion)
} else {
self.appOpenAd = ad
self.isLoadingOpenAd = false
//
self.appOpenAd?.fullScreenContentDelegate = self
//
self.loadOpenAdTime = Date()
completion(true)
}
}
}
}else if item.type == .Insert {
//广
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载开屏广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingOpenAd = false
loadOpenAd(type, level: level+1, completion: completion)
} else {
self.appInterstitialAd = ad
self.isLoadingOpenAd = false
//
self.appInterstitialAd?.fullScreenContentDelegate = self
//
self.loadOpenAdTime = Date()
completion(true)
}
}
}
}else {
completion(false)
}
}
///广
func showOpenAdIfAvailable(_ type:OpenType, completion:((GADAppOpenAd) -> Void)?) {
func showOpenAdIfAvailable(_ type:OpenType, completion:((_ T:GADFullScreenPresentingAd, _ isOpen:Bool) -> Void)?) {
guard openAdStatus else {return}
// 广广广
guard !interstitialSwitch, !isShowingOpenAd else { return }
@ -415,10 +455,33 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
MP_AnalyticsManager.shared.hot_ads_chanceAction()
}
//广
if let ad = appOpenAd {
if let ad = (appOpenAd) {
//
if let block = completion {
block(ad)
block(ad, true)
}else {
isShowingOpenAd = true
interstitialSwitch = true
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
do{
try ad.canPresent(fromRootViewController: nil)
ad.present(fromRootViewController: nil)
}catch{
print("开屏广告展示失败,失败原因:\(error)")
if completeOpenAdBlock != nil {
completeOpenAdBlock!()
}
accessAppdelegate.setAudioSupport()
}
}
}
}else if let ad = (appInterstitialAd) {
//
if let block = completion {
block(ad, false)
}else {
isShowingOpenAd = true
interstitialSwitch = true
@ -447,14 +510,14 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
}
///广
func isOpenAdAvailable() -> Bool {
return appOpenAd != nil && wasAdexpirationTime(loadOpenAdTime)
return (appOpenAd != nil || appInterstitialAd != nil) && wasAdexpirationTime(loadOpenAdTime)
}
//MARK: -
//广ID
private var SearchINSERTID:String!
private var SearchINSERTID:[MPPositive_AdModelModel] = []
//广ID
private var SearchNATIVEID:String!
private var SearchNATIVEID:[MPPositive_AdModelModel] = []
///广
private var searchInterstitialAd:GADInterstitialAd?
///广
@ -492,9 +555,11 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
let multipleAdOptions = GADMultipleAdsAdLoaderOptions()
//使
multipleAdOptions.numberOfAds = 1
searchAdLoader = GADAdLoader(adUnitID: SearchNATIVEID, rootViewController: vc, adTypes: [.native], options: [multipleAdOptions])
searchAdLoader?.delegate = self
searchAdLoader?.load(GADRequest())
if let first = SearchNATIVEID.first, first.type == .Native {
searchAdLoader = GADAdLoader(adUnitID: first.identifier, rootViewController: vc, adTypes: [.native], options: [multipleAdOptions])
searchAdLoader?.delegate = self
searchAdLoader?.load(GADRequest())
}
}
///广
func layoutSearchNativeAd(in containerView: UIView) {
@ -541,8 +606,16 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
}
//广
func loadSearchInterstitialAd(completion: @escaping (Bool) -> Void) {
func loadSearchInterstitialAd(_ level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
guard level <= (SearchINSERTID.count-1) else {
print("搜索插页广告组已经全部加载失败,停止继续加载")
//
loadGlobalInterstitialAd { status in
completion(status)
}
return
}
// 广广
if isLoadingSearchInterstitialAd || isSearchInterstitialAdAvailable() {
// 广广
@ -550,17 +623,15 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingSearchInterstitialAd = true
let item = SearchINSERTID[level]
//广
GADInterstitialAd.load(withAdUnitID: SearchINSERTID, request: GADRequest()) { ad, error in
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载搜索插页广告失败,失败原因: \(error.localizedDescription)")
print("加载搜索插页广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingSearchInterstitialAd = false
//
loadGlobalInterstitialAd { status in
completion(status)
}
loadSearchInterstitialAd(level+1, completion: completion)
} else {
self.searchInterstitialAd = ad
self.isLoadingSearchInterstitialAd = false
@ -628,7 +699,7 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
//MARK: -
//广ID
private var PlayerINSERTID:String!
private var PlayerINSERTID:[MPPositive_AdModelModel] = []
///广
var playInterstitialAd:GADInterstitialAd?
///广
@ -640,8 +711,16 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
///广
var completePlayInterstitialAdBlock:(() -> Void)?
//广
func loadPlayInterstitialAd(completion: @escaping (Bool) -> Void) {
func loadPlayInterstitialAd(_ level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
guard level <= (PlayerINSERTID.count-1) else {
print("播放插页广告组已经全部加载失败,停止继续加载")
//
loadGlobalInterstitialAd { status in
completion(status)
}
return
}
// 广广
if isLoadingPlayInterstitialAd || isPlayInterstitialAdAvailable() {
// 广广
@ -649,16 +728,15 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingPlayInterstitialAd = true
let item = PlayerINSERTID[level]
//广
GADInterstitialAd.load(withAdUnitID: PlayerINSERTID, request: GADRequest()) { ad, error in
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载播放插页广告失败,失败原因: \(error.localizedDescription)")
print("加载播放插页广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingPlayInterstitialAd = false
loadGlobalInterstitialAd { status in
completion(status)
}
loadPlayInterstitialAd(level+1, completion: completion)
} else {
self.playInterstitialAd = ad
self.isLoadingPlayInterstitialAd = false
@ -727,7 +805,7 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
//MARK: -
//广ID
private var SwitchINSERTID:String!
private var SwitchINSERTID:[MPPositive_AdModelModel] = []
///广
var switchInterstitialAd:GADInterstitialAd?
///广
@ -739,8 +817,16 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
///广
var completeSwitchInterstitialAdBlock:(() -> Void)?
//广
func loadSwitchInterstitialAd(completion: @escaping (Bool) -> Void) {
func loadSwitchInterstitialAd(_ level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
guard level <= (SwitchINSERTID.count-1) else {
print("切歌插页广告组已经全部加载失败,停止继续加载")
//
loadGlobalInterstitialAd { status in
completion(status)
}
return
}
// 广广
if isLoadingSwitchInterstitialAd || isSwitchInterstitialAdAvailable() {
// 广广
@ -748,16 +834,15 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingSwitchInterstitialAd = true
let item = SwitchINSERTID[level]
//广
GADInterstitialAd.load(withAdUnitID: SwitchINSERTID, request: GADRequest()) { ad, error in
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载切歌插页广告失败,失败原因: \(error.localizedDescription)")
print("加载切歌插页广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingSwitchInterstitialAd = false
loadGlobalInterstitialAd { status in
completion(status)
}
loadSwitchInterstitialAd(level+1, completion: completion)
} else {
self.switchInterstitialAd = ad
self.isLoadingSwitchInterstitialAd = false
@ -825,7 +910,7 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
//MARK: -
//广ID
private var LoadINSERTID:String!
private var LoadINSERTID:[MPPositive_AdModelModel] = []
///广
var loadInterstitialAd:GADInterstitialAd?
///广
@ -837,8 +922,16 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
///广
var completeLoadInterstitialAdBlock:(() -> Void)?
//广
func loadLoadInterstitialAd(completion: @escaping (Bool) -> Void) {
func loadLoadInterstitialAd(_ level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
guard level <= (LoadINSERTID.count-1) else {
print("下载插页广告组已经全部加载失败,停止继续加载")
//
loadGlobalInterstitialAd { status in
completion(status)
}
return
}
// 广广
if isLoadingLoadInterstitialAd || isLoadInterstitialAdAvailable() {
// 广广
@ -846,16 +939,15 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingLoadInterstitialAd = true
let item = LoadINSERTID[level]
//广
GADInterstitialAd.load(withAdUnitID: LoadINSERTID, request: GADRequest()) { ad, error in
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载下载插页广告失败,失败原因: \(error.localizedDescription)")
print("加载下载插页广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingLoadInterstitialAd = false
loadGlobalInterstitialAd { status in
completion(status)
}
loadLoadInterstitialAd(level+1, completion: completion)
} else {
self.loadInterstitialAd = ad
self.isLoadingLoadInterstitialAd = false
@ -922,9 +1014,9 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
}
//MARK: -
//ID
private var LibraryINSERTID:String!
private var LibraryINSERTID:[MPPositive_AdModelModel] = []
//ID
private var LibraryNATIVEID:String!
private var LibraryNATIVEID:[MPPositive_AdModelModel] = []
///广
private var libraryInterstitialAd:GADInterstitialAd?
///广
@ -967,10 +1059,12 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
let multipleAdOptions = GADMultipleAdsAdLoaderOptions()
//使
multipleAdOptions.numberOfAds = 2
libraryAdLoader = GADAdLoader(adUnitID: LibraryNATIVEID, rootViewController: vc, adTypes: [.native], options: [multipleAdOptions])
libraryAdLoader?.delegate = self
libraryAdLoader?.load(GADRequest())
libraryNativeAds = []
if let first = LibraryNATIVEID.first, first.type == .Native {
libraryAdLoader = GADAdLoader(adUnitID: first.identifier, rootViewController: vc, adTypes: [.native], options: [multipleAdOptions])
libraryAdLoader?.delegate = self
libraryAdLoader?.load(GADRequest())
libraryNativeAds = []
}
}
///广
func layoutLibraryNativeAd(in containerView: UIView, index:Int) {
@ -1047,8 +1141,16 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return Date().timeIntervalSince(date) < refreshLibraryTimes
}
//广
func loadLibraryInterstitialAd(completion: @escaping (Bool) -> Void) {
func loadLibraryInterstitialAd(_ level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
guard level <= (LibraryINSERTID.count-1) else {
print("曲库插页广告组已经全部加载失败,停止继续加载")
//
loadGlobalInterstitialAd { status in
completion(status)
}
return
}
// 广广
if isLoadingLibraryInterstitialAd || isLibraryInterstitialAdAvailable() {
// 广广
@ -1056,16 +1158,15 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingLibraryInterstitialAd = true
let item = LibraryINSERTID[level]
//广
GADInterstitialAd.load(withAdUnitID: LibraryINSERTID, request: GADRequest()) { ad, error in
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载曲库插页广告失败,失败原因: \(error.localizedDescription)")
print("加载曲库插页广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingLibraryInterstitialAd = false
loadGlobalInterstitialAd { status in
completion(status)
}
loadLibraryInterstitialAd(level+1, completion: completion)
} else {
self.libraryInterstitialAd = ad
self.isLoadingLibraryInterstitialAd = false
@ -1135,7 +1236,7 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
//MARK: -
//ID
private var GlobalINSERTID:String!
private var GlobalINSERTID:[MPPositive_AdModelModel] = []
///广
private var globalInterstitialAd:GADInterstitialAd?
///广
@ -1147,8 +1248,13 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
///广
var completeGlobalInterstitialAdBlock:(() -> Void)?
//广
func loadGlobalInterstitialAd(completion: @escaping (Bool) -> Void) {
func loadGlobalInterstitialAd(_ level:Int = 0, completion: @escaping (Bool) -> Void) {
guard openAdStatus else {return}
guard level <= (GlobalINSERTID.count-1) else {
print("全局插页广告组已经全部加载失败,停止继续加载")
completion(false)
return
}
// 广广
if isLoadingGlobalInterstitialAd || isGlobalInterstitialAdAvailable() {
// 广广
@ -1156,14 +1262,15 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
return
}
isLoadingGlobalInterstitialAd = true
let item = GlobalINSERTID[level]
//广
GADInterstitialAd.load(withAdUnitID: GlobalINSERTID, request: GADRequest()) { ad, error in
GADInterstitialAd.load(withAdUnitID: item.identifier, request: GADRequest()) { ad, error in
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
if let error = error {
print("加载全局插页广告失败,失败原因: \(error.localizedDescription)")
print("加载全局插页广告失败,失败原因: \(error.localizedDescription)已下调广告ID等级重新加载")
self.isLoadingGlobalInterstitialAd = false
completion(false)
loadGlobalInterstitialAd(level+1, completion: completion)
} else {
self.globalInterstitialAd = ad
self.isLoadingGlobalInterstitialAd = false
@ -1220,12 +1327,13 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
//MARK: - 广 GADFullScreenContentDelegate
//广
func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
if ad === appOpenAd {//广
print("当前展示的广告是开屏广告广告ID--\(appOpenAd?.adUnitID ?? "")")
// UIApplication.shared.isStatusBarHidden = true
if ad === appOpenAd || ad === appInterstitialAd {//广
print("当前展示的广告是开屏广告广告ID--\(appOpenAd != nil ? (appOpenAd?.adUnitID ?? ""):(appInterstitialAd?.adUnitID ?? ""))")
//
if appOpenAd?.adUnitID == OpenICEID {
if OpenICEID.contains(where: {($0.identifier == (appOpenAd?.adUnitID ?? "") || $0.identifier == (appInterstitialAd?.adUnitID ?? ""))}) {
MP_AnalyticsManager.shared.cold_ads_showSuccessAction()
}else if appOpenAd?.adUnitID == OpenHOSTID {
}else if OpenHOSTID.contains(where: {($0.identifier == (appOpenAd?.adUnitID ?? "") || $0.identifier == (appInterstitialAd?.adUnitID ?? ""))}) {
MP_AnalyticsManager.shared.hot_ads_showSuccessAction()
}
}else if ad === searchInterstitialAd {//广
@ -1249,10 +1357,11 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
}
//广
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = false
//广
interstitialDate = Date()
if ad === appOpenAd {//广
print("当前消失的广告是开屏广告广告ID--\(appOpenAd?.adUnitID ?? "")")
if ad === appOpenAd || ad === appInterstitialAd {//广
print("当前消失的广告是开屏广告广告ID--\(appOpenAd != nil ? (appOpenAd?.adUnitID ?? ""):(appInterstitialAd?.adUnitID ?? ""))")
//广
if completeOpenAdBlock != nil {
completeOpenAdBlock!()
@ -1294,18 +1403,23 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
completeGlobalInterstitialAdBlock!()
}
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
//广
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
// UIApplication.shared.isStatusBarHidden = false
//广
interstitialDate = Date()
if ad === appOpenAd {//广
print("开屏广告展示时出错广告ID--\(appOpenAd?.adUnitID ?? ""),具体错误原因:\(error.localizedDescription)")
if ad === appOpenAd || ad === appInterstitialAd {//广
print("开屏广告展示时出错广告ID--\(appOpenAd != nil ? (appOpenAd?.adUnitID ?? ""):(appInterstitialAd?.adUnitID ?? "")),具体错误原因:\(error.localizedDescription)")
//
if appOpenAd?.adUnitID == OpenICEID {
if OpenICEID.contains(where: {($0.identifier == (appOpenAd?.adUnitID ?? "") || $0.identifier == (appInterstitialAd?.adUnitID ?? ""))}) {
MP_AnalyticsManager.shared.cold_ads_showFailureAction(error.localizedDescription)
}else if appOpenAd?.adUnitID == OpenHOSTID {
}else if OpenHOSTID.contains(where: {($0.identifier == (appOpenAd?.adUnitID ?? "") || $0.identifier == (appInterstitialAd?.adUnitID ?? ""))}) {
MP_AnalyticsManager.shared.hot_ads_showFailureAction(error.localizedDescription)
}
if completeOpenAdBlock != nil {
@ -1350,7 +1464,11 @@ class MP_AdMobManager: NSObject, GADFullScreenContentDelegate, GADNativeAdLoader
completeGlobalInterstitialAdBlock!()
}
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
//MARK: - GADNativeAdLoaderDelegate
// 广

View File

@ -23,6 +23,8 @@ class MP_AnalyticsManager: NSObject {
private let app_crash:String = "app_crash"
//
private let launch_pv:String = "launch_pv"
//
private let launch_progress_end:String = "launch_progress_end"
//
private let jump_event:String = "jump_event"
//A
@ -63,6 +65,8 @@ class MP_AnalyticsManager: NSObject {
private let player_b_downloadfailure_error = "player_b_downloadfailure_error"
//B
private let search_pv = "search_pv"
//B
private let grid_mood_click = "grid_mood_click"
//SUG
private let search_sug_show = "search_sug_show"
//sug
@ -114,14 +118,23 @@ class MP_AnalyticsManager: NSObject {
print("更新了插页广告时长间隔")
}
//广ID
// if let content = self.remoteConfig.configValue(forKey: "adMobIDs").jsonValue as? [String:String] {
// //广ID
// for (key, value) in content {
// UserDefaults.standard.setValue(value, forKey: key)
// }
// print("广ID")
// MP_AdMobManager.shared.reloadAdMobIDs()
// }
if let adTextIDs = self.remoteConfig.configValue(forKey: "adMobLevelIDs").jsonValue as? [String:[[String:Any]]] {
//广ID
for (key, values) in adTextIDs {
var array:[MPPositive_AdModelModel] = []
values.forEach { value in
if let level = value["level"] as? Int, let identifier = value["identifier"] as? String, let ad = value["ad"] as? String, let item = value["type"] as? String, let type = MPPositive_AdModelType(rawValue: item) {
array.append(.init(level: level, identifier: identifier, ad: ad, type: type))
}
}
//arrayjsonData
if let data = coreAdModelforJson(array) {
UserDefaults.standard.set(data, forKey: key)
}
}
print("更新了所有广告ID")
MP_AdMobManager.shared.reloadAdMobIDs()
}
//
if let versionData = self.remoteConfig.configValue(forKey: "dataVersion").jsonValue as? [String:String] {
//
@ -131,6 +144,17 @@ class MP_AnalyticsManager: NSObject {
print("更新了所有版本数据")
MP_NetWorkManager.shared.reloadVersion()
}
//
if let notificationBodyTexts = self.remoteConfig.configValue(forKey: "notificationBodyTexts").jsonValue as? [String:[String]] {
//
for (key, value) in notificationBodyTexts {
UserDefaults.standard.setValue(value, forKey: key)
}
print("更新了通知文本数据")
//
scheduleDailyNotifications()
}
let js = self.remoteConfig.configValue(forKey: "openStatus").jsonValue as! [String:Any]
let value = js["versionCode"] as! String
if value == app_Version {
@ -186,6 +210,10 @@ class MP_AnalyticsManager: NSObject {
func launch_pvAction(){
Analytics.logEvent(launch_pv, parameters: nil)
}
///
func launch_progress_endAction() {
Analytics.logEvent(launch_progress_end, parameters: nil)
}
///
func jump_eventAction(_ side:String, reason:String) {
Analytics.logEvent(jump_event, parameters: ["side":side,
@ -339,6 +367,10 @@ class MP_AnalyticsManager: NSObject {
func search_pvAction(){
Analytics.logEvent(search_pv, parameters: nil)
}
///B
func grid_mood_clickAction(_ mood:String) {
Analytics.logEvent(grid_mood_click, parameters: ["mood":mood])
}
///SUG
func search_sug_showAction(){
Analytics.logEvent(search_sug_show, parameters: nil)

View File

@ -27,14 +27,24 @@ class MP_CoreDataHandlerManager {
}
return container
}()
//
//线
var context: NSManagedObjectContext {
return persistentContainer.viewContext
}
//
var backgroundContext: NSManagedObjectContext {
//
var backgroundContext: NSManagedObjectContext{
return persistentContainer.newBackgroundContext()
}
private init() {
//
NotificationCenter.default.addObserver(self,
selector: #selector(mergeChangesFromBackgroundContext),
name: .NSManagedObjectContextDidSave,
object: nil)
}
deinit{
NotificationCenter.default.removeObserver(self)
}
//线
func saveContext() {
//线
@ -47,41 +57,42 @@ class MP_CoreDataHandlerManager {
try context.save()
} catch {
//
let nserror = error as NSError
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
print("数据库更新失败,错误详情:\(error.localizedDescription)")
}
}
}
// //
// if context.hasChanges {
// //线
// context.perform {
// [weak self] in
// guard let self = self else {return}
// do {
// //
// try context.save()
// } catch {
// //
// let nserror = error as NSError
// fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
// }
// }
// }
}
//
///
func saveContextInBackground() {
backgroundContext.perform {
[weak self] in
guard let self = self else {return}
guard let self = self else { return }
if backgroundContext.hasChanges {
do {
try backgroundContext.save()
//
NotificationCenter.default.post(name: .NSManagedObjectContextDidSave, object: backgroundContext)
} catch {
//
print("后台保存失败: \(error), \(error.localizedDescription)")
//
let nserror = error as NSError
// 使
// self.logError(nserror)
print("后台保存失败: \(nserror), \(nserror.userInfo)")
}
}
}
}
@objc func mergeChangesFromBackgroundContext(notification: Notification) {
DispatchQueue.main.async {
//
guard let backgroundContext = notification.object as? NSManagedObjectContext else {
return
}
//
self.context.perform {
self.context.mergeChanges(fromContextDidSave: notification)
}
}
}
}

View File

@ -68,11 +68,11 @@ class MP_NetWorkManager: NSObject {
private var playerVersion:String!
///IP
private let banIPs:[String] = [
// "CN",
// "HK",
// "TW",
// "JP",
// "KR"
"CN",
"HK",
"TW",
"JP",
"KR"
]
///访Code
private let codes:[String] = [
@ -657,6 +657,105 @@ extension MP_NetWorkManager {
}
}
}
///
func requestGenres(_ completion:@escaping (([MPPositive_GridViewModel]) -> Void)) {
//browse
let path = header+point+browse
//url
guard let url = URL(string: path) else {
print("Url is Incorrect")
return
}
//
let parameters:[String:Any] = [
"browseId": "FEmusic_moods_and_genres",
"prettyPrint":"false",
"context":[
"client":[
//web
"clientName": "WEB_REMIX",
//访
"clientVersion": clientVersion,
"platform":"MOBILE",
//
"hl":Language_first_local,
//
"gl":locaton ?? ""
]
]
]
requestPostGenres(url, parameters: parameters) { array in
completion(array)
}
}
///
private func requestPostGenres(_ url:URL, parameters:Parameters, completion:@escaping (([MPPositive_GridViewModel]) -> Void)) {
//post
MPSession.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseDecodable(of: JsonGenres.self) { [weak self] (response) in
guard let self = self else {return}
switch response.result {
case .success(let value):
if let contents = value.contents?.singleColumnBrowseResultsRenderer?.tabs?.first?.tabRenderer?.content?.sectionListRenderer?.contents {
let array = parsingGenres(contents)
completion(array)
}
case .failure(let error):
//
handleError(url, error: error)
}
}
}
///
func requestMoodDetails(_ browseId:String, params:String, completion:@escaping (([MPPositive_BrowseModuleListViewModel]) -> Void)) {
//browse
let path = header+point+browse
//url
guard let url = URL(string: path) else {
print("Url is Incorrect")
return
}
//
let parameters:[String:Any] = [
"browseId": browseId,
"params":params,
"prettyPrint":"false",
"context":[
"client":[
//web
"clientName": "WEB_REMIX",
//访
"clientVersion": clientVersion,
"platform":"MOBILE",
//
"hl":Language_first_local,
//
"gl":locaton ?? ""
]
]
]
requestPostMoodDetails(url, parameters: parameters) { array in
completion(array)
}
}
///
private func requestPostMoodDetails(_ url:URL, parameters:Parameters, completion:@escaping (([MPPositive_BrowseModuleListViewModel]) -> Void)) {
MPSession.request(url, method: .post, parameters: parameters, encoding: JSONEncoding.default).responseDecodable(of: JsonBrowses.self) { [weak self] (response) in
guard let self = self else {return}
switch response.result {
case .success(let value):
//
let tab = value.contents?.singleColumnBrowseResultsRenderer?.tabs?[0]
if let content = tab?.tabRenderer?.content {
let array = parsingMoodDetails(content)
completion(array)
}
case .failure(let error):
print("Failed to parse browses content")
//
handleError(url, error: error)
}
}
}
//MARK: -
///NextPlayer
@ -1673,7 +1772,64 @@ extension MP_NetWorkManager {
return (nil,nil)
}
}
///_Genres
private func parsingGenres(_ contents:[JsonGenres.Contents.SingleColumnBrowseResultsRenderer.Tab.TabRenderer.Content.SectionListRenderer.Content]) -> [MPPositive_GridViewModel] {
var array:[MPPositive_GridViewModel] = []
contents.forEach { content in
if let items = content.gridRenderer?.items {
items.forEach { item in
if let text = item.musicNavigationButtonRenderer?.buttonText?.runs?.first?.text, let leftStripeColor = item.musicNavigationButtonRenderer?.solid?.leftStripeColor, let browseId = item.musicNavigationButtonRenderer?.clickCommand?.browseEndpoint?.browseId, let params = item.musicNavigationButtonRenderer?.clickCommand?.browseEndpoint?.params {
let gride = MPPositive_GridModel(title: text, stringColor: leftStripeColor, browseId: browseId, params: params)
array.append(.init(gride))
}
}
}
}
return array
}
///_Mood
private func parsingMoodDetails(_ content:JsonBrowses.Contents.SingleColumnBrowseResultsRenderer.Tab.TabRenderer.Content) -> [MPPositive_BrowseModuleListViewModel] {
//:idid
var browses:[MPPositive_BrowseModuleListViewModel] = []
//
content.sectionListRenderer?.contents?.forEach({ content in
//
let browse = MPPositive_BrowseModuleListViewModel()
if let musicCarouselShelfRenderer = content.musicCarouselShelfRenderer {
browse.title = musicCarouselShelfRenderer.header?.musicCarouselShelfBasicHeaderRenderer?.title?.runs?.first?.text
//
musicCarouselShelfRenderer.contents?.forEach({ content in
///
if let musicResponsiveListItemRenderer = content.musicResponsiveListItemRenderer {
if let item = parsingMusicResponsiveListItemRenderer(musicResponsiveListItemRenderer) {
browse.items.append(.init(item))
}
}else if let musicTwoRowItemRenderer = content.musicTwoRowItemRenderer {
browse.items.append(.init(parsingMusicTwoRowItemRenderer(musicTwoRowItemRenderer)))
}
})
if browse.items.isEmpty != true {
browses.append(browse)
}
}else if let gridRenderer = content.gridRenderer {
browse.title = gridRenderer.header?.gridHeaderRenderer?.title?.runs?.first?.text
gridRenderer.items?.forEach({ content in
///
if let musicResponsiveListItemRenderer = content.musicResponsiveListItemRenderer {
if let item = parsingMusicResponsiveListItemRenderer(musicResponsiveListItemRenderer) {
browse.items.append(.init(item))
}
}else if let musicTwoRowItemRenderer = content.musicTwoRowItemRenderer {
browse.items.append(.init(parsingMusicTwoRowItemRenderer(musicTwoRowItemRenderer)))
}
})
if browse.items.isEmpty != true {
browses.append(browse)
}
}
})
return browses
}
/// _Player
/// - Parameters:
/// - player: player

View File

@ -310,15 +310,21 @@ class MP_PlayerManager:NSObject{
print("当前音乐-\(loadPlayer?.currentVideo?.title ?? "") 已经准备好播放")
}
}else {
print("当前音乐-\(loadPlayer?.currentVideo?.title ?? "") 未做好准备播放,失败原因是\(loadPlayer?.currentVideo?.resourcePlayerItem.error?.localizedDescription ?? "")")
MP_AnalyticsManager.shared.player_b_failure_errorAction(loadPlayer?.currentVideo?.song.videoId ?? "", videoname: loadPlayer?.currentVideo?.title ?? "", artistname: loadPlayer?.currentVideo?.song.shortBylineText ?? "", error: loadPlayer?.currentVideo?.resourcePlayerItem.error?.localizedDescription ?? "Failed to buffer data")
if loadPlayer?.currentVideo?.isKVO == true {
suspendTimer()
loadPlayer?.currentVideo?.isKVO = false
//
loadPlayer?.remakeImproveData {
[weak self] in
self?.play()
if let currentVideo = loadPlayer?.currentVideo {
print("当前音乐-\(currentVideo.title ?? "") 未做好准备播放,失败原因是\(currentVideo.resourcePlayerItem.error?.localizedDescription ?? "")")
MP_AnalyticsManager.shared.player_b_failure_errorAction(currentVideo.song.videoId ?? "", videoname: currentVideo.title ?? "", artistname: currentVideo.song.shortBylineText ?? "", error: currentVideo.resourcePlayerItem.error?.localizedDescription ?? "Failed to buffer data")
if loadPlayer?.currentVideo?.isKVO == true {
suspendTimer()
loadPlayer?.currentVideo?.isKVO = false
statusObservation?.invalidate()
loadedTimeRangesObservation?.invalidate()
playbackLikelyToKeepUpObservation?.invalidate()
errorObservation?.invalidate()
//
loadPlayer?.remakeImproveData {
[weak self] in
self?.play()
}
}
}
}

View File

@ -140,15 +140,19 @@ struct JsonBrowses: Codable {
}
///
struct Content: Codable {
///
let musicCarouselShelfRenderer:MusicCarouselShelfRenderer?
///
let gridRenderer:GridRenderer?
enum CodingKeys: String, CodingKey {
case musicCarouselShelfRenderer = "musicCarouselShelfRenderer"
case gridRenderer = "gridRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
musicCarouselShelfRenderer = try values.decodeIfPresent(MusicCarouselShelfRenderer.self, forKey: .musicCarouselShelfRenderer)
gridRenderer = try values.decodeIfPresent(GridRenderer.self, forKey: .gridRenderer)
}
struct MusicCarouselShelfRenderer: Codable {
///
@ -226,6 +230,82 @@ struct JsonBrowses: Codable {
}
}
}
struct GridRenderer: Codable {
let items:[Item]?
let header:Header?
enum CodingKeys: String, CodingKey {
case items = "items"
case header = "header"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
items = try values.decodeIfPresent([Item].self, forKey: .items)
header = try values.decodeIfPresent(Header.self, forKey: .header)
}
struct Item: Codable {
///(ID)
let musicResponsiveListItemRenderer:RootMusicResponsiveListItemRenderer?
///(ID)
let musicTwoRowItemRenderer:RootMusicTwoRowItemRenderer?
enum CodingKeys: String, CodingKey {
case musicResponsiveListItemRenderer = "musicResponsiveListItemRenderer"
case musicTwoRowItemRenderer = "musicTwoRowItemRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
musicResponsiveListItemRenderer = try values.decodeIfPresent(RootMusicResponsiveListItemRenderer.self, forKey: .musicResponsiveListItemRenderer)
musicTwoRowItemRenderer = try values.decodeIfPresent(RootMusicTwoRowItemRenderer.self, forKey: .musicTwoRowItemRenderer)
}
}
struct Header: Codable {
let gridHeaderRenderer:GridHeaderRenderer?
enum CodingKeys: String, CodingKey {
case gridHeaderRenderer = "gridHeaderRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
gridHeaderRenderer = try values.decodeIfPresent(GridHeaderRenderer.self, forKey: .gridHeaderRenderer)
}
struct GridHeaderRenderer: Codable {
let title:Title?
enum CodingKeys: String, CodingKey {
case title = "title"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
title = try values.decodeIfPresent(Title.self, forKey: .title)
}
struct Title: Codable {
///0
let runs:[Run]?
enum CodingKeys: String, CodingKey {
case runs = "runs"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
runs = try values.decodeIfPresent([Run].self, forKey: .runs)
}
//MARK: - //
struct Run: Codable {
///
let text:String?
enum CodingKeys: String, CodingKey {
case text = "text"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
text = try values.decodeIfPresent(String.self, forKey: .text)
}
}
}
}
}
}
}
///
struct Continuation: Codable {

View File

@ -0,0 +1,231 @@
//
// MPPositive_JsonGenres.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/11.
//
import UIKit
///
struct JsonGenres: Codable {
let contents:Contents?
let header:Header?
enum CodingKeys: String, CodingKey {
case contents = "contents"
case header = "header"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
contents = try values.decodeIfPresent(Contents.self, forKey: .contents)
header = try values.decodeIfPresent(Header.self, forKey: .header)
}
struct Contents: Codable {
let singleColumnBrowseResultsRenderer:SingleColumnBrowseResultsRenderer?
enum CodingKeys: String, CodingKey {
case singleColumnBrowseResultsRenderer = "singleColumnBrowseResultsRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
singleColumnBrowseResultsRenderer = try values.decodeIfPresent(SingleColumnBrowseResultsRenderer.self, forKey: .singleColumnBrowseResultsRenderer)
}
struct SingleColumnBrowseResultsRenderer: Codable {
let tabs:[Tab]?
enum CodingKeys: String, CodingKey {
case tabs = "tabs"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
tabs = try values.decodeIfPresent([Tab].self, forKey: .tabs)
}
struct Tab:Codable {
let tabRenderer:TabRenderer?
enum CodingKeys: String, CodingKey {
case tabRenderer = "tabRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
tabRenderer = try values.decodeIfPresent(TabRenderer.self, forKey: .tabRenderer)
}
struct TabRenderer: Codable {
let content:Content?
enum CodingKeys: String, CodingKey {
case content = "content"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
content = try values.decodeIfPresent(Content.self, forKey: .content)
}
struct Content: Codable {
let sectionListRenderer:SectionListRenderer?
enum CodingKeys: String, CodingKey {
case sectionListRenderer = "sectionListRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
sectionListRenderer = try values.decodeIfPresent(SectionListRenderer.self, forKey: .sectionListRenderer)
}
struct SectionListRenderer: Codable {
let contents:[Content]?
enum CodingKeys: String, CodingKey {
case contents = "contents"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
contents = try values.decodeIfPresent([Content].self, forKey: .contents)
}
struct Content: Codable {
let gridRenderer:GridRenderer?
enum CodingKeys: String, CodingKey {
case gridRenderer = "gridRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
gridRenderer = try values.decodeIfPresent(GridRenderer.self, forKey: .gridRenderer)
}
struct GridRenderer: Codable {
let items:[Item]?
enum CodingKeys: String, CodingKey {
case items = "items"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
items = try values.decodeIfPresent([Item].self, forKey: .items)
}
struct Item: Codable {
let musicNavigationButtonRenderer:MusicNavigationButtonRenderer?
enum CodingKeys: String, CodingKey {
case musicNavigationButtonRenderer = "musicNavigationButtonRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
musicNavigationButtonRenderer = try values.decodeIfPresent(MusicNavigationButtonRenderer.self, forKey: .musicNavigationButtonRenderer)
}
struct MusicNavigationButtonRenderer: Codable {
///
let buttonText:ButtonText?
///
let solid:Solid?
///
let clickCommand:ClickCommand?
enum CodingKeys: String, CodingKey {
case buttonText = "buttonText"
case solid = "solid"
case clickCommand = "clickCommand"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
buttonText = try values.decodeIfPresent(ButtonText.self, forKey: .buttonText)
solid = try values.decodeIfPresent(Solid.self, forKey: .solid)
clickCommand = try values.decodeIfPresent(ClickCommand.self, forKey: .clickCommand)
}
//
struct ButtonText: Codable{
//
let runs:[Run]?
enum CodingKeys: String, CodingKey {
case runs = "runs"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
runs = try values.decodeIfPresent([Run].self, forKey: .runs)
}
struct Run: Codable {
//
let text:String?
enum CodingKeys: String, CodingKey {
case text = "text"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
text = try values.decodeIfPresent(String.self, forKey: .text)
}
}
}
//
struct Solid: Codable {
///
let leftStripeColor:Int?
enum CodingKeys: String, CodingKey {
case leftStripeColor = "leftStripeColor"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
leftStripeColor = try values.decodeIfPresent(Int.self, forKey: .leftStripeColor)
}
}
//
struct ClickCommand: Codable {
let browseEndpoint:BrowseEndpoint?
enum CodingKeys: String, CodingKey {
case browseEndpoint = "browseEndpoint"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
browseEndpoint = try values.decodeIfPresent(BrowseEndpoint.self, forKey: .browseEndpoint)
}
struct BrowseEndpoint: Codable {
let browseId:String?
let params:String?
enum CodingKeys: String, CodingKey {
case browseId = "browseId"
case params = "params"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
browseId = try values.decodeIfPresent(String.self, forKey: .browseId)
params = try values.decodeIfPresent(String.self, forKey: .params)
}
}
}
}
}
}
}
}
}
}
}
}
}
struct Header: Codable {
let musicHeaderRenderer:MusicHeaderRenderer?
enum CodingKeys: String, CodingKey {
case musicHeaderRenderer = "musicHeaderRenderer"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
musicHeaderRenderer = try values.decodeIfPresent(MusicHeaderRenderer.self, forKey: .musicHeaderRenderer)
}
struct MusicHeaderRenderer: Codable {
let title:Title?
enum CodingKeys: String, CodingKey {
case title = "title"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
title = try values.decodeIfPresent(Title.self, forKey: .title)
}
struct Title: Codable {
let runs:[Run]?
enum CodingKeys: String, CodingKey {
case runs = "runs"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
runs = try values.decodeIfPresent([Run].self, forKey: .runs)
}
struct Run: Codable {
let text:String?
enum CodingKeys: String, CodingKey {
case text = "text"
}
init(from decoder: Decoder) throws {
let values = try decoder.container(keyedBy: CodingKeys.self)
text = try values.decodeIfPresent(String.self, forKey: .text)
}
}
}
}
}
}

View File

@ -0,0 +1,33 @@
//
// MPPositive_AdModelModel.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/10.
//
import UIKit
///广
class MPPositive_AdModelModel: NSObject, Codable {
///
var level:Int
///id
var identifier:String
///广
var ad:String
///广
var type:MPPositive_AdModelType
init(level: Int, identifier: String, ad: String, type:MPPositive_AdModelType) {
self.level = level
self.identifier = identifier
self.ad = ad
self.type = type
}
}
enum MPPositive_AdModelType: String, Codable {
///
case Open = "Open"
///
case Insert = "Insert"
///
case Native = "Native"
}

View File

@ -0,0 +1,26 @@
//
// MPPositive_GridModel.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/11.
//
import UIKit
class MPPositive_GridModel: NSObject, Codable {
///
var title:String
///
var stringColor:Int
///id
var browseId:String
///params
var params:String
init(title: String, stringColor: Int, browseId: String, params: String) {
self.title = title
self.stringColor = stringColor
self.browseId = browseId
self.params = params
}
}

View File

@ -0,0 +1,27 @@
//
// MPPositive_GridViewModel.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/11.
//
import UIKit
///ViewModel
class MPPositive_GridViewModel: NSObject, Codable {
///
var title:String?
///
var stringColor:Int64?
///
var grid:MPPositive_GridModel
init(_ grid:MPPositive_GridModel) {
self.grid = grid
super.init()
configure()
}
//
private func configure() {
self.title = self.grid.title
self.stringColor = Int64(self.grid.stringColor)
}
}

View File

@ -92,6 +92,8 @@ class MPPositive_BrowseLoadViewModel: NSObject {
browseModuleLists.removeAll()
//
MP_NetWorkManager.shared.requestBrowseDatas()
//gride
MPPositive_GridLoadViewModel.shared.reloadGrides()
}
///
private func cacheResponseData(_ array: [MPPositive_BrowseModuleListViewModel]) {

View File

@ -0,0 +1,65 @@
//
// MPPositive_GridLoadViewModel.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/12.
//
import UIKit
class MPPositive_GridLoadViewModel: NSObject {
static let shared = MPPositive_GridLoadViewModel()
var grideViewModels:[MPPositive_GridViewModel] = []
private override init() {
super.init()
if let data = chachedData() {
grideViewModels = data
}
}
//grideModel
func reloadGrides() {
MP_NetWorkManager.shared.requestGenres { [weak self] array in
guard let self = self else {return}
DispatchQueue.main.async {
self.grideViewModels = array
self.cacheResponseData(self.grideViewModels)
//
NotificationCenter.notificationKey.post(notificationName: .search_gride_reload)
}
}
}
//
private func cacheResponseData(_ array: [MPPositive_GridViewModel]) {
guard grideViewModels.count != 0 else {
print("Search Gride数据未加载无法缓存")
return
}
//jsonData
do{
let jsonData = try JSONEncoder().encode(array)
//使UserDefaults
UserDefaults.standard.set(jsonData, forKey: "SearchGride")
print("已经将Search Gride数据缓存")
}catch{
//jsonData
print("Search Gride数据转为Data失败失败原因\(error)")
}
}
//
private func chachedData() -> [MPPositive_GridViewModel]? {
guard let cacheData = UserDefaults.standard.data(forKey: "SearchGride") else {
print("获取Search Gride缓存数据失败")
return nil
}
do {
let array:[MPPositive_GridViewModel] = try JSONDecoder().decode([MPPositive_GridViewModel].self, from: cacheData)
print("已经将Search Gride缓存数据取出")
return array
} catch {
//jsonData
print("获取Search Gride缓存数据失败失败原因\(error)")
return nil
}
}
}

View File

@ -113,7 +113,7 @@ class MPPositive_LoadCoreModel: NSObject {
///
func reloadSearchTags(_ complection:(() -> Void)?) {
MPPositive_SearchTagModel.fetchAll{ array in
let s = array.sorted(by: {$1.date > $0.date})
let s = array.sorted(by: {$0.date > $1.date})
DispatchQueue.main.async {
self.searchTags = s
if complection != nil {

View File

@ -30,7 +30,7 @@ class MPPositive_SearchResultsLoadViewModel: NSObject {
//
private func getSearchResults(_ text:String) {
MP_HUD.loading()
//
MPPositive_SearchTagModel.fetch(predicate: .init(format: "text==%@", text)) { results in
if results.count == 0 {
@ -40,7 +40,6 @@ class MPPositive_SearchResultsLoadViewModel: NSObject {
tag.date = Date().timeZone()
tag.text = text
MPPositive_SearchTagModel.save()
MPPositive_LoadCoreModel.shared.reloadSearchTags(nil)
}
}
MP_NetWorkManager.shared.requestSearchPreviewResults(text) { [weak self] results in

View File

@ -111,7 +111,7 @@ extension MPPositive_TabBarController {
self?.viewControllers![self?.selectedIndex ?? 0].children[0].navigationController?.pushViewController(recommendVC, animated: false)
}
playerVC.searchBlock = { (text) in
let resultVC = MPPositive_SearchResultShowViewController(text)
let resultVC = MPPositive_SearchResultShowViewController(text, isShowAd: false)
self?.viewControllers![self?.selectedIndex ?? 0].children[0].navigationController?.pushViewController(resultVC, animated: false)
}
self?.present(playerVC, animated: true)
@ -163,6 +163,7 @@ extension MPPositive_TabBarController {
//MARK: - 广 GADFullScreenContentDelegate
//广
func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = true
if ad === MP_AdMobManager.shared.playInterstitialAd {//广
print("当前展示的广告是播放插页广告广告ID--\(MP_AdMobManager.shared.playInterstitialAd?.adUnitID ?? "")")
MP_AnalyticsManager.shared.play_ads_showSuccessAction()
@ -170,6 +171,7 @@ extension MPPositive_TabBarController {
}
//广
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = false
MP_AdMobManager.shared.interstitialDate = Date()
if ad === MP_AdMobManager.shared.playInterstitialAd {//广
let UUID = MP_AdMobManager.shared.playInterstitialAd?.adUnitID ?? ""
@ -190,10 +192,15 @@ extension MPPositive_TabBarController {
self?.present(playerVC, animated: true)
}
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
//广
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
// UIApplication.shared.isStatusBarHidden = false
MP_AdMobManager.shared.interstitialDate = Date()
if ad === MP_AdMobManager.shared.playInterstitialAd {//广
let UUID = MP_AdMobManager.shared.playInterstitialAd?.adUnitID ?? ""
@ -215,6 +222,10 @@ extension MPPositive_TabBarController {
// self?.present(playerVC, animated: true)
// }
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
}

View File

@ -0,0 +1,189 @@
//
// MPPositive_GrideMoodViewController.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/12.
//
import UIKit
///
class MPPositive_GrideMoodViewController: MPPositive_BaseViewController {
//tableView
private lazy var tableView:UITableView = {
let tableView = UITableView(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height), style: .plain)
tableView.backgroundColor = .clear
tableView.separatorStyle = .none
tableView.estimatedRowHeight = 200
tableView.rowHeight = UITableView.automaticDimension
tableView.dataSource = self
tableView.delegate = self
tableView.register(MPPositive_HomeSinglesTableViewCell.self, forCellReuseIdentifier: MPPositive_HomeSinglesTableViewCellID)
tableView.register(MPPositive_HomeShowTableViewCell.self, forCellReuseIdentifier: MPPositive_HomeShowTableViewCellID)
tableView.contentInset = .init(top: 0, left: 0, bottom: 70*width, right: 0)
return tableView
}()
private let MPPositive_HomeSinglesTableViewCellID = "MPPositive_HomeSinglesTableViewCell"
private let MPPositive_HomeShowTableViewCellID = "MPPositive_HomeShowTableViewCell"
private var browseModuleLists:[MPPositive_BrowseModuleListViewModel]! = []{
didSet{
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
if browseModuleLists != nil{
configure()
reload()
removeErrorView()
MP_HUD.hideNow()
}
}
}
}
private var browseId:String!
private var params:String!
private var titleText:String!
init(_ browseId:String, params:String, title:String) {
self.browseId = browseId
self.params = params
self.titleText = title
super.init(nibName: nil, bundle: nil)
//
MP_HUD.loading()
MP_NetWorkManager.shared.requestMoodDetails(browseId, params: params) { [weak self] result in
guard let self = self else {return}
browseModuleLists = result
}
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
override func viewDidLoad() {
super.viewDidLoad()
//
setTitle(titleText)
setPopBtn()
errorBlock = {
[weak self] in
guard let self = self else {
return
}
//navView
view.subviews.forEach { item in
if item != self.navView {
//
if item.superview != nil {
item.removeFromSuperview()
}
}
}
//View
setErrorView()
MP_HUD.hideNow()
}
retryBlock = {
[weak self] in
guard let self = self else {return}
MP_HUD.loading()
MP_NetWorkManager.shared.requestMoodDetails(browseId, params: params) { [weak self] result in
guard let self = self else {return}
browseModuleLists = result
}
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
reload()
}
//
private func reload() {
tableView.reloadData()
}
private func configure() {
view.addSubview(tableView)
tableView.snp.makeConstraints { make in
make.left.bottom.right.equalToSuperview()
make.top.equalTo(navView.snp.bottom).offset(20*width)
}
}
}
//MARK: - tableView
extension MPPositive_GrideMoodViewController: UITableViewDataSource, UITableViewDelegate {
func numberOfSections(in tableView: UITableView) -> Int {
return browseModuleLists.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if let first = browseModuleLists[indexPath.section].items.first, first.browseItem.itemType == .single, first.browseItem.pageType == "MUSIC_VIDEO_TYPE_ATV" {
//
let cell = tableView.dequeueReusableCell(withIdentifier: MPPositive_HomeSinglesTableViewCellID, for: indexPath) as! MPPositive_HomeSinglesTableViewCell
cell.browseViewModel = browseModuleLists[indexPath.section]
return cell
}else {
let cell = tableView.dequeueReusableCell(withIdentifier: MPPositive_HomeShowTableViewCellID, for: indexPath) as! MPPositive_HomeShowTableViewCell
cell.browseViewModel = browseModuleLists[indexPath.section]
if let first = browseModuleLists[indexPath.section].items.first, first.browseItem.itemType == .single, first.browseItem.pageType == "MUSIC_VIDEO_TYPE_OMV" {
cell.showType = .Fifth
}else {
//
if browseModuleLists[indexPath.section].items.first?.browseItem.pageType == "MUSIC_PAGE_TYPE_ARTIST" {
cell.showType = .Fourth
}else {
cell.showType = .Third
}
}
cell.requestNextBlock = {
[weak self] (item) in
guard let self = self else {return}
switch item.browseItem.itemType {
case .single:
///
MPPositive_Debouncer.shared.call {
[weak self] in
guard let self = self else {return}
guard MP_NetWorkManager.shared.netWorkStatu == .reachable else {
MP_HUD.text("Weak connection.", delay: 2.0, completion: nil)
return
}
MP_AnalyticsManager.shared.song_clickAction("Mood")
//
MP_PlayerManager.shared.loadPlayer = nil
//
NotificationCenter.notificationKey.post(notificationName: .pup_player_vc)
MP_AnalyticsManager.shared.player_b_impAction()
//next
MP_NetWorkManager.shared.requestNextList(item.browseItem.playListId ?? "", videoId: item.browseItem.videoId ?? ""){ [weak self] listSongs in
guard let self = self else {return}
//playerloadViewModel
let lodaViewModel = MPPositive_PlayerLoadViewModel(listSongs, currentVideoId: item.browseItem.videoId ?? "")
lodaViewModel.improveData(item.browseItem.videoId ?? "")
//
MP_PlayerManager.shared.setPlayType(.normal)
MP_PlayerManager.shared.loadPlayer = lodaViewModel
MP_AnalyticsManager.shared.player_b_listAction()
}
}
case .list:
//
let listVC = MPPositive_ListShowViewController(item.browseItem.browseId ?? "", params: "", title: item.title ?? "", subtitle: item.subtitle ?? "")
navigationController?.pushViewController(listVC, animated: true)
case .artist:
//
let artistVC = MPPositive_ArtistShowViewController(item.browseItem.artistId ?? "")
navigationController?.pushViewController(artistVC, animated: true)
default:
break
}
}
cell.findMoreBlock = {
[weak self] in
guard let self = self else {return}
let moreVC = MPPositive_MoreContentViewController(browseModuleLists[indexPath.section])
navigationController?.pushViewController(moreVC, animated: true)
}
return cell
}
}
}

View File

@ -57,18 +57,21 @@ class MPPositive_SearchResultShowViewController: MPPositive_BaseViewController,
}
}
}
private var isShowAd = true
//
private var searchText:String?
//MARK: - View
private lazy var suggestionView:MPPositive_SearchSuggestionsView = .init(frame: .zero)
//MARK: - View
private lazy var resultsShowView:MPPositive_SearchResultsShowView = .init(frame: .zero)
private lazy var resultsShowView:MPPositive_SearchResultsShowView = .init(frame: .zero, isShowAd: self.isShowAd)
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
init(_ text:String) {
init(_ text:String, isShowAd:Bool = true) {
super.init(nibName: nil, bundle: nil)
self.isShowAd = isShowAd
searchTextField.text = text
searchText = text
resultsShowView.loadModel = .init(text)

View File

@ -14,7 +14,8 @@ class MPPositive_SearchViewController: MPPositive_BaseViewController {
imageView.contentMode = .scaleAspectFill
return imageView
}()
private lazy var collectionView:UICollectionView = {
//
private lazy var historyCollectionView:UICollectionView = {
let layout = MPPositive_TagFlowLayout()
layout.delegate = self
let collectionView:UICollectionView = .init(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height), collectionViewLayout: layout)
@ -27,6 +28,21 @@ class MPPositive_SearchViewController: MPPositive_BaseViewController {
return collectionView
}()
private let MPPositive_SearchTagCollectionViewCellID = "MPPositive_SearchTagCollectionViewCell"
//
private lazy var grideCollectionView:UICollectionView = {
let layout = UICollectionViewFlowLayout()
layout.itemSize = .init(width: 162*width, height: 60*width)
layout.sectionInset = .init(top: 20*width, left: 18*width, bottom: 70*width, right: 18*width)
let collectionView = UICollectionView(frame: .init(x: 0, y: 0, width: screen_Width, height: screen_Height), collectionViewLayout: layout)
collectionView.showsVerticalScrollIndicator = false
collectionView.showsHorizontalScrollIndicator = false
collectionView.backgroundColor = .clear
collectionView.dataSource = self
collectionView.delegate = self
collectionView.register(MPPositive_SearchGrideCollectionViewCell.self, forCellWithReuseIdentifier: MPPositive_SearchGrideCollectionViewCellID)
return collectionView
}()
fileprivate let MPPositive_SearchGrideCollectionViewCellID = "MPPositive_SearchGrideCollectionViewCell"
//
private lazy var historyLabel:UILabel = createLabel("History", font: .systemFont(ofSize: 14*width, weight: .regular), textColor: .init(hex: "#666666"), textAlignment: .left)
//
@ -43,16 +59,25 @@ class MPPositive_SearchViewController: MPPositive_BaseViewController {
//广
MP_AdMobManager.shared.configureSreachNativeAd(rootController: self)
MP_AdMobManager.shared.loadSearchNativeAd()
NotificationCenter.notificationKey.add(observer: self, selector: #selector(grideReloadAction(_ :)), notificationName: .search_gride_reload)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
MP_AnalyticsManager.shared.search_pvAction()
collectionView.reloadData()
MPPositive_LoadCoreModel.shared.reloadSearchTags {
[weak self] in
guard let self = self else {return}
historyCollectionView.reloadData()
}
grideCollectionView.reloadData()
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
}
deinit{
NotificationCenter.default.removeObserver(self)
}
//
private func configure() {
let searchView = createSearchView()
@ -78,12 +103,17 @@ class MPPositive_SearchViewController: MPPositive_BaseViewController {
make.centerY.equalTo(deleteBtn)
make.left.equalToSuperview().offset(18*width)
}
view.addSubview(collectionView)
collectionView.snp.makeConstraints { make in
view.addSubview(historyCollectionView)
historyCollectionView.snp.makeConstraints { make in
make.left.right.equalToSuperview()
make.top.equalTo(deleteBtn.snp.bottom).offset(6*width)
make.height.equalTo(130*width)
}
view.addSubview(grideCollectionView)
grideCollectionView.snp.makeConstraints { make in
make.top.equalTo(historyCollectionView.snp.bottom)
make.left.right.bottom.equalToSuperview()
}
}
//
private func createSearchView() -> UIView{
@ -110,6 +140,14 @@ class MPPositive_SearchViewController: MPPositive_BaseViewController {
searchView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(searchClick(_:))))
return searchView
}
//
@objc private func grideReloadAction(_ sender:Notification) {
DispatchQueue.main.async {
[weak self] in
guard let self = self else {return}
grideCollectionView.reloadData()
}
}
//
@objc fileprivate func searchClick(_ sender:UITapGestureRecognizer) {
let resultVC = MPPositive_SearchResultShowViewController()
@ -124,7 +162,7 @@ class MPPositive_SearchViewController: MPPositive_BaseViewController {
MPPositive_LoadCoreModel.shared.reloadSearchTags {
[weak self] in
guard let self = self else {return}
collectionView.reloadData()
historyCollectionView.reloadData()
}
}
}
@ -139,17 +177,36 @@ extension MPPositive_SearchViewController: UICollectionViewDataSource, UICollect
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return MPPositive_LoadCoreModel.shared.searchTags.count > 10 ? 10:MPPositive_LoadCoreModel.shared.searchTags.count
if collectionView == historyCollectionView {
return MPPositive_LoadCoreModel.shared.searchTags.count > 10 ? 10:MPPositive_LoadCoreModel.shared.searchTags.count
}else {
return MPPositive_GridLoadViewModel.shared.grideViewModels.count
}
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MPPositive_SearchTagCollectionViewCellID, for: indexPath) as! MPPositive_SearchTagCollectionViewCell
cell.setText(MPPositive_LoadCoreModel.shared.searchTags[indexPath.row].text)
return cell
if collectionView == historyCollectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MPPositive_SearchTagCollectionViewCellID, for: indexPath) as! MPPositive_SearchTagCollectionViewCell
cell.setText(MPPositive_LoadCoreModel.shared.searchTags[indexPath.row].text)
return cell
}else {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: MPPositive_SearchGrideCollectionViewCellID, for: indexPath) as! MPPositive_SearchGrideCollectionViewCell
cell.gride = MPPositive_GridLoadViewModel.shared.grideViewModels[indexPath.row]
return cell
}
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let text = MPPositive_LoadCoreModel.shared.searchTags[indexPath.row].text ?? ""
let resultVC = MPPositive_SearchResultShowViewController(text)
navigationController?.pushViewController(resultVC, animated: false)
if collectionView == historyCollectionView {
let text = MPPositive_LoadCoreModel.shared.searchTags[indexPath.row].text ?? ""
let resultVC = MPPositive_SearchResultShowViewController(text)
navigationController?.pushViewController(resultVC, animated: false)
}else {
if indexPath.row <= (MPPositive_GridLoadViewModel.shared.grideViewModels.count - 1) {
let item = MPPositive_GridLoadViewModel.shared.grideViewModels[indexPath.row]
MP_AnalyticsManager.shared.grid_mood_clickAction(item.title ?? "")
let moodVC = MPPositive_GrideMoodViewController(item.grid.browseId, params: item.grid.params, title: item.title ?? "")
navigationController?.pushViewController(moodVC, animated: false)
}
}
}
}
//MARK: -

View File

@ -81,7 +81,7 @@ class MPPositive_HomeSinglesTableViewCell: UITableViewCell, UIViewControllerTran
override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize {
let size = super.systemLayoutSizeFitting(targetSize, withHorizontalFittingPriority: horizontalFittingPriority, verticalFittingPriority: verticalFittingPriority)
collectionView.layoutIfNeeded()
let height = layout.itemSize.height*3 + layout.sectionInset.top
let height = layout.itemSize.height*3 + layout.sectionInset.top + 10
return CGSize(width: size.width, height: size.height + height)
}
}

View File

@ -0,0 +1,45 @@
//
// MPPositive_SearchGrideCollectionViewCell.swift
// relax.offline.mp3.music
//
// Created by Mr.Zhou on 2024/7/12.
//
import UIKit
import MarqueeLabel
class MPPositive_SearchGrideCollectionViewCell: UICollectionViewCell {
//
private lazy var colorView:UIView = .init()
//Label
private lazy var titleLabel:UILabel = createMarQueeLabel("Loading", font: .systemFont(ofSize: 16, weight: .bold), textColor: .white)
var gride:MPPositive_GridViewModel!{
didSet{
colorView.backgroundColor = .randomColor
titleLabel.text = gride.title
}
}
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = .init(hex: "#1F1F1F")
layer.masksToBounds = true
layer.cornerRadius = 10*width
confirgue()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
//
private func confirgue() {
addSubview(colorView)
colorView.snp.makeConstraints { make in
make.top.left.bottom.equalToSuperview()
make.width.equalToSuperview().multipliedBy(0.2)
}
addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalTo(colorView.snp.right).offset(12*width)
make.right.equalToSuperview().offset(-12*width)
}
}
}

View File

@ -17,17 +17,19 @@ class MPPositive_SearchResultsShowView: UIView {
if loadModel == nil {
emptyImageView.isHidden = false
}else {
MP_AdMobManager.shared.showSearchInterstitialAdIfAvailable { [weak self] ad in
guard let self = self else {return}
//
if loadModel?.sectionLists?.count != nil {
//
MP_AdMobManager.shared.setInterstitialSwitch(false)
}else {
MP_AdMobManager.shared.isShowingSearchInterstitialAd = true
//
MP_AdMobManager.shared.setInterstitialSwitch(true)
ad.present(fromRootViewController: nil)
if isShowAd == true {
MP_AdMobManager.shared.showSearchInterstitialAdIfAvailable { [weak self] ad in
guard let self = self else {return}
//
if loadModel?.sectionLists?.count != nil {
//
MP_AdMobManager.shared.setInterstitialSwitch(false)
}else {
MP_AdMobManager.shared.isShowingSearchInterstitialAd = true
//
MP_AdMobManager.shared.setInterstitialSwitch(true)
ad.present(fromRootViewController: nil)
}
}
}
//
@ -43,6 +45,7 @@ class MPPositive_SearchResultsShowView: UIView {
dataSource.titles = titles
dataSource.reloadData(selectedIndex: 0)
segmentView.reloadData()
segmentView.selectItemAt(index: 0)
emptyImageView.isHidden = !(titles.count == 0)
}
}
@ -102,8 +105,11 @@ class MPPositive_SearchResultsShowView: UIView {
return imageView
}()
var scrollBlock:(() -> Void)?
override init(frame: CGRect) {
//广
private var isShowAd:Bool = true
init(frame: CGRect, isShowAd:Bool = true) {
super.init(frame: frame)
self.isShowAd = isShowAd
backgroundColor = .init(hex: "1A1A1A")
configure()
MP_AdMobManager.shared.onSearchNativeAdBlock = {

View File

@ -63,11 +63,17 @@ class MPSideA_LoadDataMusic: NSObject {
homeSecondMusics = locallistMusics.filter{($0.type == .Second)}
homeThirdMusics = convertToTwoArray(locallistMusics.filter{($0.type == .Third)}, raw: 3)
//
homeZeroMusics.append(homeThirdMusics.last!.last!)
homeZeroMusics.append(homeSecondMusics.last!)
homeZeroMusics.append(homeFirstMusics.last!)
if userlistMusics.count != 0 {
homeZeroMusics.append(userlistMusics.last!)
if let last = homeThirdMusics.last?.last {
homeZeroMusics.append(last)
}
if let last = homeSecondMusics.last {
homeZeroMusics.append(last)
}
if let last = homeFirstMusics.last {
homeZeroMusics.append(last)
}
if userlistMusics.count != 0, let last = userlistMusics.last {
homeZeroMusics.append(last)
}
completion?()
}

View File

@ -259,6 +259,7 @@ extension MPSideA_TabBarController {
//MARK: - 广 GADFullScreenContentDelegate
//广
func adWillPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = true
if ad === MP_AdMobManager.shared.playInterstitialAd {//广
print("当前展示的广告是播放插页广告广告ID--\(MP_AdMobManager.shared.playInterstitialAd?.adUnitID ?? "")")
MP_AnalyticsManager.shared.play_ads_showSuccessAction()
@ -266,6 +267,7 @@ extension MPSideA_TabBarController {
}
//广
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
// UIApplication.shared.isStatusBarHidden = false
MP_AdMobManager.shared.interstitialDate = Date()
if ad === MP_AdMobManager.shared.playInterstitialAd {//广
let UUID = MP_AdMobManager.shared.playInterstitialAd?.adUnitID ?? ""
@ -282,10 +284,15 @@ extension MPSideA_TabBarController {
self?.present(playerVC, animated: true)
}
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
//广
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
// UIApplication.shared.isStatusBarHidden = false
MP_AdMobManager.shared.interstitialDate = Date()
if ad === MP_AdMobManager.shared.playInterstitialAd {//广
let UUID = MP_AdMobManager.shared.playInterstitialAd?.adUnitID ?? ""
@ -304,6 +311,10 @@ extension MPSideA_TabBarController {
// self?.present(playerVC, animated: true)
// }
}
accessAppdelegate.setAudioSupport()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3){
[weak self] in
guard let self = self else {return}
accessAppdelegate.setAudioSupport()
}
}
}