Kaynağa Gözat

封面图完成

南鑫林 5 yıl önce
ebeveyn
işleme
c4c664c1ab
15 değiştirilmiş dosya ile 594 ekleme ve 109 silme
  1. 39 3
      RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj
  2. 64 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishCoverVideo/View/PublishCoverVideoCollectionViewCell.swift
  3. 199 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishCoverVideo/View/PublishCoverVideoView.swift
  4. 123 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishCoverVideo/ViewController/PublishCoverVideoViewController.swift
  5. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishEditContentView/PublishEditContentViewDescribeCell.swift
  6. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishEditContentView/PublishEditContentViewTitleCell.swift
  7. 133 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishEditVideoCoverImageView/PublishEditVideoCoverImageTableViewCell.swift
  8. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishNewEditLocationView/PublishNewEditLocationTableViewCell.swift
  9. 0 0
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishNewEditTopicView/PublishNewEditTopicViewTableViewCell.swift
  10. 23 7
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/ViewController/PublishEditVideoContentViewController.swift
  11. 0 4
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditNew/View/PublishEditNew/PublishEditNewVideoView.swift
  12. 0 75
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/View/PublishEditVideoCoverImageView/PublishEditVideoCoverImageTableViewCell.swift
  13. 3 3
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishManager/PublishManager.swift
  14. 9 16
      RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishNew/View/PublishNewView/PublishNewVideoPhotoView.swift
  15. 1 1
      RainbowPlanet/RainbowPlanet/ViewModel/Virus/VirusViewModel.swift

+ 39 - 3
RainbowPlanet/RainbowPlanet.xcodeproj/project.pbxproj

@@ -463,6 +463,9 @@
 		A7DE18D723795A3200D9D72E /* PublishManagerUploadView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE18D623795A3200D9D72E /* PublishManagerUploadView.swift */; };
 		A7DE18D923795B2A00D9D72E /* PublishManagerUploadProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE18D823795B2A00D9D72E /* PublishManagerUploadProgressView.swift */; };
 		A7DE18DB23795B5700D9D72E /* PublishManagerUploadFailureView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE18DA23795B5700D9D72E /* PublishManagerUploadFailureView.swift */; };
+		A7DE18DE237A7D2100D9D72E /* PublishCoverVideoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE18DD237A7D2100D9D72E /* PublishCoverVideoViewController.swift */; };
+		A7DE18E2237A845C00D9D72E /* PublishCoverVideoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE18E1237A845C00D9D72E /* PublishCoverVideoView.swift */; };
+		A7DE18E4237A862D00D9D72E /* PublishCoverVideoCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE18E3237A862D00D9D72E /* PublishCoverVideoCollectionViewCell.swift */; };
 		A7DF50DF22A5590200998908 /* BrowsePicturesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50DE22A5590200998908 /* BrowsePicturesViewController.swift */; };
 		A7DF50E322A55AB600998908 /* BrowsePicturesPagerViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DF50E222A55AB600998908 /* BrowsePicturesPagerViewCell.swift */; };
 		A7E19FA822BA2CDF009BCCE1 /* SearchProductListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7E19FA722BA2CDF009BCCE1 /* SearchProductListViewController.swift */; };
@@ -1239,6 +1242,9 @@
 		A7DE18D623795A3200D9D72E /* PublishManagerUploadView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishManagerUploadView.swift; sourceTree = "<group>"; };
 		A7DE18D823795B2A00D9D72E /* PublishManagerUploadProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishManagerUploadProgressView.swift; sourceTree = "<group>"; };
 		A7DE18DA23795B5700D9D72E /* PublishManagerUploadFailureView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishManagerUploadFailureView.swift; sourceTree = "<group>"; };
+		A7DE18DD237A7D2100D9D72E /* PublishCoverVideoViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishCoverVideoViewController.swift; sourceTree = "<group>"; };
+		A7DE18E1237A845C00D9D72E /* PublishCoverVideoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishCoverVideoView.swift; sourceTree = "<group>"; };
+		A7DE18E3237A862D00D9D72E /* PublishCoverVideoCollectionViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PublishCoverVideoCollectionViewCell.swift; sourceTree = "<group>"; };
 		A7DF50DE22A5590200998908 /* BrowsePicturesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowsePicturesViewController.swift; sourceTree = "<group>"; };
 		A7DF50E222A55AB600998908 /* BrowsePicturesPagerViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrowsePicturesPagerViewCell.swift; sourceTree = "<group>"; };
 		A7E03A30F40582782EC5DA89 /* Pods_RainbowPlanetTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RainbowPlanetTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -3489,9 +3495,10 @@
 		A7811CCC2323D25A00C2D8DE /* PublishNewModule */ = {
 			isa = PBXGroup;
 			children = (
+				A7DE18DC237A7D0900D9D72E /* PublishCoverVideo */,
 				A7FF1DB523767149002B3435 /* PublishNewCommonView */,
 				A7FF1DB62376B50D002B3435 /* PublishManager */,
-				A7FF1DBD2376C673002B3435 /* PublishEditVideo */,
+				A7FF1DBD2376C673002B3435 /* PublishEditContent */,
 				A74CF4242372CD9100BA620E /* PublishEditNew */,
 				A7EE5AC5236C131C00309931 /* PublishNew */,
 				A70E3F2D236FF9520039D7FC /* PublishConfirmPhotoNew */,
@@ -4503,6 +4510,32 @@
 			path = PublishEditVideoCoverImageView;
 			sourceTree = "<group>";
 		};
+		A7DE18DC237A7D0900D9D72E /* PublishCoverVideo */ = {
+			isa = PBXGroup;
+			children = (
+				A7DE18E0237A843E00D9D72E /* View */,
+				A7DE18DF237A843100D9D72E /* ViewController */,
+			);
+			path = PublishCoverVideo;
+			sourceTree = "<group>";
+		};
+		A7DE18DF237A843100D9D72E /* ViewController */ = {
+			isa = PBXGroup;
+			children = (
+				A7DE18DD237A7D2100D9D72E /* PublishCoverVideoViewController.swift */,
+			);
+			path = ViewController;
+			sourceTree = "<group>";
+		};
+		A7DE18E0237A843E00D9D72E /* View */ = {
+			isa = PBXGroup;
+			children = (
+				A7DE18E1237A845C00D9D72E /* PublishCoverVideoView.swift */,
+				A7DE18E3237A862D00D9D72E /* PublishCoverVideoCollectionViewCell.swift */,
+			);
+			path = View;
+			sourceTree = "<group>";
+		};
 		A7DF50D922A556C300998908 /* BrowsePictures */ = {
 			isa = PBXGroup;
 			children = (
@@ -5148,13 +5181,13 @@
 			path = PublishManager;
 			sourceTree = "<group>";
 		};
-		A7FF1DBD2376C673002B3435 /* PublishEditVideo */ = {
+		A7FF1DBD2376C673002B3435 /* PublishEditContent */ = {
 			isa = PBXGroup;
 			children = (
 				A7DE18CB23790F2F00D9D72E /* View */,
 				A7DE18CA23790F1D00D9D72E /* ViewController */,
 			);
-			path = PublishEditVideo;
+			path = PublishEditContent;
 			sourceTree = "<group>";
 		};
 		BD01B1F722BC673900CE9F36 /* PublishTakePhoto */ = {
@@ -6492,6 +6525,7 @@
 				A7D07CD622B78BC300186014 /* PersonViewUserAndOtherListCollectionViewCell.swift in Sources */,
 				A75B782322DEC2F8007B986A /* RedemptionAreaSpecialOneTableViewCell.swift in Sources */,
 				A71AA513227215B5008FF1A5 /* ExpressAddressListView.swift in Sources */,
+				A7DE18E2237A845C00D9D72E /* PublishCoverVideoView.swift in Sources */,
 				A7DC467F22783A47001F3EFC /* EditExpressAddressTableViewCell.swift in Sources */,
 				A7AA9F6722C640F10086498B /* CommunityRecommendFeedModel.swift in Sources */,
 				A7824B082271F53A00ABA381 /* EditSetDefaultTableViewCell.swift in Sources */,
@@ -6541,6 +6575,7 @@
 				A7D5F25722C05BE900F8E9AF /* UserDetailModel.swift in Sources */,
 				BDE8AD1622CC59EE00E03C65 /* CommunityVideoListModel.swift in Sources */,
 				A7284401224DBB7700F82F30 /* SwiftMoyaNetWorkServiceUser.swift in Sources */,
+				A7DE18DE237A7D2100D9D72E /* PublishCoverVideoViewController.swift in Sources */,
 				A7C0FDE922B4BC5600BC1E86 /* CardContentCommentListContentTableViewCell.swift in Sources */,
 				A7F689072357153B000C313F /* CircleLeavingMessageUserTableViewCell.swift in Sources */,
 				A77BB4632329EF1200DCAE32 /* NXLPermissionNotification.swift in Sources */,
@@ -6827,6 +6862,7 @@
 				A72623E722C469B700AEF875 /* SearchMemberListModel.swift in Sources */,
 				A7F68916235738EB000C313F /* CircleLeavingMessageCommentTopStepTableViewCell.swift in Sources */,
 				A7A98DFD227E84F4005306E9 /* SwiftMoyaServiceProductApi.swift in Sources */,
+				A7DE18E4237A862D00D9D72E /* PublishCoverVideoCollectionViewCell.swift in Sources */,
 				BD01B1FB22BC673A00CE9F36 /* PublishTakePhotoController.swift in Sources */,
 				A7B7748E236AF22300BF26F1 /* NXLWebView.swift in Sources */,
 				A7D07CCF22B77E0200186014 /* UserPersonalCenterOrderCollectionViewCell.swift in Sources */,

+ 64 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishCoverVideo/View/PublishCoverVideoCollectionViewCell.swift

@@ -0,0 +1,64 @@
+//
+//  PublishCoverVideoCollectionViewCell.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/12.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishCoverVideoCollectionViewCell: UICollectionViewCell {
+    
+    class func cellWith(collectionView:UICollectionView,indexPath:IndexPath) -> PublishCoverVideoCollectionViewCell {
+        let ID = "PublishCoverVideoCollectionViewCell"
+        collectionView.register(PublishCoverVideoCollectionViewCell.self, forCellWithReuseIdentifier: ID)
+        let cell : PublishCoverVideoCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: ID, for: indexPath) as! PublishCoverVideoCollectionViewCell
+        cell.indexPath = indexPath
+        return cell
+    }
+
+    //MARK: - indexPath
+    var indexPath: IndexPath?{
+        didSet {
+            
+        }
+    }
+
+    //MARK: - 初始化
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+        setupViews()
+        setupLayouts()
+    }
+
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+
+    //MRAK: - 设置View
+    private func setupViews() {
+        addSubview(imageView)
+    }
+
+    private func setupLayouts() {
+        imageView.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
+        }
+    }
+
+    lazy var imageView: UIImageView = {
+        let imageView = UIImageView()
+        imageView.contentMode = .scaleAspectFill
+        imageView.clipsToBounds = true
+        return imageView
+    }()
+
+    var image : UIImage? {
+        didSet {
+            imageView.image = image ?? UIImage()
+        }
+    }
+}
+
+

+ 199 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishCoverVideo/View/PublishCoverVideoView.swift

@@ -0,0 +1,199 @@
+//
+//  PublishCoverVideoView.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/12.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishCoverVideoView: UIView {
+
+    /// 合成导出路径
+    var outputPath : String?
+    /// 封面路径
+    var outCoverImagePath : String?
+    /// 总时长
+    var duration : Double? = 0
+    /// 展示的图片
+    var images = Array<UIImage>()
+    
+    typealias SelectedImageClosure = (UIImage) -> Void
+    var selectedImageClosure : SelectedImageClosure?
+    
+    override init(frame: CGRect) {
+        super.init(frame: frame)
+    }
+    
+    init(outputPath : String?) {
+        self.init()
+        frame = CGRect(x: 14, y: kScreenHeight-89-kSafeTabBarHeight, width: kScreenWidth-28, height: 69)
+        self.outputPath = outputPath
+        setupViews()
+        setupData()
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    func setupViews() {
+        addSubview(collectionView)
+        addSubview(view)
+        view.addSubview(progressView)
+
+        
+    }
+    
+    func setupData() {
+        
+        let asset = AVURLAsset(url: URL(fileURLWithPath: outputPath ?? ""))
+        let videoTracks = asset.tracks(withMediaType: AVMediaType.video)
+        if videoTracks.count != 0 {
+            let track = videoTracks[0]
+            duration = CMTimeGetSeconds(CMTimeRangeGetEnd(track.timeRange))
+        }
+        getImages()
+        
+    }
+    
+    private lazy var collectionView: UICollectionView = {
+        let collectionView = UICollectionView.init(frame: CGRect(x: 0, y: 0, width: kScreenWidth-28, height: 69), collectionViewLayout: collectionViewLayout)
+        collectionView.backgroundColor = .clear
+        collectionView.delegate = self;
+        collectionView.dataSource = self;
+        collectionView.showsVerticalScrollIndicator = false
+        collectionView.showsHorizontalScrollIndicator = false
+        collectionView.cornerRadius = 4
+        collectionView.masksToBounds = true
+        return collectionView
+    }()
+    
+    private lazy var collectionViewLayout: UICollectionViewFlowLayout = {
+        let collectionViewLayout = UICollectionViewFlowLayout.init()
+        collectionViewLayout.minimumLineSpacing = 0
+        collectionViewLayout.minimumInteritemSpacing = 0
+        collectionViewLayout.itemSize = CGSize(width:(kScreenWidth-28)/12, height: 69)
+        collectionViewLayout.scrollDirection = .horizontal
+        collectionViewLayout.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
+        return collectionViewLayout
+    }()
+    
+    lazy var view: UIView = {
+        let view = UIView(frame: CGRect(x: 0, y: 0, width: kScreenWidth-28, height: 69))
+        view.backgroundColor = .clear
+        return view
+    }()
+    
+    lazy var progressView: UIView = {
+        let progressView = UIView(frame: CGRect(x: 0, y: 0, width: (kScreenWidth-28)/12, height: 69))
+        progressView.cornerRadius = 4
+        progressView.masksToBounds = true
+        progressView.layer.borderColor = kffffffColor.cgColor
+        progressView.layer.borderWidth = 2
+        return progressView
+    }()
+    
+    lazy var thumbnailImageGenerator: AVAssetImageGenerator = {
+        let thumbnailImageGenerator = AVAssetImageGenerator(asset: AVURLAsset(url: URL(fileURLWithPath: outputPath ?? "")))
+        thumbnailImageGenerator.appliesPreferredTrackTransform = true
+        thumbnailImageGenerator.requestedTimeToleranceBefore = CMTime.zero
+        thumbnailImageGenerator.requestedTimeToleranceAfter = CMTime.zero
+        thumbnailImageGenerator.maximumSize = CGSize(width: (kScreenWidth-28)/12, height: 69)
+        return thumbnailImageGenerator
+    }()
+    
+    lazy var imageGenerator: AVAssetImageGenerator = {
+        let imageGenerator = AVAssetImageGenerator(asset: AVURLAsset(url: URL(fileURLWithPath: outputPath ?? "")))
+        imageGenerator.appliesPreferredTrackTransform = true
+        imageGenerator.requestedTimeToleranceBefore = CMTime.zero
+        imageGenerator.requestedTimeToleranceAfter = CMTime.zero
+        return imageGenerator
+    }()
+    
+    
+    /// 获取图片
+    func getImages() {
+        
+        var times = Array<NSValue>()
+        var startTime = CMTime.zero
+        let addTime = CMTimeMake(value: Int64(duration! * 1000/12), timescale: 1000)
+        let endTime = CMTimeMake(value: Int64(duration! * 1000), timescale: 1000);
+        
+        while startTime < endTime {
+            times.append(NSValue(time: startTime))
+            startTime = CMTimeAdd(startTime, addTime)
+        }
+        
+        thumbnailImageGenerator.generateCGImagesAsynchronously(forTimes: times) { [weak self] (requestedTime, cgImage, actualTime, result, error) in
+            if result == .succeeded {
+                let image = UIImage(cgImage: cgImage!)
+                DispatchQueue.main.async {
+                    self?.images.append(image)
+                    self?.collectionView.reloadData()
+                }
+            }
+        }
+        
+    }
+}
+
+extension PublishCoverVideoView: UICollectionViewDelegateFlowLayout,UICollectionViewDataSource {
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        return 1
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        return images.count
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        let cell = PublishCoverVideoCollectionViewCell.cellWith(collectionView: collectionView, indexPath: indexPath)
+        cell.image = images[indexPath.row]
+        return cell
+    }
+}
+
+extension PublishCoverVideoView {
+    
+    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
+        touch(touches: touches)
+    }
+    
+    override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
+        touch(touches: touches)
+    }
+    
+    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
+        touch(touches: touches)
+    }
+    
+    func touch(touches: Set<UITouch>) {
+        let touch = touches.first
+        let point = touch?.location(in: collectionView)
+        var percent = (point?.x ?? 0.0) / frame.width
+        if percent < 0 {
+            percent = 0
+        } else if percent > 1 {
+            percent = 1
+        }
+        progressView.center = CGPoint(x: frame.width * percent, y: frame.height/2)
+        let time = CMTimeMake(value: Int64(duration! * 1000 * Double(percent)), timescale: 1000);
+        DispatchQueue.global().async {
+            [weak self] in
+            guard let strongSelf = self else { return }
+            do {
+                let image = try strongSelf.imageGenerator.copyCGImage(at: time, actualTime: nil)
+                        //旋转修正
+                let imageNew = UIImage.rotate(aImage: UIImage(cgImage: image))
+                if let selectedImageClosure  = strongSelf.selectedImageClosure {
+                    selectedImageClosure(imageNew)
+                }
+            } catch  {
+                NXLLog("错误")
+            }
+        }
+    }
+}
+

+ 123 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishCoverVideo/ViewController/PublishCoverVideoViewController.swift

@@ -0,0 +1,123 @@
+//
+//  PublishCoverVideoViewController.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/12.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+
+class PublishCoverVideoViewController: BaseViewController {
+    
+    /// 视频路径模型
+    var publishManagerVideoModel : PublishManagerVideoModel?
+    
+    typealias SelectedOutCoverImagePathClosure = (UIImage?) -> Void
+    var selectedOutCoverImagePathClosure : SelectedOutCoverImagePathClosure?
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        setupViews()
+        setupLayouts()
+        setupData()
+        
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = false
+    }
+    
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+        self.navigationController?.interactivePopGestureRecognizer?.isEnabled = true
+
+    }
+    
+    override func setupViews() {
+        view.backgroundColor = .black
+        statusBarStyle = .lightContent
+        navigationBar.wr_setBackgroundAlpha(alpha: 0)
+        navigationBar.leftButton.setImage(kImage(name: "navbar_back_white"), for: UIControl.State.normal)
+        navigationBar.addSubview(finishButton)
+        view.addSubview(coverImageView)
+        view.addSubview(titleLabel)
+        view.addSubview(publishCoverVideoView)
+        view.bringSubviewToFront(navigationBar)
+
+    }
+    
+    override func setupLayouts() {
+        finishButton.snp.makeConstraints { (make) in
+            make.centerY.equalTo(navigationBar.leftButton)
+            make.right.equalTo(-14)
+            make.height.equalTo(26)
+            make.width.equalTo(64)
+        }
+        
+        coverImageView.snp.makeConstraints { (make) in
+            make.edges.equalToSuperview()
+        }
+        
+        titleLabel.snp.makeConstraints { (make) in
+            make.bottom.equalTo(-(kSafeTabBarHeight+109))
+            make.centerX.equalToSuperview()
+        }
+    }
+    
+    override func setupData() {
+        publishCoverVideoView.selectedImageClosure = {
+            [weak self] image in
+            guard let strongSelf = self else { return }
+
+            DispatchQueue.main.async {
+                strongSelf.coverImageView.image = image
+            }
+        }
+        finishButton.rx.tap.subscribe(onNext: {
+            [weak self] (_) in
+            guard let strongSelf = self else { return }
+            if let selectedOutCoverImagePathClosure = strongSelf.selectedOutCoverImagePathClosure {
+                selectedOutCoverImagePathClosure(strongSelf.coverImageView.image!)
+            }
+            strongSelf.navigationController?.popViewController(animated: true)
+        }).disposed(by: disposeBag)
+    }
+    
+    
+    lazy var finishButton: UIButton = {
+        let finishButton = UIButton()
+        finishButton.setBackgroundImage(UIImage.imageWithColor(color: kThemeColor), for: UIControl.State.normal)
+        finishButton.setBackgroundImage(UIImage.imageWithColor(color: kd8d8d8Color), for: UIControl.State.disabled)
+        finishButton.setTitle("完成", for: UIControl.State.normal)
+        finishButton.setTitleColor(kffffffColor, for: UIControl.State.normal)
+        finishButton.titleLabel?.font = kMediumFont13
+        finishButton.cornerRadius = 13
+        finishButton.masksToBounds = true
+        return finishButton
+    }()
+    
+    lazy var coverImageView: UIImageView = {
+        let coverImageView = UIImageView()
+        coverImageView.contentMode = .scaleAspectFill
+        coverImageView.image = UIImage(named: publishManagerVideoModel?.outCoverImagePath ?? "")
+        coverImageView.clipsToBounds = true
+        return coverImageView
+    }()
+    
+    lazy var titleLabel: UILabel = {
+        let titleLabel = UILabel()
+        titleLabel.text = "滑动选择封面"
+        titleLabel.font = kRegularFont13
+        titleLabel.textColor = kffffffColor
+        return titleLabel
+    }()
+    
+    lazy var publishCoverVideoView: PublishCoverVideoView = {
+        let publishCoverVideoView = PublishCoverVideoView.init(outputPath: publishManagerVideoModel?.outVideoPath)
+        return publishCoverVideoView
+    }()
+    
+
+}

RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/View/PublishEditContentView/PublishEditContentViewDescribeCell.swift → RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishEditContentView/PublishEditContentViewDescribeCell.swift


RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/View/PublishEditContentView/PublishEditContentViewTitleCell.swift → RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishEditContentView/PublishEditContentViewTitleCell.swift


+ 133 - 0
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishEditVideoCoverImageView/PublishEditVideoCoverImageTableViewCell.swift

@@ -0,0 +1,133 @@
+//
+//  PublishEditVideoCoverImageTableViewCell.swift
+//  RainbowPlanet
+//
+//  Created by 南鑫林 on 2019/11/11.
+//  Copyright © 2019 RainbowPlanet. All rights reserved.
+//
+
+import UIKit
+import RxSwift
+
+class PublishEditVideoCoverImageTableViewCell: UITableViewCell {
+    
+    let disposeBag = DisposeBag()
+    
+
+    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PublishEditVideoCoverImageTableViewCell {
+       let ID = "PublishEditVideoCoverImageTableViewCell"
+       tableView.register(PublishEditVideoCoverImageTableViewCell.self, forCellReuseIdentifier: ID)
+       let cell : PublishEditVideoCoverImageTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! PublishEditVideoCoverImageTableViewCell
+       cell.indexPath = indexPath
+       cell.tableView = tableView
+       return cell
+    }
+       
+    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
+       super.init(style: style, reuseIdentifier: reuseIdentifier)
+       setupViews()
+       setupLayouts()
+       setupUpdata()
+    }
+
+    required init?(coder aDecoder: NSCoder) {
+       fatalError("init(coder:) has not been implemented")
+    }
+
+    //MRAK: - 设置View
+    private func setupViews() {
+       self.selectionStyle = .none
+        addSubview(coverImageButton)
+        coverImageButton.addSubview(selectedCoverLabel)
+    }
+
+    private func setupLayouts() {
+        coverImageButton.snp.makeConstraints { (make) in
+            make.top.equalTo(15)
+            make.left.equalTo(14)
+            make.size.equalTo(100)
+        }
+        selectedCoverLabel.snp.makeConstraints { (make) in
+            make.bottom.left.right.equalToSuperview()
+            make.height.equalTo(24)
+        }
+    }
+    
+    
+    func setupUpdata() {
+        coverImageButton.rx.tap.subscribe(onNext: {
+            [weak self] (_) in
+            let vc = PublishCoverVideoViewController()
+            vc.publishManagerVideoModel = self?.publishManagerVideoModel
+            vc.selectedOutCoverImagePathClosure = {
+               [weak self] (coverImage) in
+                guard let strongSelf = self else { return }
+                strongSelf.coverImage = coverImage
+            }
+            UIViewController.topMost?.navigationController?.pushViewController(vc, animated: true)
+        }).disposed(by: disposeBag)
+    }
+    
+    
+    lazy var coverImageButton: UIButton = {
+        let coverImageButton = UIButton()
+        coverImageButton.setImage(kImage(name: "default_pic"), for: UIControl.State.normal)
+        coverImageButton.imageView?.contentMode = .scaleAspectFill
+        coverImageButton.cornerRadius = 2
+        coverImageButton.masksToBounds = true
+        return coverImageButton
+    }()
+    
+    lazy var selectedCoverLabel: UILabel = {
+        let selectedCoverLabel = UILabel()
+        selectedCoverLabel.text = "选封面"
+        selectedCoverLabel.textColor = kffffffColor
+        selectedCoverLabel.font = kRegularFont12
+        selectedCoverLabel.textAlignment = .center
+        selectedCoverLabel.backgroundColor = k000000Color.withAlphaComponent(0.36)
+        return selectedCoverLabel
+    }()
+    
+    var tableView: UITableView?
+    var indexPath: IndexPath?
+    /// 封面路径
+    var publishManagerVideoModel : PublishManagerVideoModel? {
+        didSet {
+            coverImageButton.setImage(UIImage(named: publishManagerVideoModel?.outCoverImagePath ?? "default_pic"), for: UIControl.State.normal)
+        }
+    }
+    var coverImage : UIImage? {
+        didSet {
+            coverImageButton.setImage(coverImage, for: UIControl.State.normal)
+            let imgData: Data? = UIImage.pngData(coverImage!)()
+            do {                
+                // 清除图片路径
+                PathURLManager.clearPath(pathURL:
+                    PathURLManager.projectPicturesPath(parentURL:
+                        PathURLManager.projectResourcesPath(parentURL:
+                            PathURLManager.projectRecordssPath(parentURL:
+                                PathURLManager.projectDocumentPath())))!)
+                
+                //设置录制视频封面输出路径
+                let outCoverImagePathURL =
+                    PathURLManager.projectPathExtensionPng(parentURL:
+                        PathURLManager.projectFilePath(fileName:
+                            PathURLManager.randomString(), parentURL:
+                                PathURLManager.projectDateFormatPath(dateFormat: "yyyyMM", parentURL:
+                                    PathURLManager.projectPicturesPath(parentURL:
+                                        PathURLManager.projectResourcesPath(parentURL:
+                                            PathURLManager.projectRecordssPath(parentURL:
+                                                PathURLManager.projectDocumentPath()))))))!
+                
+                try imgData?.write(to: outCoverImagePathURL)
+                publishManagerVideoModel?.outCoverImagePath = outCoverImagePathURL.path
+                publishManagerVideoModel?.outCoverImagePathURL = outCoverImagePathURL
+            }
+            catch {
+                SwiftProgressHUD.shared().showText("封面写入失败")
+                NXLLog("存入失败")
+                return
+            }
+        }
+    }
+}

RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/View/PublishNewEditLocationView/PublishNewEditLocationTableViewCell.swift → RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishNewEditLocationView/PublishNewEditLocationTableViewCell.swift


RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/View/PublishNewEditTopicView/PublishNewEditTopicViewTableViewCell.swift → RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditContent/View/PublishNewEditTopicView/PublishNewEditTopicViewTableViewCell.swift


+ 23 - 7
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/ViewController/PublishEditVideoContentViewController.swift

@@ -13,8 +13,6 @@ class PublishEditVideoContentViewController: BaseViewController {
     var isRenewEdit : Bool = false
     /// 合成导出路径
     var outputPath : String?
-    /// 封面路径
-    var outCoverImagePath : String?
     /// 发布模型
     var publishManagerModel : PublishManagerModel?
     /// 视频路径模型
@@ -36,7 +34,26 @@ class PublishEditVideoContentViewController: BaseViewController {
     
     func setVideoCoverImagePath() {
         
+        
         if publishManagerModel == nil {
+            // 清除图片路径
+            PathURLManager.clearPath(pathURL:
+                PathURLManager.projectPicturesPath(parentURL:
+                    PathURLManager.projectResourcesPath(parentURL:
+                        PathURLManager.projectRecordssPath(parentURL:
+                            PathURLManager.projectDocumentPath())))!)
+            
+            //设置录制视频封面输出路径
+            let outCoverImagePathURL =
+                PathURLManager.projectPathExtensionPng(parentURL:
+                    PathURLManager.projectFilePath(fileName:
+                        PathURLManager.randomString(), parentURL:
+                            PathURLManager.projectDateFormatPath(dateFormat: "yyyyMM", parentURL:
+                                PathURLManager.projectPicturesPath(parentURL:
+                                    PathURLManager.projectResourcesPath(parentURL:
+                                        PathURLManager.projectRecordssPath(parentURL:
+                                            PathURLManager.projectDocumentPath()))))))!
+            
             // 视频路径
             let asset = AVURLAsset.init(url: URL(fileURLWithPath: outputPath ?? ""))
             let gen = AVAssetImageGenerator.init(asset: asset)
@@ -49,7 +66,7 @@ class PublishEditVideoContentViewController: BaseViewController {
                 let imageNew = UIImage.rotate(aImage: UIImage(cgImage: image))
                 let imgData: Data? = UIImage.pngData(imageNew)()
                 do {
-                    try imgData?.write(to: URL(fileURLWithPath: outCoverImagePath ?? ""))
+                    try imgData?.write(to: outCoverImagePathURL)
                 }
                 catch {
                     SwiftProgressHUD.shared().showText("封面写入失败")
@@ -66,8 +83,8 @@ class PublishEditVideoContentViewController: BaseViewController {
             publishManagerVideoModel = PublishManagerVideoModel()
             publishManagerVideoModel?.outVideoPath = outputPath
             publishManagerVideoModel?.outVideoPathURL = URL(fileURLWithPath: outputPath ?? "")
-            publishManagerVideoModel?.outCoverImagePath = outCoverImagePath
-            publishManagerVideoModel?.outCoverImagePathURL = URL(fileURLWithPath: outCoverImagePath ?? "")
+            publishManagerVideoModel?.outCoverImagePath = outCoverImagePathURL.path
+            publishManagerVideoModel?.outCoverImagePathURL = outCoverImagePathURL
             //发布内容
             publishManagerContentModel = PublishManagerContentModel()
             // 话题
@@ -192,8 +209,7 @@ extension PublishEditVideoContentViewController : UITableViewDelegate, UITableVi
         switch indexPath.row {
         case 0:
             let cell = PublishEditVideoCoverImageTableViewCell.cellWith(tableView: tableView, indexPath: indexPath)
-            cell.coverImageButton.setImage(UIImage(named: publishManagerVideoModel?.outCoverImagePath ?? "default_pic"), for: UIControl.State.normal)
-           
+            cell.publishManagerVideoModel = publishManagerVideoModel
             return cell
         case 1:
             let cell = PublishEditContentViewTitleCell.cellWith(tableView: tableView, indexPath: indexPath)

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

@@ -29,8 +29,6 @@ class PublishEditNewVideoView: UIView {
     var taskPath : String?
     /// 合成导出路径
     var outputPath : String?
-    /// 封面路径
-    var outCoverImagePath : String?
     /// 是否正在播放
     var isPlaying : Bool = true
     /// 滤镜选中的selected
@@ -57,7 +55,6 @@ class PublishEditNewVideoView: UIView {
         frame = CGRect(x: 0, y: 0, width: kScreenWidth, height: kScreenHeight)
         self.taskPath = taskPath
         self.outputPath = outputPath
-        self.outCoverImagePath = outCoverImagePath
         setupViews()
         setupLayouts()
         setupData()
@@ -670,7 +667,6 @@ extension PublishEditNewVideoView : AliyunIExporterCallback {
         
         let vc = PublishEditVideoContentViewController()
         vc.outputPath = outputPath
-        vc.outCoverImagePath = outCoverImagePath
         vc.popClosure = {
             [weak self] in
             guard let strongSelf = self else { return }

+ 0 - 75
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishEditVideo/View/PublishEditVideoCoverImageView/PublishEditVideoCoverImageTableViewCell.swift

@@ -1,75 +0,0 @@
-//
-//  PublishEditVideoCoverImageTableViewCell.swift
-//  RainbowPlanet
-//
-//  Created by 南鑫林 on 2019/11/11.
-//  Copyright © 2019 RainbowPlanet. All rights reserved.
-//
-
-import UIKit
-
-class PublishEditVideoCoverImageTableViewCell: UITableViewCell {
-
-    class func cellWith(tableView:UITableView,indexPath:IndexPath) -> PublishEditVideoCoverImageTableViewCell {
-           let ID = "PublishEditVideoCoverImageTableViewCell"
-           tableView.register(PublishEditVideoCoverImageTableViewCell.self, forCellReuseIdentifier: ID)
-           let cell : PublishEditVideoCoverImageTableViewCell = tableView.dequeueReusableCell(withIdentifier: ID, for: indexPath) as! PublishEditVideoCoverImageTableViewCell
-           cell.indexPath = indexPath
-           return cell
-    }
-       
-    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
-       super.init(style: style, reuseIdentifier: reuseIdentifier)
-       setupViews()
-       setupLayouts()
-    }
-
-    required init?(coder aDecoder: NSCoder) {
-       fatalError("init(coder:) has not been implemented")
-    }
-
-    var indexPath: IndexPath? {
-       didSet {
-           
-       }
-    }
-
-    //MRAK: - 设置View
-    private func setupViews() {
-       self.selectionStyle = .none
-        addSubview(coverImageButton)
-        coverImageButton.addSubview(selectedCoverLabel)
-    }
-
-    private func setupLayouts() {
-        coverImageButton.snp.makeConstraints { (make) in
-            make.top.equalTo(15)
-            make.left.equalTo(14)
-            make.size.equalTo(100)
-        }
-        selectedCoverLabel.snp.makeConstraints { (make) in
-            make.bottom.left.right.equalToSuperview()
-            make.height.equalTo(24)
-        }
-    }
-    
-    lazy var coverImageButton: UIButton = {
-        let coverImageButton = UIButton()
-        coverImageButton.setImage(kImage(name: "default_pic"), for: UIControl.State.normal)
-        coverImageButton.imageView?.contentMode = .scaleAspectFill
-        coverImageButton.cornerRadius = 2
-        coverImageButton.masksToBounds = true
-        return coverImageButton
-    }()
-    
-    lazy var selectedCoverLabel: UILabel = {
-        let selectedCoverLabel = UILabel()
-        selectedCoverLabel.text = "选封面"
-        selectedCoverLabel.textColor = kffffffColor
-        selectedCoverLabel.font = kRegularFont12
-        selectedCoverLabel.textAlignment = .center
-        selectedCoverLabel.backgroundColor = k000000Color.withAlphaComponent(0.36)
-        return selectedCoverLabel
-    }()
-
-}

+ 3 - 3
RainbowPlanet/RainbowPlanet/Modules/PublishNewModule/PublishManager/PublishManager.swift

@@ -161,18 +161,18 @@ extension PublishManager {
                          }
                     }else {
                         if let failureClosure = self?.failureClosure {
-                            failureClosure(rootModel.msg ?? "发布失败!!")
+                            failureClosure(rootModel.msg ?? "信息有误!")
                         }
                     }
                 }, fail: {
                     if let failureClosure = self?.failureClosure {
-                        failureClosure("发布失败!!")
+                        failureClosure("信息有误!")
                 }
             })
 
         }) { [weak self] _ in
             if let failureClosure = self?.failureClosure {
-                failureClosure("发布失败!!")
+                failureClosure("信息有误!")
             }
         }
     }

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

@@ -30,8 +30,6 @@ class PublishNewVideoPhotoView: BaseView {
     var selectedIndex : Int = 0
     /// 是否完成录制
     var isFinishRecorder : Bool = false
-    /// 封面图路径
-    var outCoverImagePathURL : URL?
     
     /// 添加View
     override func setupViews() {
@@ -229,6 +227,14 @@ class PublishNewVideoPhotoView: BaseView {
         let recorder = AliyunIRecorder.init(delegate: self, videoSize: CGSize(width: 720, height: 1280))
         // 预览View
         recorder?.preview = recorderPreview
+        
+        //清除录制路径
+        PathURLManager.clearPath(pathURL:
+            PathURLManager.projectVideosPath(parentURL:
+                PathURLManager.projectResourcesPath(parentURL:
+                    PathURLManager.projectRecordssPath(parentURL:
+                        PathURLManager.projectDocumentPath())))!)
+        
         //创建文件夹路径
         let taskPathUrl =
             PathURLManager.projectDateFormatPath(dateFormat: "yyyyMM", parentURL:
@@ -236,8 +242,6 @@ class PublishNewVideoPhotoView: BaseView {
                     PathURLManager.projectResourcesPath(parentURL:
                         PathURLManager.projectRecordssPath(parentURL:
                             PathURLManager.projectDocumentPath()))))!
-        //清除录制路径
-        PathURLManager.clearPath(pathURL: taskPathUrl)
 
         // 设置文件夹路径
         recorder?.taskPath = taskPathUrl.path
@@ -252,17 +256,7 @@ class PublishNewVideoPhotoView: BaseView {
                                 PathURLManager.projectResourcesPath(parentURL:
                                     PathURLManager.projectRecordssPath(parentURL:
                                         PathURLManager.projectDocumentPath()))))))!
-        
-        // 设置录制视频封面输出路径
-        outCoverImagePathURL =
-            PathURLManager.projectPathExtensionPng(parentURL:
-                PathURLManager.projectFilePath(fileName:
-                    PathURLManager.randomString(), parentURL:
-                        PathURLManager.projectDateFormatPath(dateFormat: "yyyyMM", parentURL:
-                            PathURLManager.projectPicturesPath(parentURL:
-                                PathURLManager.projectResourcesPath(parentURL:
-                                    PathURLManager.projectRecordssPath(parentURL:
-                                        PathURLManager.projectDocumentPath()))))))!
+
         // 设置录制视频输出路径
         recorder?.outputPath = outputPathURL.path
         //循环切换手电筒模式手电筒模式有三种,分别是off,on和auto。切换顺序:off —-> on —-> auto。默认值:off。
@@ -818,7 +812,6 @@ extension PublishNewVideoPhotoView : AliyunIRecorderDelegate {
             let vc = PublishEditNewViewController()
             vc.taskPath = self?.recorder?.taskPath
             vc.outputPath = self?.recorder?.outputPath
-            vc.outCoverImagePath = self?.outCoverImagePathURL?.path
             vc.popClosure = {
                 [weak self] in
                 self?.recorder?.startPreview()

+ 1 - 1
RainbowPlanet/RainbowPlanet/ViewModel/Virus/VirusViewModel.swift

@@ -1060,7 +1060,7 @@ extension VirusViewModel {
         
         virueRecordAddParameterModel.postId = postId
         virueRecordAddParameterModel.actionId = "\(postId ?? 0)"
-        if title == "" {
+        if title == "" || title == nil  {
             virueRecordAddParameterModel.postDesc = "\(content?.prefix(20) ?? "")"
         }else {
             virueRecordAddParameterModel.postDesc = title