Parcourir la source

音乐音量布局完成

南鑫林 il y a 5 ans
Parent
commit
32f798134d

+ 21 - 1
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -544,6 +544,9 @@
 		A7FF1598228D092A00A85748 /* OrderListModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1597228D092A00A85748 /* OrderListModel.swift */; };
 		A7FF159C228D9E3D00A85748 /* OrderRefundDetailModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF159B228D9E3C00A85748 /* OrderRefundDetailModel.swift */; };
 		A7FF1DAA23753A16002B3435 /* PublishEditNewEffectFilterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1DA923753A16002B3435 /* PublishEditNewEffectFilterView.swift */; };
+		A7FF1DAD2375510D002B3435 /* PublishEditNewMusicView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1DAC2375510D002B3435 /* PublishEditNewMusicView.swift */; };
+		A7FF1DB1237561B2002B3435 /* PublishEditNewVolumeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1DB0237561B2002B3435 /* PublishEditNewVolumeView.swift */; };
+		A7FF1DB323757C27002B3435 /* PublishEditNewMusicVolumeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7FF1DB223757C27002B3435 /* PublishEditNewMusicVolumeView.swift */; };
 		BD01B1FA22BC673900CE9F36 /* PublishConfirmPhotoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD01B1F822BC673900CE9F36 /* PublishConfirmPhotoController.swift */; };
 		BD01B1FB22BC673A00CE9F36 /* PublishTakePhotoController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD01B1F922BC673900CE9F36 /* PublishTakePhotoController.swift */; };
 		BD0808EC22C5BA3100D12E6A /* AliyunCompositionInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = BD0808EA22C5BA3000D12E6A /* AliyunCompositionInfo.m */; };
@@ -1312,6 +1315,9 @@
 		A7FF1597228D092A00A85748 /* OrderListModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderListModel.swift; sourceTree = "<group>"; };
 		A7FF159B228D9E3C00A85748 /* OrderRefundDetailModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderRefundDetailModel.swift; sourceTree = "<group>"; };
 		A7FF1DA923753A16002B3435 /* PublishEditNewEffectFilterView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishEditNewEffectFilterView.swift; sourceTree = "<group>"; };
+		A7FF1DAC2375510D002B3435 /* PublishEditNewMusicView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishEditNewMusicView.swift; sourceTree = "<group>"; };
+		A7FF1DB0237561B2002B3435 /* PublishEditNewVolumeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishEditNewVolumeView.swift; sourceTree = "<group>"; };
+		A7FF1DB223757C27002B3435 /* PublishEditNewMusicVolumeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishEditNewMusicVolumeView.swift; sourceTree = "<group>"; };
 		BD01B1F822BC673900CE9F36 /* PublishConfirmPhotoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishConfirmPhotoController.swift; sourceTree = "<group>"; };
 		BD01B1F922BC673900CE9F36 /* PublishTakePhotoController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PublishTakePhotoController.swift; sourceTree = "<group>"; };
 		BD0808EA22C5BA3000D12E6A /* AliyunCompositionInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AliyunCompositionInfo.m; sourceTree = "<group>"; };
@@ -2669,6 +2675,7 @@
 		A74CF4282373136100BA620E /* View */ = {
 			isa = PBXGroup;
 			children = (
+				A7FF1DAB237550F7002B3435 /* PublishEditNewMusicVolumeView */,
 				A7FF1DA7237539B2002B3435 /* PublishEditNewEffect */,
 				A74CF4302373BA7200BA620E /* PublishEditNewPlayProgressView */,
 				A74CF42F2373B9E300BA620E /* PublishEditNew */,
@@ -4629,9 +4636,9 @@
 		A7EE5AD7236C131C00309931 /* PublishNewEffect */ = {
 			isa = PBXGroup;
 			children = (
+				A7EE5ADE236C131C00309931 /* PublishNewEffectFilterBeautyView */,
 				A7EE5AD8236C131C00309931 /* PublishNewEffectBeautyView */,
 				A7EE5ADB236C131C00309931 /* PublishNewEffectFilterView */,
-				A7EE5ADE236C131C00309931 /* PublishNewEffectFilterBeautyView */,
 			);
 			path = PublishNewEffect;
 			sourceTree = "<group>";
@@ -5050,6 +5057,16 @@
 			path = PublishEditNewEffectFilterView;
 			sourceTree = "<group>";
 		};
+		A7FF1DAB237550F7002B3435 /* PublishEditNewMusicVolumeView */ = {
+			isa = PBXGroup;
+			children = (
+				A7FF1DAC2375510D002B3435 /* PublishEditNewMusicView.swift */,
+				A7FF1DB0237561B2002B3435 /* PublishEditNewVolumeView.swift */,
+				A7FF1DB223757C27002B3435 /* PublishEditNewMusicVolumeView.swift */,
+			);
+			path = PublishEditNewMusicVolumeView;
+			sourceTree = "<group>";
+		};
 		BD01B1F722BC673900CE9F36 /* PublishTakePhoto */ = {
 			isa = PBXGroup;
 			children = (
@@ -6326,6 +6343,7 @@
 				A7D77DE422DDB4B20048D5F6 /* RedemptionAreaBannerTableViewCell.swift in Sources */,
 				A72623EE22C4CFD800AEF875 /* WaterFallLayout.m in Sources */,
 				A7D5F25A22C05D1400F8E9AF /* SwiftMoyaServiceCommunityApi.swift in Sources */,
+				A7FF1DAD2375510D002B3435 /* PublishEditNewMusicView.swift in Sources */,
 				A7CC75332271ABB0003C4F38 /* AddressManagerViewController.swift in Sources */,
 				BD0FAA6322C4C35E00DDFB37 /* AliyunCropViewBottomView.m in Sources */,
 				BD12B67D22B4EE6D00AEB10B /* KSMediaPickerItemModel.swift in Sources */,
@@ -6439,6 +6457,7 @@
 				A7C0FDE922B4BC5600BC1E86 /* CardContentCommentListContentTableViewCell.swift in Sources */,
 				A7F689072357153B000C313F /* CircleLeavingMessageUserTableViewCell.swift in Sources */,
 				A77BB4632329EF1200DCAE32 /* NXLPermissionNotification.swift in Sources */,
+				A7FF1DB1237561B2002B3435 /* PublishEditNewVolumeView.swift in Sources */,
 				A7EF3E0C23013EDE001E4D26 /* CommunityImageAuthModel.swift in Sources */,
 				A7811C8C231AD26300C2D8DE /* OtherPersonalCenterReportSureView.swift in Sources */,
 				BD12B67C22B4EE6D00AEB10B /* KSMediaPickerAlbumModel.swift in Sources */,
@@ -6806,6 +6825,7 @@
 				BDE376DA22C22A260055E2EA /* UIButton+AliyunBlock.m in Sources */,
 				A70E3F3E236FF9CD0039D7FC /* AliyunVodUptoyouEffectsModel.swift in Sources */,
 				A7F304B523331B0800A4850F /* IMChatRoomViewController.swift in Sources */,
+				A7FF1DB323757C27002B3435 /* PublishEditNewMusicVolumeView.swift in Sources */,
 				A7D07CBF22B73EE600186014 /* UserPersonalCenterViewController.swift in Sources */,
 				BD27F0AD22CC5E4D00A6514D /* CommunityVideoListController.swift in Sources */,
 				A7CC753C2271C177003C4F38 /* AddressManagerSelfMentionTableViewCell.swift in Sources */,

+ 8 - 8
RainbowPlanet/RainbowPlanet/Manager/AliyunManager/AliPlayerManager/AliPlayerManager.swift

@@ -23,7 +23,7 @@ class AliPlayerManager: NSObject {
     typealias StartPlayClosure = (() -> Void)?
     var startPlayClosure : StartPlayClosure?
     
-    lazy var audioPlayer: AliPlayer = {
+    lazy var audioPlayer: AliPlayer? = {
         let audioPlayer = AliPlayer()
         audioPlayer?.delegate = self
         return audioPlayer!
@@ -53,17 +53,17 @@ extension AliPlayerManager {
         self.startPlayClosure = startPlayClosure
         
         if url != nil {
-            audioPlayer.setUrlSource(AVPUrlSource().url(with: url))
+            audioPlayer?.setUrlSource(AVPUrlSource().url(with: url))
         }
         if pathUrl != nil {
-            audioPlayer.setUrlSource(AVPUrlSource().fileURL(withPath: pathUrl))
+            audioPlayer?.setUrlSource(AVPUrlSource().fileURL(withPath: pathUrl))
         }
         
-        audioPlayer.enableLog = false
-        audioPlayer.isLoop = true
-        audioPlayer.isMuted = false
-        audioPlayer.isAutoPlay = true
-        audioPlayer.prepare()
+        audioPlayer?.enableLog = false
+        audioPlayer?.isLoop = true
+        audioPlayer?.isMuted = false
+        audioPlayer?.isAutoPlay = true
+        audioPlayer?.prepare()
     }
 }
 

+ 186 - 4
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditNew/View/PublishEditNew/PublishEditNewVideoView.swift

@@ -54,6 +54,7 @@ class PublishEditNewVideoView: UIView {
         backgroundColor = UIColor.black
         addSubview(editorPreview)
         addSubview(publishEditNewVideoSetView)
+        addSubview(musicVolumeView)
         addSubview(effectFilterView)
         addSubview(segmentedView)
     }
@@ -86,7 +87,10 @@ class PublishEditNewVideoView: UIView {
         // 音乐
         publishEditNewVideoSetView.musicButton.rx.tap.subscribe(onNext: {[weak self] (data) in
             guard let strongSelf = self else { return }
-            strongSelf.showHiddenSegmentedView(isHidden: true)
+            if strongSelf.player?.isPlaying() ?? true {
+                strongSelf.player?.pause()
+            }
+            strongSelf.musicVolumeViewisHidden(isHidden: false)
         }).disposed(by: disposeBag)
         
         // 滤镜
@@ -156,18 +160,31 @@ class PublishEditNewVideoView: UIView {
             self?.filterLess()
         }
         
+        // 手势
         editorPreview.tapClosure = {
             [weak self] in
             guard let strongSelf = self else { return }
+            // 隐藏滤镜
             if  strongSelf.effectFilterView.alpha == 1 {
-                // 隐藏滤镜
+                
                 strongSelf.effectFilterViewisHidden(isHidden: true)
             }
-//
+
+//            // 隐藏音乐
 //            if  strongSelf.musicView.alpha == 1 {
-//                // 隐藏音乐
+//
+//                PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
 //                strongSelf.musicViewisHidden(isHidden: true)
+//                if strongSelf.isPlaying {
+//                    strongSelf.resumePlay()
+//                }
+//            }
+//
+//            // 隐藏音量
+//            if  strongSelf.volumeView.alpha == 1 {
+//                strongSelf.volumeViewisHidden(isHidden: true)
 //            }
+            
         }
         
         // 左滑 滤镜 加 1
@@ -191,6 +208,74 @@ class PublishEditNewVideoView: UIView {
             }
             self?.showFilterNameLabel(aliyunEffectFilter: aliyunEffectFilter)
         }
+        
+//        // 关闭音乐按钮
+//        musicView.closeButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+//            guard let strongSelf = self else { return }
+//            PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+//            strongSelf.musicViewisHidden(isHidden: true)
+//            if strongSelf.isPlaying {
+//                strongSelf.resumePlay()
+//            }
+//        }).disposed(by: disposeBag)
+        
+//        // 不使用音乐按钮
+//        musicView.noUseMusicButton.rx.tap.subscribe(onNext: { [weak self] (data) in
+//             guard let strongSelf = self else { return }
+//            PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+//            PublishNewMusicView.publishNewMusicUseIndexPath = nil
+//            strongSelf.editor?.removeMusics()
+//            strongSelf.musicViewisHidden(isHidden: true)
+//            if strongSelf.isPlaying {
+//                strongSelf.resumePlay()
+//            }
+//        }).disposed(by: disposeBag)
+        
+//        // 使用音乐
+//        musicView.userMusicClosure = {
+//            [weak self] in
+//            guard let strongSelf = self else { return }
+//            if PublishNewMusicView.publishNewMusicUseURL?.path == nil {
+//                PublishNewMusicView.publishNewMusicUseIndexPath = nil
+//                strongSelf.musicViewisHidden(isHidden: true)
+//                SwiftProgressHUD.shared().showText("使用音乐错误,请您重新选择!!!")
+//            }else {
+//                strongSelf.editor?.removeMusics()
+//                PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+//                strongSelf.editor?.apply(AliyunEffectMusic(file: PublishNewMusicView.publishNewMusicUseURL?.path))
+//                strongSelf.musicViewisHidden(isHidden: true)
+//                strongSelf.player?.replay()
+//            }
+//
+//        }
+        
+//        // 选中音量
+//        musicView.publishEditNewMusicSegmentView.didSelectedItemClosure = {
+//            [weak self] in
+//            guard let strongSelf = self else { return }
+//            PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
+//            if strongSelf.volumeView.alpha == 1.0 {
+//                strongSelf.volumeViewisHidden(isHidden: false)
+//            }
+//            strongSelf.musicViewisHidden(isHidden: true)
+//            if strongSelf.isPlaying {
+//                strongSelf.resumePlay()
+//            }
+//
+//        }
+        
+//        // 选中音乐
+//        volumeView.publishEditNewVolumeSegmentView.didSelectedItemClosure = {
+//            [weak self] in
+//            guard let strongSelf = self else { return }
+////            if strongSelf.musicView.alpha == 1 {
+////                strongSelf.musicViewisHidden(isHidden: false)
+////            }
+//            strongSelf.volumeViewisHidden(isHidden: true)
+//            if strongSelf.player?.isPlaying() ?? true {
+//                strongSelf.player?.pause()
+//            }
+//        }
 
     }
     
@@ -235,6 +320,12 @@ class PublishEditNewVideoView: UIView {
         return publishEditNewVideoSetView
     }()
     
+    /// 音乐/音量
+    lazy var musicVolumeView : PublishEditNewMusicVolumeView = {
+        let musicVolumeView = PublishEditNewMusicVolumeView(frame: CGRect(x: 0, y: kScreenHeight, width: kScreenWidth, height: kScreenHeight - kSafeStatusBarHeight))
+        return musicVolumeView
+    }()
+    
     /// 滤镜跟美颜
     lazy var effectFilterView: PublishEditNewEffectFilterView = {
         let effectFilterView = PublishEditNewEffectFilterView(frame: CGRect(x: 0, y: kScreenHeight, width: kScreenWidth, height: 125 + kSafeTabBarHeight))
@@ -306,6 +397,97 @@ extension PublishEditNewVideoView {
         publishEditNewVideoSetView.playProgressView.playButton.isSelected = false
     }
     
+    /// 音乐/音量是否显示
+    ///
+    /// - Parameter isHidden: 是否隐藏
+    func musicVolumeViewisHidden(isHidden:Bool) {
+        AliPlayerManager.shared.audioPlayer?.stop()
+        var offsetY : CGFloat = kScreenHeight
+        if isHidden {
+            offsetY = kScreenHeight
+            // 移除点击手势
+            editorPreview.removetap()
+//            musicView.listContainerView.reloadData()
+        }else {
+            offsetY = kSafeStatusBarHeight
+            // 添加点击手势
+            editorPreview.addTap()
+        }
+        UIView.animate(withDuration: 0.5, animations: {
+            [weak self] in
+            self?.musicVolumeView.frame = CGRect(x: 0, y: offsetY, width: kScreenWidth, height: kScreenHeight -
+               kSafeStatusBarHeight)
+            if isHidden {
+               self?.musicVolumeView.alpha = 0
+               self?.publishEditNewVideoSetView.alpha = 1
+            }else {
+               self?.musicVolumeView.alpha = 1
+               self?.publishEditNewVideoSetView.alpha = 0
+            }
+        })
+    }
+    
+//    /// 音乐是否显示
+//    ///
+//    /// - Parameter isHidden: 是否隐藏
+//    func musicViewisHidden(isHidden:Bool) {
+//        AliPlayerManager.shared.audioPlayer?.stop()
+//        var offsetY : CGFloat = kScreenHeight
+//        if isHidden {
+//            offsetY = kScreenHeight
+//            // 移除点击手势
+//            editorPreview.removetap()
+//            musicView.listContainerView.reloadData()
+//        }else {
+//            offsetY = kSafeStatusBarHeight
+//            // 添加点击手势
+//            editorPreview.addTap()
+//            musicView.publishEditNewMusicSegmentView.segmentedView.selectItemAt(index: 0)
+//            musicView.publishEditNewMusicSegmentView.segmentedView.reloadData()
+//        }
+//        UIView.animate(withDuration: 0.5, animations: {
+//            [weak self] in
+//            self?.musicView.frame = CGRect(x: 0, y: offsetY, width: kScreenWidth, height: kScreenHeight -
+//               kSafeStatusBarHeight)
+//            if isHidden {
+//               self?.musicView.alpha = 0
+//               self?.publishEditNewVideoSetView.alpha = 1
+//            }else {
+//               self?.musicView.alpha = 1
+//               self?.publishEditNewVideoSetView.alpha = 0
+//            }
+//        })
+//    }
+    
+//    /// 音量是否显示
+//    ///
+//    /// - Parameter isHidden: 是否隐藏
+//    func volumeViewisHidden(isHidden:Bool) {
+//        var offsetY : CGFloat = kScreenHeight
+//        if isHidden {
+//            offsetY = kScreenHeight
+//            // 移除点击手势
+//            editorPreview.removetap()
+//        }else {
+//            offsetY = kScreenHeight - kSafeTabBarHeight - 129 - 48
+//            // 添加点击手势
+//            editorPreview.addTap()
+//            volumeView.publishEditNewVolumeSegmentView.segmentedView.selectItemAt(index: 1)
+//            volumeView.publishEditNewVolumeSegmentView.segmentedView.reloadData()
+//        }
+//        UIView.animate(withDuration: 0.5, animations: {
+//            [weak self] in
+//            self?.volumeView.frame = CGRect(x: 0, y: offsetY, width: kScreenWidth, height: kSafeTabBarHeight + 129 + 48)
+//            if isHidden {
+//               self?.volumeView.alpha = 0
+//               self?.publishEditNewVideoSetView.alpha = 1
+//            }else {
+//               self?.volumeView.alpha = 1
+//               self?.publishEditNewVideoSetView.alpha = 0
+//            }
+//        })
+//    }
+    
     /// 滑块需要显示的时间
     /// - Parameter playSec: 时间
     func sliderTime(playSec: Double) {

+ 262 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditNew/View/PublishEditNewMusicVolumeView/PublishEditNewMusicView.swift

@@ -0,0 +1,262 @@
+//
+//  PublishEditNewMusicView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/10/24.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import JXSegmentedView
+
+class PublishEditNewMusicView: BaseView {
+    
+    deinit {
+        NXLLog("deinit")
+    }
+    
+    var index : Int = 0
+    var musicCategoryNames = Array<String>()
+    var musicCategorys : Array<MusicCategoryItemModel> = [] {
+        didSet {
+            guard !(musicCategorys.isEmpty) else { return }
+            for categoryMdl in musicCategorys {
+                musicCategoryNames.append(categoryMdl.name!)
+            }
+        }
+    }
+    
+    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(lineLabel)
+
+    }
+    
+    override func setupLayouts() {
+
+        vibrancyView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(kSafeTabBarHeight+48)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(kScreenHeight - kSafeStatusBarHeight)
+        }
+        
+        closeButton.snp.makeConstraints { (make) in
+            make.top.equalTo(9)
+            make.left.equalTo(12)
+            make.size.equalTo(26)
+        }
+        
+        noUseMusicButton.snp.makeConstraints { (make) in
+            make.centerY.equalTo(closeButton)
+            make.right.equalTo(-14)
+        }
+        
+        lineLabel.snp.makeConstraints { (make) in
+            make.bottom.equalTo(-(kSafeTabBarHeight + 48))
+            make.left.right.equalToSuperview()
+            make.height.equalTo(0.5)
+        }
+        
+    }
+    
+    override func setupData() {
+        /// 获取音乐分类
+        communityGetMusicCategoryApi()
+        
+        recommendMusicLabel.addClickText("点击推荐", attributeds: [NSAttributedString.Key.font:kMediumFont14!,NSAttributedString.Key.foregroundColor:kffffffColor], transmitBody: nil) {
+            (data) in
+            let vc = PublishRecommendMusicNewController()
+            AliPlayerManager.shared.audioPlayer?.pause()
+            vc.backClosure = {
+                AliPlayerManager.shared.audioPlayer?.start()
+            }
+            UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
+        }
+    }
+    
+    
+    // 毛玻璃效果
+    lazy var vibrancyView: UIVisualEffectView = {
+        let vibrancyView = UIVisualEffectView(frame: self.frame)
+        vibrancyView.effect = UIBlurEffect(style: .dark)
+        return vibrancyView
+    }()
+    
+    /// 关闭按钮
+    lazy var closeButton: UIButton = {
+        let closeButton = UIButton(type: UIButton.ButtonType.custom)
+        closeButton.setImage(kImage(name: "video_btn_close_white"), for: UIControl.State.normal)
+        return closeButton
+    }()
+    
+    //1.初始化JXSegmentedViewx
+    private lazy var segmentedView: JXSegmentedView = {
+        let segmentedView = JXSegmentedView()
+        segmentedView.backgroundColor = .clear
+        segmentedView.delegate = self
+        segmentedView.dataSource = segmentedDataSourceMusic
+        segmentedView.indicators = [indicator]
+        segmentedView.listContainer = listContainerView
+        segmentedView.contentEdgeInsetLeft = 14
+        segmentedView.contentEdgeInsetRight = 14
+        return segmentedView
+    }()
+    
+    //2.初始化dataSource
+    private lazy var segmentedDataSourceMusic: JXSegmentedTitleDataSource = {
+        let segmentedDataSource = JXSegmentedTitleDataSource()
+        segmentedDataSource.isTitleColorGradientEnabled = true
+        segmentedDataSource.isItemSpacingAverageEnabled = false
+        segmentedDataSource.isTitleZoomEnabled = true
+        segmentedDataSource.titleNormalColor = k999999Color
+        segmentedDataSource.titleSelectedColor = kffffffColor
+        segmentedDataSource.titleNormalFont = kRegularFont14!
+        segmentedDataSource.titleSelectedFont = kBoldFont22
+        segmentedDataSource.isTitleStrokeWidthEnabled = true
+        //reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
+        segmentedDataSource.itemSpacing = 34
+        return segmentedDataSource
+    }()
+    
+    //3.初始化指示器indicator
+    private lazy var indicator: JXSegmentedIndicatorLineView = {
+        let indicator = JXSegmentedIndicatorLineView()
+        indicator.indicatorColor = .white
+        indicator.indicatorHeight = 3
+        indicator.indicatorWidth = 20
+        return indicator
+    }()
+    
+    //4.初始化JXSegmentedListContainerView
+    lazy var listContainerView: JXSegmentedListContainerView = {
+        let listContainerView = JXSegmentedListContainerView(dataSource: self)
+        return listContainerView
+    }()
+    
+    /// 不使用音乐
+    lazy var noUseMusicButton: UIButton = {
+        let noUseMusicButton = UIButton(type: UIButton.ButtonType.custom)
+        noUseMusicButton.setTitle("不使用音乐", for: UIControl.State.normal)
+        noUseMusicButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
+        noUseMusicButton.titleLabel?.font = kRegularFont15
+        return noUseMusicButton
+    }()
+    
+    // 推荐音乐
+    private lazy var recommendMusicLabel: FMLinkLabel = {
+        let recommendMusicLabel = FMLinkLabel()
+        recommendMusicLabel.text = "没有找到想要的音乐?点击推荐"
+        recommendMusicLabel.numberOfLines = 0
+        recommendMusicLabel.textColor = k999999Color
+        recommendMusicLabel.font = kRegularFont14
+        return recommendMusicLabel
+    }()
+    
+    lazy var lineLabel: UILabel = {
+        let lineLabel = UILabel()
+        lineLabel.backgroundColor = kffffffColor.withAlphaComponent(0.2)
+        return lineLabel
+    }()
+    
+    /// 获取音乐分类
+    func communityGetMusicCategoryApi() {
+        SwiftMoyaNetWorkServiceCommunity.shared().communityGetMusicCategoryApi() {
+            [weak self] (musicCategoryListModel) -> (Void) in
+            guard let strongSelf = self else { return }
+            let musicCategoryListModel = musicCategoryListModel as? CommunityMusicCategoryListModel
+            
+            guard !(musicCategoryListModel?.data?.isEmpty ?? true) else { return }
+            
+            strongSelf.musicCategorys = (musicCategoryListModel?.data)!
+            strongSelf.segmentedDataSourceMusic.titles = strongSelf.musicCategoryNames
+            strongSelf.segmentedView.selectItemAt(index: strongSelf.index)
+            strongSelf.segmentedView.defaultSelectedIndex = strongSelf.index
+            strongSelf.segmentedDataSourceMusic.reloadData(selectedIndex: strongSelf.index)
+            strongSelf.segmentedView.reloadData()
+            strongSelf.listContainerView.defaultSelectedIndex =  (self?.index)!
+            strongSelf.listContainerView.reloadData()
+            
+            strongSelf.addSubview(strongSelf.recommendMusicLabel)
+            strongSelf.addSubview(strongSelf.segmentedView)
+            strongSelf.addSubview(strongSelf.listContainerView)
+            strongSelf.segmentedView.snp.makeConstraints { (make) in
+                make.left.right.equalToSuperview()
+                make.top.equalTo(48)
+                make.height.equalTo(44)
+            }
+            strongSelf.recommendMusicLabel.snp.makeConstraints { (make) in
+                make.bottom.equalTo(strongSelf.lineLabel.snp.top).offset(-15)
+                make.height.equalTo(20)
+                make.centerX.equalToSuperview()
+            }
+            
+            strongSelf.listContainerView.snp.makeConstraints { (make) in
+                make.top.equalTo(strongSelf.segmentedView.snp.bottom)
+                make.left.right.equalToSuperview()
+                make.bottom.equalTo(strongSelf.recommendMusicLabel.snp.top).offset(-20)
+            }
+            
+            
+
+        }
+    }
+
+}
+
+extension PublishEditNewMusicView : JXSegmentedViewDelegate {
+    
+    //点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,而不关心具体是点击还是滚动选中的情况。
+    func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
+        listContainerView.didClickSelectedItem(at: index)
+    }
+    
+    // 点击选中的情况才会调用该方法
+    func segmentedView(_ segmentedView: JXSegmentedView, didClickSelectedItemAt index: Int) {
+        //传递didClickSelectedItemAt事件给listContainerView,必须调用!!!
+    }
+    
+    // 滚动选中的情况才会调用该方法(未支持滚动选中)
+    func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
+        
+    }
+    
+    // 正在滚动中的回调
+    func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
+        self.segmentedView.backgroundColor = .clear
+        //传递scrolling事件给listContainerView,必须调用!!!
+    }
+    
+    /// 是否允许点击选中目标index的item
+    func segmentedView(_ segmentedView: JXSegmentedView, canClickItemAt index: Int) -> Bool {
+        return true
+    }
+}
+
+extension PublishEditNewMusicView : JXSegmentedListContainerViewDataSource {
+    func numberOfLists(in listContainerView: JXSegmentedListContainerView) -> Int {
+        if let titleDataSource = segmentedView.dataSource as? JXSegmentedBaseDataSource {
+            return titleDataSource.dataSource.count
+        }
+        return 0
+    }
+    func listContainerView(_ listContainerView: JXSegmentedListContainerView, initListAt index: Int) -> JXSegmentedListContainerViewListDelegate {
+        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
+    }
+}
+

+ 151 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditNew/View/PublishEditNewMusicVolumeView/PublishEditNewMusicVolumeView.swift

@@ -0,0 +1,151 @@
+//
+//  PublishEditNewMusicVolumeView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/8.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import JXSegmentedView
+
+class PublishEditNewMusicVolumeView: BaseView {
+
+    var index : Int = 0
+    
+    override func setupViews() {
+        addSubview(segmentedView)
+        addSubview(scrollView)
+        scrollView.addSubview(publishEditNewMusicView)
+        scrollView.addSubview(publishEditNewVolumeBgView)
+    }
+    
+    override func setupLayouts() {
+        segmentedView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(-kSafeTabBarHeight)
+            make.left.right.bottom.equalToSuperview()
+            make.height.equalTo(48)
+        }
+        scrollView.snp.makeConstraints { (make) in
+           make.bottom.equalTo(segmentedView.snp.top)
+           make.left.right.equalToSuperview()
+           make.height.equalTo(kScreenHeight - kSafeStatusBarHeight - 48 - kSafeTabBarHeight)
+        }
+    }
+    
+    override func setupData() {
+        
+    }
+    
+    //1.初始化JXSegmentedViewx
+    lazy var segmentedView: JXSegmentedView = {
+        let segmentedView = JXSegmentedView()
+        segmentedView.backgroundColor = .clear
+        segmentedView.delegate = self
+        segmentedView.dataSource = segmentedDataSource
+        segmentedView.indicators = [indicator]
+        segmentedView.selectItemAt(index: index)
+        segmentedView.defaultSelectedIndex = index
+        return segmentedView
+    }()
+    
+    //2.初始化dataSource
+    lazy var segmentedDataSource: JXSegmentedTitleDataSource = {
+        let segmentedDataSource = JXSegmentedTitleDataSource()
+        segmentedDataSource.titles = ["音乐","音量"]
+        segmentedDataSource.isTitleColorGradientEnabled = true
+        segmentedDataSource.isItemSpacingAverageEnabled = true
+        segmentedDataSource.isTitleZoomEnabled = true
+        segmentedDataSource.titleNormalColor = k999999Color
+        segmentedDataSource.titleSelectedColor = kffffffColor
+        segmentedDataSource.titleNormalFont = kRegularFont14!
+        segmentedDataSource.titleSelectedFont = kRegularFont14!
+        segmentedDataSource.isTitleStrokeWidthEnabled = false
+        //reloadData(selectedIndex:)方法一定要调用,方法内部会刷新数据源数组
+        segmentedDataSource.reloadData(selectedIndex: index)
+        return segmentedDataSource
+    }()
+    
+    //3.初始化指示器indicator
+    private lazy var indicator: JXSegmentedIndicatorLineView = {
+        let indicator = JXSegmentedIndicatorLineView()
+        indicator.indicatorColor = .white
+        indicator.indicatorHeight = 3
+        indicator.indicatorWidth = 20
+        indicator.verticalOffset = 8
+        return indicator
+    }()
+    
+    //滚动的View
+    private lazy var scrollView: UIScrollView = {
+        let scrollView = UIScrollView()
+        scrollView.contentSize = CGSize(width: kScreenWidth * 2, height: kScreenHeight)
+        scrollView.isPagingEnabled = true
+        scrollView.showsHorizontalScrollIndicator = false
+        scrollView.showsVerticalScrollIndicator = false
+        scrollView.scrollsToTop = false
+        scrollView.isScrollEnabled = false
+        scrollView.isHidden = false
+        return scrollView
+    }()
+    
+    // 音乐View
+    lazy var publishEditNewMusicView : PublishEditNewMusicView = {
+        let publishEditNewMusicView = PublishEditNewMusicView(frame: CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight-kSafeStatusBarHeight))
+        return publishEditNewMusicView
+    }()
+    
+    // 音量背景view
+    lazy var publishEditNewVolumeBgView : UIView = {
+        let publishEditNewVolumeBgView = UIView(frame: CGRect(x: kScreenWidth, y: 0, width: kScreenWidth, height: kScreenHeight - kSafeStatusBarHeight))
+        publishEditNewVolumeBgView.backgroundColor = UIColor.clear
+        publishEditNewVolumeBgView.addSubview(publishEditNewVolumeView)
+        return publishEditNewVolumeBgView
+    }()
+    // 音量
+    lazy var publishEditNewVolumeView : PublishEditNewVolumeView = {
+        let publishEditNewVolumeView = PublishEditNewVolumeView(frame: CGRect(x: 0, y: kScreenHeight-kSafeStatusBarHeight-kSafeTabBarHeight - 48 - 129, width: kScreenWidth, height: kSafeTabBarHeight + 48 + 129))
+        return publishEditNewVolumeView
+    }()
+
+}
+
+extension PublishEditNewMusicVolumeView : JXSegmentedViewDelegate {
+ 
+    //点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,而不关心具体是点击还是滚动选中的情况。
+    func segmentedView(_ segmentedView: JXSegmentedView, didSelectedItemAt index: Int) {
+        switch index {
+        case 0:
+            scrollView.setContentOffset(CGPoint(x: 0, y:0), animated: false)
+            break
+        case 1:
+            scrollView.setContentOffset(CGPoint(x: kScreenWidth, y:0), animated: false)
+            break
+        default:
+            break
+        }
+    }
+    
+    // 点击选中的情况才会调用该方法
+    func segmentedView(_ segmentedView: JXSegmentedView, didClickSelectedItemAt index: Int) {
+        //传递didClickSelectedItemAt事件给listContainerView,必须调用!!!
+    }
+    
+    // 滚动选中的情况才会调用该方法(未支持滚动选中)
+    func segmentedView(_ segmentedView: JXSegmentedView, didScrollSelectedItemAt index: Int) {
+        print("\n------滚动选中\(index)")
+    }
+    
+    // 正在滚动中的回调
+    func segmentedView(_ segmentedView: JXSegmentedView, scrollingFrom leftIndex: Int, to rightIndex: Int, percent: CGFloat) {
+        self.segmentedView.backgroundColor = .clear
+        //传递scrolling事件给listContainerView,必须调用!!!
+    }
+    
+    /// 是否允许点击选中目标index的item
+    func segmentedView(_ segmentedView: JXSegmentedView, canClickItemAt index: Int) -> Bool {
+        return true
+    }
+}
+
+

+ 160 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditNew/View/PublishEditNewMusicVolumeView/PublishEditNewVolumeView.swift

@@ -0,0 +1,160 @@
+//
+//  PublishEditNewVolumeView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/8.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishEditNewVolumeView: BaseView {
+
+    override func setupViews() {
+        configRectCorner(corner: [.topLeft,.topRight], radii: CGSize(width: 8, height: 8))
+        clipsToBounds = true
+        addSubview(vibrancyView)
+        addSubview(sureButton)
+        addSubview(originLabel)
+        addSubview(backLabel)
+        addSubview(originSlider)
+        addSubview(backSlider)
+    }
+    
+    override func setupLayouts() {
+
+        vibrancyView.snp.makeConstraints { (make) in
+            make.bottom.equalTo(kSafeTabBarHeight+48)
+            make.left.right.equalToSuperview()
+            make.height.equalTo(129+48+kSafeTabBarHeight)
+        }
+        
+        sureButton.snp.makeConstraints { (make) in
+            make.top.equalTo(9)
+            make.right.equalTo(-12)
+            make.size.equalTo(26)
+        }
+        
+        originLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(78)
+            make.left.equalTo(19)
+            make.width.equalTo(30)
+            make.height.equalTo(21)
+        }
+        backLabel.snp.makeConstraints { (make) in
+            make.top.equalTo(78)
+            make.left.equalTo(kScreenWidth/2 + 13)
+            make.width.equalTo(30)
+            make.height.equalTo(21)
+        }
+        originSlider.snp.makeConstraints { (make) in
+            make.left.equalTo(originLabel.snp.right).offset(6)
+            make.right.equalTo(backLabel.snp.left).offset(-20)
+            make.height.equalTo(10)
+            make.centerY.equalTo(originLabel.snp.centerY)
+        }
+        backSlider.snp.makeConstraints { (make) in
+            make.left.equalTo(backLabel.snp.right).offset(6)
+            make.right.equalTo(-14)
+            make.height.equalTo(10)
+            make.centerY.equalTo(backLabel.snp.centerY)
+        }
+        
+    }
+    
+    override func setupData() {
+        
+    }
+    
+    // 毛玻璃效果
+    lazy var vibrancyView: UIVisualEffectView = {
+        let vibrancyView = UIVisualEffectView(frame: self.frame)
+        vibrancyView.effect = UIBlurEffect(style: .dark)
+        return vibrancyView
+    }()
+    
+    /// 关闭按钮
+    lazy var sureButton: UIButton = {
+        let sureButton = UIButton(type: UIButton.ButtonType.custom)
+        sureButton.setImage(kImage(name: "nav_finish_white"), for: UIControl.State.normal)
+        return sureButton
+    }()
+    
+    
+    /// 原声
+    lazy var originLabel: UILabel = {
+        let originLabel = UILabel()
+        originLabel.text = "原声"
+        originLabel.textColor = kffffffColor
+        originLabel.font = kRegularFont15
+        return originLabel
+    }()
+    
+    
+    /// 原声Slider
+    lazy var originSlider: CustomSlider = {
+        let originSlider = CustomSlider()
+        originSlider.thumbTintColor = kffffffColor
+        // 区域颜色
+        originSlider.minimumTrackTintColor = kffffffColor
+        originSlider.maximumTrackTintColor = UIColor(hexString: "000000", alpha: 0.3)
+        //
+        originSlider.setThumbImage(kImage(name: "music_btn_dot"), for: .normal)
+        originSlider.setThumbImage(kImage(name: "music_btn_dot"), for: .highlighted)
+        //滑块滑动停止后才触发ValueChanged事件
+        originSlider.isContinuous = false
+        originSlider.addTarget(self,action:#selector(originValueChanged(_:)), for:.valueChanged)
+
+        return originSlider
+    }()
+    
+    /// 配乐
+    lazy var backLabel: UILabel = {
+        let backLabel = UILabel()
+        backLabel.text = "配乐"
+        backLabel.textColor = kffffffColor
+        backLabel.font = kRegularFont15
+        return backLabel
+    }()
+    
+    /// 配乐Slider
+    lazy var backSlider: CustomSlider = {
+        let backSlider = CustomSlider()
+        backSlider.thumbTintColor = kffffffColor
+        // 区域颜色
+        backSlider.minimumTrackTintColor = kffffffColor
+        backSlider.maximumTrackTintColor = UIColor(hexString: "000000", alpha: 0.3)
+        //
+        backSlider.setThumbImage(kImage(name: "music_btn_dot"), for: .normal)
+        backSlider.setThumbImage(kImage(name: "music_btn_dot"), for: .highlighted)
+        //滑块滑动停止后才触发ValueChanged事件
+        backSlider.isContinuous = false
+        backSlider.addTarget(self,action:#selector(backValueChanged(_:)), for:.valueChanged)
+        return backSlider
+    }()
+    
+    @objc func originValueChanged(_ sender: Any?) {
+//        let slider = sender as? UISlider
+//
+//        let sliderRate = (slider?.value ?? 0.0) / (slider?.maximumValue ?? 0.0)
+//        self.originVolumn = CGFloat(sliderRate)*CGFloat(100)
+//
+//        var paraDic = Dictionary<String, Any>()
+//        paraDic.updateValue(originVolumn!, forKey: "origin")
+//        paraDic.updateValue(backVolumn!, forKey: "back")
+//        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ChangeAudioVolumnNoti"), object: paraDic)
+    }
+    
+    @objc func backValueChanged(_ sender: Any?) {
+//        let slider = sender as? UISlider
+//
+//        let sliderRate = (slider?.value ?? 0.0) / (slider?.maximumValue ?? 0.0)
+//        self.backVolumn = CGFloat(sliderRate)*CGFloat(100)
+//
+//        var paraDic = Dictionary<String, Any>()
+//        paraDic.updateValue(originVolumn!, forKey: "origin")
+//        paraDic.updateValue(backVolumn!, forKey: "back")
+//        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "ChangeAudioVolumnNoti"), object: paraDic)
+    }
+
+}

+ 2 - 1
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewMusicView/PublishNewMusicListView.swift

@@ -11,6 +11,7 @@ import JXSegmentedView
 
 class PublishNewMusicListView: BaseView {
     
+    
     var categoryId : Int = 0
     var index : Int? = nil
     var communityMusicItemModels : Array<CommunityMusicItemModel> = []
@@ -195,7 +196,7 @@ extension PublishNewMusicListView : UITableViewDelegate, UITableViewDataSource {
            }
        }else {
             //暂停播放
-            AliPlayerManager.shared.audioPlayer.pause()
+            AliPlayerManager.shared.audioPlayer?.pause()
             self.tableView(tableView, didDeselectRowAt: indexPath)
             PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
        }

+ 2 - 2
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewMusicView/PublishNewMusicView.swift

@@ -77,9 +77,9 @@ class PublishNewMusicView: BaseView {
         recommendMusicLabel.addClickText("点击推荐", attributeds: [NSAttributedString.Key.font:kMediumFont14!,NSAttributedString.Key.foregroundColor:kffffffColor], transmitBody: nil) {
             (data) in
             let vc = PublishRecommendMusicNewController()
-            AliPlayerManager.shared.audioPlayer.pause()
+            AliPlayerManager.shared.audioPlayer?.pause()
             vc.backClosure = {
-                AliPlayerManager.shared.audioPlayer.start()
+                AliPlayerManager.shared.audioPlayer?.start()
             }
             UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
         }

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

@@ -605,7 +605,7 @@ extension PublishNewVideoPhotoView {
     ///
     /// - Parameter isHidden: 是否隐藏
     func musicViewisHidden(isHidden:Bool) {
-        AliPlayerManager.shared.audioPlayer.stop()
+        AliPlayerManager.shared.audioPlayer?.stop()
         recorder?.startPreview()
         var offsetY : CGFloat = kScreenHeight
         if isHidden {