Pārlūkot izejas kodu

feat:修复部分bug,调到第一个tab

kailen 2 mēneši atpakaļ
vecāks
revīzija
2b5a096cf4

+ 2 - 1
Podfile

@@ -27,7 +27,8 @@ target 'TSLiveWallpaper' do
   pod 'Localize-Swift', '~> 3.2'
   pod 'BetterSegmentedControl', '~> 2.0'
   pod 'Google-Mobile-Ads-SDK'
-
+  pod 'ADManager', :path => '../TSCoacopods/ADManager'
+  
 end
 
 

+ 7 - 1
Podfile.lock

@@ -1,4 +1,6 @@
 PODS:
+  - ADManager (1.0):
+    - Google-Mobile-Ads-SDK
   - AFNetworking (4.0.1):
     - AFNetworking/NSURLSession (= 4.0.1)
     - AFNetworking/Reachability (= 4.0.1)
@@ -111,6 +113,7 @@ PODS:
   - YYModel (1.0.4)
 
 DEPENDENCIES:
+  - ADManager (from `../TSCoacopods/ADManager`)
   - Alamofire
   - BetterSegmentedControl (~> 2.0)
   - Google-Mobile-Ads-SDK
@@ -151,6 +154,8 @@ SPEC REPOS:
     - YYModel
 
 EXTERNAL SOURCES:
+  ADManager:
+    :path: "../TSCoacopods/ADManager"
   IJKMediaPlayerKit:
     :podspec: https://github.com/debugly/ijkplayer/releases/download/k0.11.8/IJKMediaPlayerKit.spec.json
   KLExtension:
@@ -173,6 +178,7 @@ CHECKOUT OPTIONS:
     :git: https://gitee.com/WanlanNeel/tsvideo-kit.git
 
 SPEC CHECKSUMS:
+  ADManager: 69cd1b8805b2e64a72315ed2abfa1f1c02f8f879
   AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58
   Alamofire: 7193b3b92c74a07f85569e1a6c4f4237291e7496
   BetterSegmentedControl: 09607b27861d49cbce48b7673b74f9150a3d371a
@@ -197,6 +203,6 @@ SPEC CHECKSUMS:
   TZImagePickerController: d084a7b97c82d387e7669dd86dc9a9057500aacf
   YYModel: 2a7fdd96aaa4b86a824e26d0c517de8928c04b30
 
-PODFILE CHECKSUM: db6fcc789e5b50316ea28fb8e59556cae05e1117
+PODFILE CHECKSUM: 436b32429cb708cca90f47b70a0a376c1a6e0417
 
 COCOAPODS: 1.15.2

+ 12 - 0
TSLiveWallpaper.xcodeproj/project.pbxproj

@@ -103,6 +103,7 @@
 		60553FE32D3DF12200BAAD7F /* CustomSegementItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60553FE22D3DF12200BAAD7F /* CustomSegementItem.swift */; };
 		606372D82D545E6C005C82CF /* Example Music.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 606372D72D545E6C005C82CF /* Example Music.mp3 */; };
 		606372DA2D545F0D005C82CF /* ExampleIniter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606372D92D545F0D005C82CF /* ExampleIniter.swift */; };
+		606372DD2D54999C005C82CF /* ADScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = 606372DC2D54999C005C82CF /* ADScene.swift */; };
 		60F82C0F2D43295100FFB08D /* MusicContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F82C0E2D43295100FFB08D /* MusicContainerViewController.swift */; };
 		60F82C112D43298800FFB08D /* MusicContainerViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 60F82C102D43298800FFB08D /* MusicContainerViewModel.swift */; };
 		A81CA4652D15685F00A3AAC8 /* TSLaunchVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A81CA4642D15685D00A3AAC8 /* TSLaunchVC.swift */; };
@@ -305,6 +306,7 @@
 		60553FE22D3DF12200BAAD7F /* CustomSegementItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSegementItem.swift; sourceTree = "<group>"; };
 		606372D72D545E6C005C82CF /* Example Music.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "Example Music.mp3"; sourceTree = "<group>"; };
 		606372D92D545F0D005C82CF /* ExampleIniter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleIniter.swift; sourceTree = "<group>"; };
+		606372DC2D54999C005C82CF /* ADScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ADScene.swift; sourceTree = "<group>"; };
 		60F82C0E2D43295100FFB08D /* MusicContainerViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicContainerViewController.swift; sourceTree = "<group>"; };
 		60F82C102D43298800FFB08D /* MusicContainerViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicContainerViewModel.swift; sourceTree = "<group>"; };
 		71E5F623537702A8306DF3C8 /* Pods-TSLiveWallpaper.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-TSLiveWallpaper.release.xcconfig"; path = "Target Support Files/Pods-TSLiveWallpaper/Pods-TSLiveWallpaper.release.xcconfig"; sourceTree = "<group>"; };
@@ -740,6 +742,14 @@
 			path = Example;
 			sourceTree = "<group>";
 		};
+		606372DB2D549998005C82CF /* AdMob */ = {
+			isa = PBXGroup;
+			children = (
+				606372DC2D54999C005C82CF /* ADScene.swift */,
+			);
+			path = AdMob;
+			sourceTree = "<group>";
+		};
 		A81CA45F2D1567CD00A3AAC8 /* LaunchVC */ = {
 			isa = PBXGroup;
 			children = (
@@ -859,6 +869,7 @@
 		A81CA48C2D15855300A3AAC8 /* Business */ = {
 			isa = PBXGroup;
 			children = (
+				606372DB2D549998005C82CF /* AdMob */,
 				60553F022D3B4DF800BAAD7F /* TSMusic */,
 				A8F76C3A2D35022300AA6E93 /* TSPurchaseMembershipVC */,
 				A8477C952D2272FB00DF0B93 /* TSBusinessWebVC */,
@@ -1379,6 +1390,7 @@
 				60553FD72D3B54A400BAAD7F /* GradientText.swift in Sources */,
 				60553FD82D3B54A400BAAD7F /* LWBaseNavigationController.swift in Sources */,
 				60553FD92D3B54A400BAAD7F /* GradientBackgroundModifier.swift in Sources */,
+				606372DD2D54999C005C82CF /* ADScene.swift in Sources */,
 				A81F5B5D2D1A906C00740085 /* TSHomeDataModel.swift in Sources */,
 				A8F778B02D1AC17500BF55D5 /* TSBaseView.swift in Sources */,
 				A81CA49B2D1652CA00A3AAC8 /* TSHomeVC.swift in Sources */,

+ 74 - 0
TSLiveWallpaper/Business/AdMob/ADScene.swift

@@ -0,0 +1,74 @@
+//
+//  ADScene.swift
+//
+
+/**
+ 随机壁纸的广告;
+ ca-app-pub-4941656534177879/9888331446  下载的激励广告
+ ca-app-pub-4941656534177879/5488145330 开屏广告
+ ca-app-pub-4941656534177879/2201413111 播放的插屏广告(冷启动后,每个播放列表只展示一次,就是比如第一次点击没出,继续拉取,第二次点击出,第二次没出,第三次出)
+ ca-app-pub-4941656534177879/9397376852 搜索广告(每次第一次点击搜索框出广告)
+ */
+
+import ADManager
+import Foundation
+
+// TODO: !!!
+
+// #if DEBUG
+// private let GAD_ID_Launch                   = "ca-app-pub-3940256099942544/5575463023"
+// private let GAD_ID_Search_Insert            = "ca-app-pub-3940256099942544/4411468910"
+// private let GAD_ID_Play_Insert              = "ca-app-pub-3940256099942544/4411468910"
+// private let GAD_ID_Download_Reward          = "ca-app-pub-3940256099942544/1712485313"
+// #else
+
+// 开屏广告
+private let GAD_ID_Launch = "ca-app-pub-4941656534177879/5488145330"
+// 点击搜索时弹出的插屏广告
+private let GAD_ID_Search_Insert = "ca-app-pub-4941656534177879/9397376852"
+// 播放视频时弹出的插屏广告
+private let GAD_ID_Play_Insert = "ca-app-pub-4941656534177879/2201413111"
+// 下载视频弹出的激励广告
+private let GAD_ID_Download_Reward = "ca-app-pub-4941656534177879/9888331446"
+// #endif
+
+enum ADScene: CaseIterable, ADSceneProtocol {
+    case unknow
+    case launch // 开屏
+
+    case searchInsert // 进入搜索,插屏广告
+    case playInsert // 第一次进入视频播放,插屏广告
+    case downloadReward // 下载视频,激励广告
+
+    static var prepareScenes: [ADScene] {
+        return [.searchInsert, .playInsert, .downloadReward]
+    }
+
+    var adId: String {
+        switch self {
+        case .launch:
+            return GAD_ID_Launch
+        case .searchInsert:
+            return GAD_ID_Search_Insert
+        case .playInsert:
+            return GAD_ID_Play_Insert
+        case .downloadReward:
+            return GAD_ID_Download_Reward
+        case .unknow:
+            return ""
+        }
+    }
+
+    var adType: ADType {
+        switch self {
+        case .launch:
+            return .launch
+        case .searchInsert, .playInsert:
+            return .interstitial
+        case .downloadReward:
+            return .reward
+        case .unknow:
+            return .unknow
+        }
+    }
+}

+ 2 - 0
TSLiveWallpaper/Business/TSMusic/Detail/Controller/PlayDetailViewController.swift

@@ -159,6 +159,7 @@ class PlayDetailViewController: LWBGViewController {
         guard let mVideo = video else {
             return
         }
+        playControl.player.view.isHidden = false
         if mVideo.isOnline {
             placeHolderView.isHidden = true
             playControl.player.presentView.placeholderImageView.kf.setImage(with: mVideo.iconUrl)
@@ -167,6 +168,7 @@ class PlayDetailViewController: LWBGViewController {
             if mVideo.isAudio {
                 placeHolderView.isHidden = false
                 placeHolderView.iconView.image = UIImage(named: "ic_default")
+                playControl.player.view.isHidden = true
             } else {
                 placeHolderView.iconView.kf.setImage(with: mVideo.iconUrl)
                 if mVideo.videoStatus == .cached {

+ 1 - 1
TSLiveWallpaper/Business/TSMusic/PlayList/Views/PlayListCell.swift

@@ -17,7 +17,7 @@ class PlayListCell: UITableViewCell {
 
     lazy var iconView: UIImageView = {
         let img: UIImageView = .init(image: .icDefault)
-        img.customCornerRadius = 12
+        img.customCornerRadius = 8
         img.contentMode = .scaleAspectFill
         return img
     }()

+ 8 - 12
TSLiveWallpaper/Business/TSTabBarController/TSTabBarController.swift

@@ -5,11 +5,10 @@
 //  Created by 100Years on 2024/12/20.
 //
 
-import UIKit
 import TSVideoKit
+import UIKit
 
 class TSTabBarController: UITabBarController {
-        
     lazy var miniBar: PlayMiniBar = PlayMiniBar()
     lazy var playerVc: PlayDetailViewController = .init()
     lazy var multiSelectView: CWMutiSelectOpeateView = {
@@ -46,18 +45,18 @@ class TSTabBarController: UITabBarController {
     }
 
     @objc private func setUpData() {
-        viewControllerArray = ["TSHomeVC", "TSRandomWallpaperVC", "MusicContainerViewController", "TSMineVC"]
+        viewControllerArray = ["MusicContainerViewController", "TSHomeVC", "TSRandomWallpaperVC", "TSMineVC"]
 
         selectedImageArray = [
+            "tabbar_select_music",
             "tabbar_select_home",
             "tabbar_select_random",
-            "tabbar_select_music",
             "tabbar_select_mine",
         ]
         unselectedImageArray = [
+            "tabbar_unSelect_music",
             "tabbar_unSelect_home",
             "tabbar_unSelect_random",
-            "tabbar_unSelect_music",
             "tabbar_unSelect_mine",
         ]
 
@@ -130,7 +129,7 @@ class TSTabBarController: UITabBarController {
         debugPrint("TSTabBarController deinit")
         NotificationCenter.default.removeObserver(self)
     }
-    
+
     func initExampleData() {
         if UserDefaults.standard.string(forKey: "InitExampleData") == nil {
             if let path = Bundle.main.path(forResource: "Example Music", ofType: ".mp3") {
@@ -158,7 +157,6 @@ extension TSTabBarController: UITabBarControllerDelegate {
 // MARK: 音乐布局相关
 
 extension TSTabBarController {
-    
     private func addMusicAndMiniBar() {
         let tap = UITapGestureRecognizer(target: self, action: #selector(showPlayDetailVc))
         miniBar.bgImageView.addGestureRecognizer(tap)
@@ -214,18 +212,16 @@ extension TSTabBarController {
 // MARK: 音乐操作相关
 
 extension TSTabBarController {
-    
-    func showMultiSelectView(){
+    func showMultiSelectView() {
         multiSelectView.isHidden = false
         view.bringSubviewToFront(multiSelectView)
     }
-    
-    func hideMultiSelectView(){
+
+    func hideMultiSelectView() {
         multiSelectView.isHidden = true
         view.bringSubviewToFront(multiSelectView)
     }
 
-
     @objc func deleteButtonAction() {
         PlayerManager.shared.deleteSelectedVideos()
     }