Browse Source

录制完成

南鑫林 5 years ago
parent
commit
08fd3a0990

+ 6 - 6
RainbowPlanet/Podfile

@@ -106,15 +106,15 @@ target 'RainbowPlanet' do
   #=====================AliyunVideoSDK===========
   #共同依赖的库
   pod 'QuCore-ThirdParty'
-  pod 'AlivcConan', '0.9.5'
-#  pod 'AlivcConan'
+#  pod 'AlivcConan', '0.9.5'
+  pod 'AlivcConan'
   #短视频SDK
-  pod 'AliyunVideoSDKPro', '3.11.0'  #短视频核心库
-#  pod 'AliyunVideoSDKPro'
+#  pod 'AliyunVideoSDKPro', '3.11.0'  #短视频核心库
+  pod 'AliyunVideoSDKPro'
   pod 'VODUpload'  #短视频上传,不使用上传功能可以不依赖此库
   #播放器SDK
-  pod 'AliPlayerPartSDK_iOS', '4.7.1' #播放器和短视频SDK同时集成时使用这个
-#   pod 'AliPlayerPartSDK_iOS'
+#  pod 'AliPlayerPartSDK_iOS', '4.7.1' #播放器和短视频SDK同时集成时使用这个
+   pod 'AliPlayerPartSDK_iOS'
   #    pod 'AliPlayerSDK_iOS', '4.7.1' #单独集成播放器时使用这个
   
   #=====================融云IMSDK===========

+ 10 - 10
RainbowPlanet/Podfile.lock

@@ -18,11 +18,11 @@ PODS:
   - AliPlayerPartSDK_iOS (4.7.1):
     - AliPlayerPartSDK_iOS/AliPlayerPartSDK (= 4.7.1)
   - AliPlayerPartSDK_iOS/AliPlayerPartSDK (4.7.1)
-  - AlivcConan (0.9.5):
-    - AlivcConan/AlivcConan (= 0.9.5)
-  - AlivcConan/AlivcConan (0.9.5)
+  - AlivcConan (1.0.0):
+    - AlivcConan/AlivcConan (= 1.0.0)
+  - AlivcConan/AlivcConan (1.0.0)
   - AliyunOSSiOS (2.10.7)
-  - AliyunVideoSDKPro (3.11.0)
+  - AliyunVideoSDKPro (3.12.0)
   - BaiduMapKit (5.0.0)
   - BMKLocationKit (1.5.0)
   - Cache (5.2.0)
@@ -111,9 +111,9 @@ PODS:
 DEPENDENCIES:
   - AFNetworking (~> 3.0)
   - Alamofire
-  - AliPlayerPartSDK_iOS (= 4.7.1)
-  - AlivcConan (= 0.9.5)
-  - AliyunVideoSDKPro (= 3.11.0)
+  - AliPlayerPartSDK_iOS
+  - AlivcConan
+  - AliyunVideoSDKPro
   - BaiduMapKit
   - BMKLocationKit (= 1.5.0)
   - Cache
@@ -221,9 +221,9 @@ SPEC CHECKSUMS:
   AFNetworking: b6f891fdfaed196b46c7a83cf209e09697b94057
   Alamofire: 85e8a02c69d6020a0d734f6054870d7ecb75cf18
   AliPlayerPartSDK_iOS: b7acc7cf47271f67a4eed38185438371e382b749
-  AlivcConan: 9dccc32986024768bb5f50e14ad54490123903c7
+  AlivcConan: 3e339a2bc6ce11e47c20ff4f2bd9c0a0dd90ebc8
   AliyunOSSiOS: 602b6a4e70e62a5f0a6431c20496343141d7e66f
-  AliyunVideoSDKPro: da710c1e7fb93b1e9a741b3619814c6608780b4b
+  AliyunVideoSDKPro: 3f19f021ab48fbc41ac667a08322a506950281de
   BaiduMapKit: 3a875b001293a9ee6692febd549d8bf82108dbac
   BMKLocationKit: 40d267478acd8704ddebd0e9deaddc727b13df9f
   Cache: 807c5d86d01a177f06ede9865add3aea269bbfd4
@@ -271,6 +271,6 @@ SPEC CHECKSUMS:
   YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
   ZipArchive: e25a4373192673e3229ac8d6e9f64a3e5713c966
 
-PODFILE CHECKSUM: ae0c1a3403fa6fc300fe512922451d01fa32f74a
+PODFILE CHECKSUM: b27e2ccae0be82e0a4ac1b5a2293ef59c10e73c5
 
 COCOAPODS: 1.8.4

+ 33 - 13
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -190,6 +190,7 @@
 		A747D846235D9DF6007F4E33 /* CircleAlbumSectionHeaderCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A747D845235D9DF6007F4E33 /* CircleAlbumSectionHeaderCollectionReusableView.swift */; };
 		A747D848235DA16F007F4E33 /* CircleAlbumSectionFooterCollectionReusableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A747D847235DA16F007F4E33 /* CircleAlbumSectionFooterCollectionReusableView.swift */; };
 		A74CF41D23715A9500BA620E /* Extension+DispatchQueue.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74CF41C23715A9500BA620E /* Extension+DispatchQueue.swift */; };
+		A74CF4272372DB2400BA620E /* PublishEditNewViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74CF4262372DB2400BA620E /* PublishEditNewViewController.swift */; };
 		A74D9D572327B54100F05C14 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74D9D562327B54100F05C14 /* NotificationService.swift */; };
 		A74D9D5B2327B54100F05C14 /* NotificationService.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = A74D9D542327B54100F05C14 /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
 		A74DF74922EAAF17007FB505 /* MJDIYFullScreenHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = A74DF74822EAAF17007FB505 /* MJDIYFullScreenHeader.swift */; };
@@ -933,6 +934,7 @@
 		A747D845235D9DF6007F4E33 /* CircleAlbumSectionHeaderCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleAlbumSectionHeaderCollectionReusableView.swift; sourceTree = "<group>"; };
 		A747D847235DA16F007F4E33 /* CircleAlbumSectionFooterCollectionReusableView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircleAlbumSectionFooterCollectionReusableView.swift; sourceTree = "<group>"; };
 		A74CF41C23715A9500BA620E /* Extension+DispatchQueue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Extension+DispatchQueue.swift"; sourceTree = "<group>"; };
+		A74CF4262372DB2400BA620E /* PublishEditNewViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishEditNewViewController.swift; sourceTree = "<group>"; };
 		A74D9D542327B54100F05C14 /* NotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; };
 		A74D9D562327B54100F05C14 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
 		A74D9D582327B54100F05C14 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
@@ -2653,6 +2655,22 @@
 			path = View;
 			sourceTree = "<group>";
 		};
+		A74CF4242372CD9100BA620E /* PublishEditNew */ = {
+			isa = PBXGroup;
+			children = (
+				A74CF4252372D7CE00BA620E /* ViewController */,
+			);
+			path = PublishEditNew;
+			sourceTree = "<group>";
+		};
+		A74CF4252372D7CE00BA620E /* ViewController */ = {
+			isa = PBXGroup;
+			children = (
+				A74CF4262372DB2400BA620E /* PublishEditNewViewController.swift */,
+			);
+			path = ViewController;
+			sourceTree = "<group>";
+		};
 		A74D9D552327B54100F05C14 /* NotificationService */ = {
 			isa = PBXGroup;
 			children = (
@@ -3444,6 +3462,7 @@
 		A7811CCC2323D25A00C2D8DE /* PublishNewModule */ = {
 			isa = PBXGroup;
 			children = (
+				A74CF4242372CD9100BA620E /* PublishEditNew */,
 				A7EE5AC5236C131C00309931 /* PublishNew */,
 				A70E3F2D236FF9520039D7FC /* PublishConfirmPhotoNew */,
 				A7EE5AE2236C131D00309931 /* PublishRecommendMusicNewController */,
@@ -4529,9 +4548,9 @@
 		A7EE5AC8236C131C00309931 /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A7EE5ACD236C131C00309931 /* PublishNewView */,
 				A7EE5AC9236C131C00309931 /* PublishNewProgress */,
 				A7EE5ACB236C131C00309931 /* PublishNewPopView */,
-				A7EE5ACD236C131C00309931 /* PublishNewView */,
 				A7EE5AD1236C131C00309931 /* PublishNewMusicView */,
 				A7EE5AD5236C131C00309931 /* PublishNewAuthorization */,
 				A7EE5AD7236C131C00309931 /* PublishNewEffect */,
@@ -5871,8 +5890,8 @@
 				A77F2C5A2231FB49001BD3F6 /* Frameworks */,
 				A77F2C5B2231FB49001BD3F6 /* Resources */,
 				A74D9D5F2327B54100F05C14 /* Embed App Extensions */,
-				39935CBFD70D065C2E9C2DFF /* [CP] Embed Pods Frameworks */,
-				34B1F4486D247516EBA6664E /* [CP] Copy Pods Resources */,
+				5255517EC082CDBDA16A6A75 /* [CP] Embed Pods Frameworks */,
+				633D32F14EB76DCDC1DC9853 /* [CP] Copy Pods Resources */,
 			);
 			buildRules = (
 			);
@@ -6054,38 +6073,38 @@
 /* End PBXResourcesBuildPhase section */
 
 /* Begin PBXShellScriptBuildPhase section */
-		34B1F4486D247516EBA6664E /* [CP] Copy Pods Resources */ = {
+		5255517EC082CDBDA16A6A75 /* [CP] Embed Pods Frameworks */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
 			);
 			inputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-resources-${CONFIGURATION}-input-files.xcfilelist",
+				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-frameworks-${CONFIGURATION}-input-files.xcfilelist",
 			);
-			name = "[CP] Copy Pods Resources";
+			name = "[CP] Embed Pods Frameworks";
 			outputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-resources-${CONFIGURATION}-output-files.xcfilelist",
+				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-frameworks-${CONFIGURATION}-output-files.xcfilelist",
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-resources.sh\"\n";
+			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-frameworks.sh\"\n";
 			showEnvVarsInLog = 0;
 		};
-		39935CBFD70D065C2E9C2DFF /* [CP] Embed Pods Frameworks */ = {
+		633D32F14EB76DCDC1DC9853 /* [CP] Copy Pods Resources */ = {
 			isa = PBXShellScriptBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
 			);
 			inputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-frameworks-${CONFIGURATION}-input-files.xcfilelist",
+				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-resources-${CONFIGURATION}-input-files.xcfilelist",
 			);
-			name = "[CP] Embed Pods Frameworks";
+			name = "[CP] Copy Pods Resources";
 			outputFileListPaths = (
-				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-frameworks-${CONFIGURATION}-output-files.xcfilelist",
+				"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-resources-${CONFIGURATION}-output-files.xcfilelist",
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-frameworks.sh\"\n";
+			shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-RainbowPlanet/Pods-RainbowPlanet-resources.sh\"\n";
 			showEnvVarsInLog = 0;
 		};
 		D3A9893FB9EA18608E79E053 /* [CP] Check Pods Manifest.lock */ = {
@@ -6180,6 +6199,7 @@
 				A714348722DD9D4700132DA9 /* RedemptionAreaViewController.swift in Sources */,
 				A73A56DE22DC9CCE004920FE /* UpdateVersionManager.swift in Sources */,
 				BD1DC6C5228CFD0B00B89C57 /* SwiftMoyaNetWorkServiceOrder.swift in Sources */,
+				A74CF4272372DB2400BA620E /* PublishEditNewViewController.swift in Sources */,
 				A72A72C422321DE000B21995 /* Extension+CAGradientLayer.swift in Sources */,
 				A7778CA72243A05400C7C47A /* IQKeyboardManagerSwiftManager.swift in Sources */,
 				A7D5F25C22C05E0800F8E9AF /* SwiftMoyaNetWorkServiceCommunity.swift in Sources */,

+ 2 - 0
RainbowPlanet/RainbowPlanet/Macro/Common.swift

@@ -20,6 +20,8 @@ let kAppDelegate : AppDelegate = (UIApplication.shared.delegate as! AppDelegate)
 
 //MARK: - 屏幕的高度
 ///屏幕宽度
+public let kScreenBounds = UIScreen.main.bounds
+///屏幕宽度
 public let kScreenWidth = UIScreen.main.bounds.size.width
 ///屏幕高度
 public let kScreenHeight = UIScreen.main.bounds.size.height

+ 3 - 0
RainbowPlanet/RainbowPlanet/Model/CommunityModel/CommunityRecommendMusicListModel.swift

@@ -41,6 +41,7 @@ class CommunityMusicItemModel : NSObject, Mappable{
     var name : String?
     var singer : String?
     var url : String?
+   
     
     // 本地添加,用于控制状态
     var isPlaying : Bool? = false
@@ -51,6 +52,8 @@ class CommunityMusicItemModel : NSObject, Mappable{
     var isSelected : Bool? = false
     // 是否使用
     var isUse :Bool? = false
+    /// 使用中的音乐路径
+    var publishNewMusicURL : URL? = nil
     
     
     class func newInstance(map: Map) -> Mappable?{

+ 30 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditNew/ViewController/PublishEditNewViewController.swift

@@ -0,0 +1,30 @@
+//
+//  PublishEditNewViewController.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/6.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishEditNewViewController: BaseViewController {
+
+    override func viewDidLoad() {
+        super.viewDidLoad()
+
+        // Do any additional setup after loading the view.
+    }
+    
+
+    /*
+    // MARK: - Navigation
+
+    // In a storyboard-based application, you will often want to do a little preparation before navigation
+    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+        // Get the new view controller using segue.destination.
+        // Pass the selected object to the new view controller.
+    }
+    */
+
+}

+ 62 - 20
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewMusicView/PublishNewMusicListView.swift

@@ -9,17 +9,15 @@
 import UIKit
 import JXSegmentedView
 
-/// 选中的音乐
-var publishNewMusicSelectedindexPath : IndexPath? = nil
-
 class PublishNewMusicListView: BaseView {
     
-    
     var categoryId : Int = 0
     var index : Int? = nil
-    
     var communityMusicItemModels : Array<CommunityMusicItemModel> = []
     
+    typealias UserMusicClosure = () -> Void
+    var userMusicClosure : UserMusicClosure?
+    
     override func setupViews() {
         addSubview(tableView)
     }
@@ -72,6 +70,7 @@ class PublishNewMusicListView: BaseView {
             MJRefreshManager.mjRefreshManagerLoadingStatus(tableView: self?.tableView,loadingStatus: loadingStatus)
         }
     }
+    
 
 }
 
@@ -87,11 +86,11 @@ extension PublishNewMusicListView : UITableViewDelegate, UITableViewDataSource {
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
         let cell = PublishNewMusicListViewTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
         let communityMusicItemModel = communityMusicItemModels[indexPath.row]
-        if publishNewMusicSelectedindexPath == nil {
+        if PublishNewMusicView.publishNewMusicSelectedIndexPath == nil {
             cell.isSelected = false
         }else {
-            if publishNewMusicSelectedindexPath?.section == index {
-                if publishNewMusicSelectedindexPath?.row == indexPath.row {
+            if PublishNewMusicView.publishNewMusicSelectedIndexPath?.section == index {
+                if PublishNewMusicView.publishNewMusicSelectedIndexPath?.row == indexPath.row {
                     cell.isSelected = true
                 }else {
                     cell.isSelected = false
@@ -100,14 +99,38 @@ extension PublishNewMusicListView : UITableViewDelegate, UITableViewDataSource {
                 cell.isSelected = false
             }
         }
+        
+        if PublishNewMusicView.publishNewMusicUseIndexPath != nil {
+            if PublishNewMusicView.publishNewMusicUseIndexPath?.section == index {
+                if PublishNewMusicView.publishNewMusicUseIndexPath?.row == indexPath.row {
+                    cell.playImageView.isHidden = false
+                    cell.useButton.isHidden = true
+                }else {
+                    cell.playImageView.isHidden = true
+                    cell.useButton.isHidden = false
+                }
+            }else {
+                    cell.playImageView.isHidden = true
+                    cell.useButton.isHidden = false
+            }
+        }
         cell.communityMusicItemModel = communityMusicItemModel
+        
+        cell.useClosure = {
+           [weak self,weak cell] in
+           PublishNewMusicView.publishNewMusicUseIndexPath = IndexPath(row: indexPath.row, section: self?.index ?? 0)
+           PublishNewMusicView.publishNewMusicUseURL = cell?.communityMusicItemModel?.publishNewMusicURL
+           if let userMusicClosure = self?.userMusicClosure {
+               userMusicClosure()
+           }
+       }
         return cell
     }
     
     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
         let cell = tableView.cellForRow(at: indexPath) as? PublishNewMusicListViewTableViewCell
-        if publishNewMusicSelectedindexPath?.row != indexPath.row || publishNewMusicSelectedindexPath?.section != index {
-           publishNewMusicSelectedindexPath = IndexPath(row: indexPath.row, section: index ?? 0)
+        if PublishNewMusicView.publishNewMusicSelectedIndexPath?.row != indexPath.row || PublishNewMusicView.publishNewMusicSelectedIndexPath?.section != index {
+           PublishNewMusicView.publishNewMusicSelectedIndexPath = IndexPath(row: indexPath.row, section: index ?? 0)
            var mp3url = kApiDownloadPrefix() + "/music/"
            mp3url = cell?.communityMusicItemModel?.url?.substring(fromIndex: mp3url.count) ?? ""
            cell?.communityMusicItemModel?.musicName = mp3url
@@ -120,24 +143,43 @@ extension PublishNewMusicListView : UITableViewDelegate, UITableViewDataSource {
                                PathURLManager.projectDownloadsPath(parentURL:
                                    PathURLManager.projectDocumentPath())))))!
            if FileManager.default.fileExists(atPath: pathUrl.path) {
-              
+                
                //播放
-               AliPlayerManager.shared.initAudioPlayer(pathUrl: pathUrl.path,startPlayClosure: {
-                   cell?.isSelected = true
-                   cell?.iconImageView.isHidden = false
+               AliPlayerManager.shared.initAudioPlayer(pathUrl: pathUrl.path,startPlayClosure: { [weak cell] in
+                    cell?.communityMusicItemModel?.publishNewMusicURL = pathUrl
+                    if PublishNewMusicView.publishNewMusicUseIndexPath != nil {
+                        if PublishNewMusicView.publishNewMusicSelectedIndexPath == PublishNewMusicView.publishNewMusicUseIndexPath {
+                            cell?.isSelected = true
+                            cell?.iconImageView.isHidden = false
+                            cell?.playImageView.isHidden = false
+                            cell?.useButton.isHidden = true
+                        }else {
+                            cell?.isSelected = true
+                            cell?.iconImageView.isHidden = false
+                            cell?.playImageView.isHidden = true
+                            cell?.useButton.isHidden = false
+                        }
+                    }else {
+                        cell?.isSelected = true
+                        cell?.iconImageView.isHidden = false
+                        cell?.playImageView.isHidden = true
+                        cell?.useButton.isHidden = false
+                    }
                })
            } else {
                 
-               SwiftMoyaNetWorkServiceDownLoad.shared().musicApi(mp3url: mp3url, progressClosure: { progress in
+               SwiftMoyaNetWorkServiceDownLoad.shared().musicApi(mp3url: mp3url, progressClosure: { [weak cell] progress in
                        cell?.activityIndicatorView.startAnimating()
                        cell?.iconImageView.isHidden = true
                        
-                   }, completion: { [weak self] (_) -> (Void) in
-                    
-                    if publishNewMusicSelectedindexPath?.row == indexPath.row && publishNewMusicSelectedindexPath?.section == self?.index {
+                   }, completion: { [weak self,weak cell] (_) -> (Void) in
+                   
+                    if PublishNewMusicView.publishNewMusicSelectedIndexPath?.row == indexPath.row && PublishNewMusicView.publishNewMusicSelectedIndexPath?.section == self?.index {
                         self?.tableView(tableView, didDeselectRowAt: indexPath)
                         //播放
                         AliPlayerManager.shared.initAudioPlayer(url: cell?.communityMusicItemModel?.url,startPlayClosure: {
+                            [weak cell] in
+                            cell?.communityMusicItemModel?.publishNewMusicURL = pathUrl
                             cell?.isSelected = true
                             cell?.activityIndicatorView.stopAnimating()
                             cell?.iconImageView.isHidden = false
@@ -148,14 +190,14 @@ extension PublishNewMusicListView : UITableViewDelegate, UITableViewDataSource {
                        
                }) { [weak self] (loadingStatus) in
                     self?.tableView((self?.tableView)!, didDeselectRowAt: indexPath)
-                   publishNewMusicSelectedindexPath = nil
+                   PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
                }
            }
        }else {
             //暂停播放
             AliPlayerManager.shared.audioPlayer.pause()
             self.tableView(tableView, didDeselectRowAt: indexPath)
-            publishNewMusicSelectedindexPath = nil
+            PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
        }
     }
     

+ 8 - 4
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewMusicView/PublishNewMusicListViewTableViewCell.swift

@@ -79,9 +79,14 @@ class PublishNewMusicListViewTableViewCell: UITableViewCell {
         
     }
     
+    typealias UseClosure = () -> Void
+    var useClosure : UseClosure?
+    
     func setupData() {
         useButton.rx.tap.subscribe(onNext: { [weak self] in
-            
+            if let useClosure = self?.useClosure {
+                useClosure()
+            }
         }).disposed(by: disposeBag)
     }
     
@@ -104,7 +109,7 @@ class PublishNewMusicListViewTableViewCell: UITableViewCell {
         return titleLabel
     }()
     
-    private lazy var playImageView: UIImageView = {
+    lazy var playImageView: UIImageView = {
         let playImageView = UIImageView()
         playImageView.image = kImage(name: "music_ico_selected")
         playImageView.isHidden = true
@@ -112,7 +117,7 @@ class PublishNewMusicListViewTableViewCell: UITableViewCell {
     }()
     
     
-    private lazy var useButton: UIButton = {
+    lazy var useButton: UIButton = {
         let useButton = UIButton(type: UIButton.ButtonType.custom)
         useButton.setTitle("使用", for: UIControl.State.normal)
         useButton.titleLabel?.font = kRegularFont13
@@ -145,5 +150,4 @@ class PublishNewMusicListViewTableViewCell: UITableViewCell {
         }
     }
     
-
 }

+ 48 - 20
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewMusicView/PublishNewMusicView.swift

@@ -11,6 +11,20 @@ import JXSegmentedView
 
 class PublishNewMusicView: BaseView {
     
+    deinit {
+        NXLLog("deinit")
+        PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+        PublishNewMusicView.publishNewMusicUseIndexPath = nil
+        PublishNewMusicView.publishNewMusicUseURL = nil
+    }
+    
+    /// 选中的音乐
+    static var publishNewMusicSelectedIndexPath : IndexPath? = nil
+    /// 使用中的音乐
+    static var publishNewMusicUseIndexPath : IndexPath? = nil
+    /// 使用中的音乐路径
+    static var publishNewMusicUseURL : URL? = nil
+    
     var index : Int = 0
     var musicCategoryNames = Array<String>()
     var musicCategorys : Array<MusicCategoryItemModel> = [] {
@@ -22,15 +36,15 @@ class PublishNewMusicView: BaseView {
         }
     }
     
+    typealias UserMusicClosure = () -> Void
+    var userMusicClosure : UserMusicClosure?
+    
     override func setupViews() {
         configRectCorner(corner: [.topLeft,.topRight], radii: CGSize(width: 8, height: 8))
         clipsToBounds = true
         addSubview(vibrancyView)
         addSubview(closeButton)
         addSubview(noUseMusicButton)
-        addSubview(segmentedView)
-        addSubview(recommendMusicLabel)
-        addSubview(listContainerView)
 
     }
     
@@ -52,22 +66,7 @@ class PublishNewMusicView: BaseView {
             make.right.equalTo(-14)
         }
         
-        segmentedView.snp.makeConstraints { (make) in
-            make.left.right.equalToSuperview()
-            make.top.equalTo(48)
-            make.height.equalTo(44)
-        }
-        recommendMusicLabel.snp.makeConstraints { (make) in
-            make.bottom.equalTo(-25)
-            make.height.equalTo(20)
-            make.centerX.equalToSuperview()
-        }
         
-        listContainerView.snp.makeConstraints { (make) in
-            make.top.equalTo(segmentedView.snp.bottom)
-            make.left.right.equalToSuperview()
-            make.bottom.equalTo(recommendMusicLabel.snp.top).offset(-20)
-        }
         
     }
     
@@ -108,9 +107,9 @@ class PublishNewMusicView: BaseView {
         segmentedView.delegate = self
         segmentedView.dataSource = segmentedDataSourceMusic
         segmentedView.indicators = [indicator]
+        segmentedView.listContainer = listContainerView
         segmentedView.contentEdgeInsetLeft = 14
         segmentedView.contentEdgeInsetRight = 14
-        segmentedView.listContainer = listContainerView
         return segmentedView
     }()
     
@@ -140,7 +139,7 @@ class PublishNewMusicView: BaseView {
     }()
     
     //4.初始化JXSegmentedListContainerView
-    private lazy var listContainerView: JXSegmentedListContainerView = {
+    lazy var listContainerView: JXSegmentedListContainerView = {
         let listContainerView = JXSegmentedListContainerView(dataSource: self)
         return listContainerView
     }()
@@ -171,6 +170,7 @@ class PublishNewMusicView: BaseView {
             let musicCategoryListModel = musicCategoryListModel as? CommunityMusicCategoryListModel
             
             guard !(musicCategoryListModel?.data?.isEmpty ?? true) else { return }
+            
             self?.musicCategorys = (musicCategoryListModel?.data)!
             self?.segmentedDataSourceMusic.titles = (self?.musicCategoryNames)!
             self?.segmentedView.selectItemAt(index: (self?.index)!)
@@ -179,6 +179,28 @@ class PublishNewMusicView: BaseView {
             self?.segmentedView.reloadData()
             self?.listContainerView.defaultSelectedIndex =  (self?.index)!
             self?.listContainerView.reloadData()
+            
+            self?.addSubview((self?.recommendMusicLabel)!)
+            self?.addSubview((self?.segmentedView)!)
+            self?.addSubview((self?.listContainerView)!)
+            self?.segmentedView.snp.makeConstraints { (make) in
+                make.left.right.equalToSuperview()
+                make.top.equalTo(48)
+                make.height.equalTo(44)
+            }
+            self?.recommendMusicLabel.snp.makeConstraints { (make) in
+                make.bottom.equalTo(-25)
+                make.height.equalTo(20)
+                make.centerX.equalToSuperview()
+            }
+            
+            self?.listContainerView.snp.makeConstraints { (make) in
+                make.top.equalTo((self?.segmentedView.snp.bottom)!)
+                make.left.right.equalToSuperview()
+                make.bottom.equalTo((self?.recommendMusicLabel.snp.top)!).offset(-20)
+            }
+            
+            
 
         }
     }
@@ -225,6 +247,12 @@ extension PublishNewMusicView : JXSegmentedListContainerViewDataSource {
         let musicListView = PublishNewMusicListView()
         musicListView.categoryId = musicCategorys[index].id ?? 0
         musicListView.index = index
+        musicListView.userMusicClosure = {
+            [weak self] in
+            if let userMusicClosure = self?.userMusicClosure {
+                userMusicClosure()
+            }
+        }
         return musicListView
     }
 }

+ 93 - 46
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewView/PublishNewVideoPhotoView.swift

@@ -18,15 +18,14 @@ class PublishNewVideoPhotoView: BaseView {
     
     /// 录制的时长
     var recorderDuration: CGFloat = 0.0
-    
     /// 录制最大时长
     let maxDuration : CGFloat = 60.0
-    
     /// 录制最小时长
     let minDuration : CGFloat = 3.0
-    
     /// 滤镜选中的selected
     var selectedIndex : Int = 0
+    /// 是否完成录制
+    var isFinishRecorder : Bool = false
     
     /// 添加View
     override func setupViews() {
@@ -94,8 +93,6 @@ class PublishNewVideoPhotoView: BaseView {
                 }else { //开始拍摄
                     self?.startTakeVideo()
                 }
-                //切换按钮状态
-                self?.publishNewVideoPhotoSetView.recordButton.isSelected = !(self?.publishNewVideoPhotoSetView.recordButton.isSelected)!
             }
             // 拍照
             if PublishNewViewModel.shared.publishNewRecorderType == .photo {
@@ -112,8 +109,15 @@ class PublishNewVideoPhotoView: BaseView {
         }).disposed(by: disposeBag)
         // 完成录制
         publishNewVideoPhotoSetView.finishButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            /// 回删视频
-            self?.finishTakeVideo()
+            //完成录制的view
+            self?.finishRecorderView()
+            if self?.recorder?.isRecording ?? true {
+                // 完成录制需要先掉用停止录制在走delegate
+                self?.stopTakeVideo()
+            }else {
+                self?.finishTakeVideo()
+            }
+           
         }).disposed(by: disposeBag)
         // 左滑 滤镜 加 1
         publishNewVideoPhotoSetView.leftSwipeClosure = {
@@ -144,20 +148,36 @@ class PublishNewVideoPhotoView: BaseView {
             self?.showFilterNameLabel(aliyunEffectFilter: aliyunEffectFilter)
         }
         
-        
         // 关闭音乐按钮
         musicView.closeButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            AliPlayerManager.shared.audioPlayer.stop()
+            PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
             self?.musicViewisHidden(isHidden: true)
         }).disposed(by: disposeBag)
         
         // 不使用音乐按钮
         musicView.noUseMusicButton.rx.tap.subscribe(onNext: { [weak self] (data) in
-            self?.recorder?.apply(AliyunEffectMusic())
-            AliPlayerManager.shared.audioPlayer.stop()
+            PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+            PublishNewMusicView.publishNewMusicUseIndexPath = nil
+            let effectMusic : AliyunEffectMusic? = nil
+            self?.recorder?.apply(effectMusic)
             self?.musicViewisHidden(isHidden: true)
         }).disposed(by: disposeBag)
         
+        // 使用音乐
+        musicView.userMusicClosure = {
+            [weak self] in
+            if PublishNewMusicView.publishNewMusicUseURL?.path == nil {
+                PublishNewMusicView.publishNewMusicUseIndexPath = nil
+                self?.musicViewisHidden(isHidden: true)
+                SwiftProgressHUD.shared().showText("使用音乐错误,请您重新选择!!!")
+            }else {
+                PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+                self?.recorder?.apply(AliyunEffectMusic(file: PublishNewMusicView.publishNewMusicUseURL?.path))
+                self?.musicViewisHidden(isHidden: true)
+            }
+           
+        }
+        
         
         // 左滑 滤镜 加 1
         recorderPreview.leftSwipeClosure = {
@@ -187,12 +207,8 @@ class PublishNewVideoPhotoView: BaseView {
     
     /// SDK录制类
     lazy var recorder: AliyunIRecorder? = {
-//        let recorder : AliyunIRecorder? = AliyunIRecorder()
-//        recorder?.reStartPreview(withVideoSize: CGSize(width: 720, height: 1280))
-//        recorder?.preview = recorderPreview
-//        recorder?.delegate = self
-        let recorder = AliyunIRecorder.init(delegate: self, videoSize: CGSize(width: 720, height: 1280))
         
+        let recorder = AliyunIRecorder.init(delegate: self, videoSize: CGSize(width: 720, height: 1280))
         // 预览View
         recorder?.preview = recorderPreview
         //创建文件夹路径
@@ -230,14 +246,10 @@ class PublishNewVideoPhotoView: BaseView {
         recorder?.frontCaptureSessionPreset = AVCaptureSession.Preset.hd1280x720.rawValue
         // 后置摄像头采集分辨率 默认:AVCaptureSessionPreset1280x720
         recorder?.backCaptureSessionPreset = AVCaptureSession.Preset.hd1280x720.rawValue
-        // 设置视频最大时长 默认8
-        recorder?.clipManager.maxDuration = maxDuration
-        // 设置视频最小时长 默认8
-        recorder?.clipManager.minDuration = minDuration
         // 设置摄像头角度
         recorder?.cameraRotate = 0
         // 设置编码方式 0软编 1硬编
-        recorder?.encodeMode = 1
+        recorder?.encodeMode = 0
         // 设置关键帧间隔
         recorder?.gop = 5
         // 设置关键帧间隔
@@ -250,13 +262,16 @@ class PublishNewVideoPhotoView: BaseView {
         recorder?.bitrate = 2000000
         // 设置采集视频格式
         recorder?.outputType = .type420f
-        
+        // 设置视频最大时长 默认8
+        recorder?.clipManager.maxDuration = maxDuration
+        // 设置视频最小时长 默认8
+        recorder?.clipManager.minDuration = minDuration
         return recorder!
     }()
     
     /// 摄像头
     lazy var recorderPreview : PublishNewRecorderPreview = {
-        let recorderPreview = PublishNewRecorderPreview(frame: bounds)
+        let recorderPreview = PublishNewRecorderPreview(frame: kScreenBounds)
         return recorderPreview
     }()
     /// 所有按钮View
@@ -286,9 +301,9 @@ extension PublishNewVideoPhotoView {
     /// 开始拍视频
     func startTakeVideo() {
         
+        self.recorder?.startRecording()
         DispatchQueue.main.async {
             [weak self] in
-            self?.recorder?.startRecording()
             // 回删按钮隐藏
             self?.deleteAlpha(alpha: 0)
             // 分段view隐藏
@@ -296,14 +311,12 @@ extension PublishNewVideoPhotoView {
             // 开始录制隐藏View
             self?.startTakeVideoHiddenView()
         }
+        
     }
     
     /// 暂停拍视频
     func stopTakeVideo() {
-        DispatchQueue.main.async {
-            [weak self] in
-            self?.recorder?.stopRecording()
-        }
+        self.recorder?.stopRecording()
     }
     
     /// 开始录制隐藏View
@@ -314,6 +327,8 @@ extension PublishNewVideoPhotoView {
         publishNewVideoPhotoSetView.filterButton.isHidden = true
         publishNewVideoPhotoSetView.beautyButton.isHidden = true
         publishNewVideoPhotoSetView.musicButton.isHidden = true
+        //切换按钮状态
+        publishNewVideoPhotoSetView.recordButton.isSelected = !publishNewVideoPhotoSetView.recordButton.isSelected
 
     }
     
@@ -324,14 +339,13 @@ extension PublishNewVideoPhotoView {
         publishNewVideoPhotoSetView.filterButton.isHidden = false
         publishNewVideoPhotoSetView.beautyButton.isHidden = false
         publishNewVideoPhotoSetView.musicButton.isHidden = false
+        //切换按钮状态
+        publishNewVideoPhotoSetView.recordButton.isSelected = !publishNewVideoPhotoSetView.recordButton.isSelected
     }
     
     /// 完成拍视频
     func finishTakeVideo() {
-        DispatchQueue.main.async {
-            [weak self] in
-            self?.recorder?.finishRecording()
-        }
+        self.recorder?.finishRecording()
     }
     
     /// 拍照
@@ -353,9 +367,9 @@ extension PublishNewVideoPhotoView {
                 AlertSheetView.alert(title: "是否删除上一片段?") { [weak self] (popupView, index, title) in
                     let partCount = self?.recorder?.clipManager?.partCount
                     // 删除最后一个视频片段
-                    self?.recorder?.clipManager.deletePart()
+                    self?.recorder?.clipManager?.deletePart()
                     // 视频时长
-                    self?.recorderDuration = (self?.recorder?.clipManager.duration)!
+                    self?.recorderDuration = (self?.recorder?.clipManager?.duration)!
                     // 完成按钮是否显示
                     self?.finishAlpha()
                     // 时间按钮是否显示
@@ -574,6 +588,8 @@ extension PublishNewVideoPhotoView {
     ///
     /// - Parameter isHidden: 是否隐藏
     func musicViewisHidden(isHidden:Bool) {
+        AliPlayerManager.shared.audioPlayer.stop()
+        recorder?.startPreview()
         var offsetY : CGFloat = kScreenHeight
         if isHidden {
             offsetY = kScreenHeight
@@ -584,25 +600,43 @@ extension PublishNewVideoPhotoView {
             }
             // 移除点击手势
             recorderPreview.removetap()
+            musicView.listContainerView.reloadData()
         }else {
             offsetY = kSafeStatusBarHeight
             segmentedViewAlpha(alpha:0)
             // 添加点击手势
             recorderPreview.addTap()
         }
-        UIView.animate(withDuration: 0.5) {
+        UIView.animate(withDuration: 0.5, animations: {
             [weak self] in
             self?.musicView.frame = CGRect(x: 0, y: offsetY, width: kScreenWidth, height: kScreenHeight -
-                kSafeStatusBarHeight)
+               kSafeStatusBarHeight)
             if isHidden {
-                self?.musicView.alpha = 0
-                self?.publishNewVideoPhotoSetView.alpha = 1
+               self?.musicView.alpha = 0
+               self?.publishNewVideoPhotoSetView.alpha = 1
             }else {
-                self?.musicView.alpha = 1
-                self?.publishNewVideoPhotoSetView.alpha = 0
+               self?.musicView.alpha = 1
+               self?.publishNewVideoPhotoSetView.alpha = 0
             }
+        })
+    }
+    
+    /// 结束录制回调/停止录制回调
+    func stopRecorderShowHidden() {
+        // 回删按钮透明度
+        deleteAlpha(alpha:1)
+        // 停止录制显示View
+        DispatchQueue.main.async {
+            [weak self] in
+            self?.stopTakeVideoVideoHiddenView()
         }
     }
+    
+    /// 完成录制的View
+    func finishRecorderView() {
+        SwiftProgressHUD.shared().showWait("视频正在合成中...")
+        isFinishRecorder = true
+    }
 }
 
 // MARK: - 代理
@@ -722,10 +756,12 @@ extension PublishNewVideoPhotoView : AliyunIRecorderDelegate {
      停止录制回调
      */
     func recorderDidStopRecording() {
-        // 回删按钮透明度
-        deleteAlpha(alpha:1)
-        // 停止录制显示View
-        stopTakeVideoVideoHiddenView()
+        //是否完成录制
+        if isFinishRecorder {  //完成 显示view也要完成视频合成
+            finishTakeVideo()
+        }else{ //没有完成只改变view显示
+            stopRecorderShowHidden()
+        }
     }
 
     
@@ -733,14 +769,25 @@ extension PublishNewVideoPhotoView : AliyunIRecorderDelegate {
      当录至最大时长时回调
      */
     func recorderDidStopWithMaxDuration() {
-        
+        finishRecorderView()
+        finishTakeVideo()
     }
-
     
     /**
      结束录制回调
      */
     func recorderDidFinishRecording() {
+        SwiftProgressHUD.shared().hide()
+        if isFinishRecorder {  //完成 显示view也要完成视频合成
+           stopRecorderShowHidden()
+        }
+        isFinishRecorder = false
+        DispatchQueue.main.async {
+            [weak self] in
+            self?.publishNewVideoPhotoSetView.recordButton.isSelected = false
+            let vc = PublishEditNewViewController()
+            UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
+        }
         
     }
 

+ 17 - 17
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/ViewController/PublishNewViewController.swift

@@ -80,9 +80,9 @@ class PublishNewViewController: BaseViewController {
         }else {
             //开启预览
             if index == 0 {
-                setRecorder(index: index, isStartPreview: false)
+                setRecorder(index: index, isStartPreview: false, duration: 0.0)
             }else {
-                setRecorder(index: index, isStartPreview: true)
+                setRecorder(index: index, isStartPreview: true, duration: 0.0)
             }
         }
         
@@ -176,9 +176,11 @@ class PublishNewViewController: BaseViewController {
     /// - Parameters:
     ///   - isStartPreview: 是否开启预览
     ///   - publishNewRecorderType: 类型
-    func setRecorder(index:Int,isStartPreview:Bool) {
+    func setRecorder(index:Int,isStartPreview:Bool,duration:TimeInterval) {
         PublishNewViewModel.shared.publishNewRecorderType = PublishNewViewModel.PublishNewRecorderType(rawValue: index)!
         if isStartPreview {
+            // 开始预览摄像头
+            publishNewVideoPhotoView.recorder?.startPreview()
             scrollView.setContentOffset(CGPoint(x: kScreenWidth, y:0), animated: true)
             segmentedDataSourceVideoPhoto.reloadData(selectedIndex: index)
             segmentedView.dataSource = segmentedDataSourceVideoPhoto
@@ -187,19 +189,19 @@ class PublishNewViewController: BaseViewController {
                 if self?.statusBarStyle != .lightContent {
                     self?.statusBarStyle = .lightContent
                 }
-            }
-            if PublishNewViewModel.shared.publishNewRecorderType == .photo {
-                publishNewVideoPhotoView.setProgressViewAlpha(alpha: 0,duration: 0.5)
+                if PublishNewViewModel.shared.publishNewRecorderType == .photo {
+                    self?.publishNewVideoPhotoView.setProgressViewAlpha(alpha: 0,duration: duration)
 
+                }
+                if PublishNewViewModel.shared.publishNewRecorderType == .video {
+                    // 是否显示进度条
+                    self?.publishNewVideoPhotoView.setProgressViewAlpha(alpha: 1,duration: duration)
+                }
             }
-            if PublishNewViewModel.shared.publishNewRecorderType == .video {
-                // 是否显示进度条
-                publishNewVideoPhotoView.setProgressViewAlpha(alpha: 1,duration: 0.5)
-            }
-            // 开始预览摄像头
-            publishNewVideoPhotoView.recorder?.startPreview()
 
         }else {
+            //停止预览摄像头
+            publishNewVideoPhotoView.recorder?.stopPreview()
             scrollView.setContentOffset(CGPoint(x: 0, y:0), animated: true)
             segmentedDataSourceAlbum.reloadData(selectedIndex: index)
             self.segmentedView.dataSource = segmentedDataSourceAlbum
@@ -209,8 +211,6 @@ class PublishNewViewController: BaseViewController {
                     self?.statusBarStyle = .default
                 }
             }
-            //停止预览摄像头
-            publishNewVideoPhotoView.recorder?.stopPreview()
         }
     }
     
@@ -222,11 +222,11 @@ extension PublishNewViewController : JXSegmentedViewDelegate {
     func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
         switch index {
         case 0:
-            setRecorder(index: index, isStartPreview: false)
+            setRecorder(index: index, isStartPreview: false, duration: 0.5)
         case 1:
-            setRecorder(index: index, isStartPreview: true)
+            setRecorder(index: index, isStartPreview: true, duration: 0.5)
         case 2:
-            setRecorder(index: index, isStartPreview: true)
+            setRecorder(index: index, isStartPreview: true, duration: 0.5)
         default:
             break
         }