|
@@ -12,12 +12,12 @@ enum createStickersModel {
|
|
|
case createStickersModelSpeed // 快慢速
|
|
|
}
|
|
|
|
|
|
+import BFCommonKit
|
|
|
import Foundation
|
|
|
import ObjectMapper
|
|
|
+import Photos
|
|
|
import RealmSwift
|
|
|
import UIKit
|
|
|
-import BFCommonKit
|
|
|
-import Photos
|
|
|
|
|
|
class PQStuckPointEditerController: PQBaseViewController {
|
|
|
// 是否导出视频成功
|
|
@@ -62,6 +62,7 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
var selectedMetarialData: [PQEditVisionTrackMaterialsModel]?
|
|
|
// 选中的音乐数据
|
|
|
var stuckPointMusicData: PQVoiceModel?
|
|
@@ -72,9 +73,9 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
var mStickers: [PQEditVisionTrackMaterialsModel]?
|
|
|
// 播放器的开始和结束时间,1,刚进界面使用推荐的开始结束时间,2,用户修改起结点时修改
|
|
|
var playeTimeRange: CMTimeRange = CMTimeRange()
|
|
|
-
|
|
|
- //add by ak 是否是再创作模式
|
|
|
- var isReCreate:Bool = false
|
|
|
+
|
|
|
+ // add by ak 是否是再创作模式
|
|
|
+ var isReCreate: Bool = false
|
|
|
// 下一步
|
|
|
lazy var nextBtn: UIButton = {
|
|
|
let nextBtn = UIButton(type: .custom)
|
|
@@ -203,7 +204,7 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
musicNameView.addCorner(corner: musicNameView.frame.height / 2)
|
|
|
let musicImageView = UIImageView()
|
|
|
musicImageView.tintColor = PQBFConfig.shared.styleTitleColor
|
|
|
- musicImageView.image = UIImage.moduleImage(named: "stuckPoint_reCreate_music", moduleName: "BFFramework",isAssets: false)?.withRenderingMode(.alwaysTemplate)
|
|
|
+ musicImageView.image = UIImage.moduleImage(named: "stuckPoint_reCreate_music", moduleName: "BFFramework", isAssets: false)?.withRenderingMode(.alwaysTemplate)
|
|
|
musicImageView.frame = CGRect(x: musicNameView.frame.height / 2 - 5, y: (musicNameView.frame.height - 22) / 2, width: 22, height: 22)
|
|
|
musicNameView.addSubview(musicImageView)
|
|
|
musicNameLab.frame.origin.x = musicImageView.frame.maxX + 5
|
|
@@ -278,7 +279,7 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
- leftButton(image: UIImage.init(named: "icon_detail_back"), tintColor: PQBFConfig.shared.styleTitleColor)
|
|
|
+ leftButton(image: UIImage(named: "icon_detail_back"), tintColor: PQBFConfig.shared.styleTitleColor)
|
|
|
navHeadImageView?.addSubview(nextBtn)
|
|
|
navHeadImageView?.addSubview(musicNameView)
|
|
|
// 添加子视图
|
|
@@ -311,11 +312,6 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
@objc func nextBtnClick(sender _: UIButton) {
|
|
|
BFLog(message: "去发布")
|
|
|
playerView.pause()
|
|
|
- let videoExporter = PQStuckPointPublicController()
|
|
|
- videoExporter.isReCreate = isReCreate
|
|
|
- videoExporter.selectedTotalDuration = selectedTotalDuration
|
|
|
- videoExporter.selectedDataCount = selectedDataCount
|
|
|
- videoExporter.selectedImageDataCount = selectedImageDataCount
|
|
|
// 使用深 copy
|
|
|
let json = projectModel.toJSONString(prettyPrint: false)
|
|
|
if json == nil {
|
|
@@ -323,10 +319,23 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
return
|
|
|
}
|
|
|
let tempModel: PQEditProjectModel? = Mapper<PQEditProjectModel>().map(JSONString: json!)
|
|
|
- videoExporter.mStickers = mStickers
|
|
|
- videoExporter.audioMixModel = stuckPointMusicData
|
|
|
- videoExporter.editProjectModel = tempModel
|
|
|
- navigationController?.pushViewController(videoExporter, animated: true)
|
|
|
+ let materialVC: PQStuckPointMaterialController? = navigationController?.viewControllers.first(where: { (vc) -> Bool in
|
|
|
+ vc is PQStuckPointMaterialController
|
|
|
+ }) as? PQStuckPointMaterialController
|
|
|
+
|
|
|
+ if materialVC != nil, materialVC?.isToPublicHandle != nil {
|
|
|
+ materialVC?.isToPublicHandle!(isReCreate, selectedTotalDuration, selectedDataCount, selectedImageDataCount, mStickers, stuckPointMusicData, tempModel)
|
|
|
+ } else {
|
|
|
+ let videoExporter = PQStuckPointPublicController()
|
|
|
+ videoExporter.isReCreate = isReCreate
|
|
|
+ videoExporter.selectedTotalDuration = selectedTotalDuration
|
|
|
+ videoExporter.selectedDataCount = selectedDataCount
|
|
|
+ videoExporter.selectedImageDataCount = selectedImageDataCount
|
|
|
+ videoExporter.mStickers = mStickers
|
|
|
+ videoExporter.audioMixModel = stuckPointMusicData
|
|
|
+ videoExporter.editProjectModel = tempModel
|
|
|
+ navigationController?.pushViewController(videoExporter, animated: true)
|
|
|
+ }
|
|
|
// 点击上报:去合成
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_commit, pageSource: .sp_stuck_previewSyncedUp, extParams: ["musicName": stuckPointMusicData?.musicName ?? "", "musicId": stuckPointMusicData?.musicId ?? "", "rhythmNumber": stuckPointMusicData?.speed ?? 2, "duration": ((stuckPointMusicData?.endTime ?? 0) - (stuckPointMusicData?.startTime ?? 0)) * 1000], remindmsg: "点击上报:去合成")
|
|
|
}
|
|
@@ -404,7 +413,7 @@ class PQStuckPointEditerController: PQBaseViewController {
|
|
|
videoSize = CGSize(width: minSlider, height: maxSlider)
|
|
|
}
|
|
|
|
|
|
- let maxValue = max(videoSize.width , videoSize.height ?? 0)
|
|
|
+ let maxValue = max(videoSize.width, videoSize.height ?? 0)
|
|
|
if maxValue > 1920 {
|
|
|
let maxRation = 1920 / maxValue
|
|
|
|
|
@@ -613,7 +622,7 @@ extension PQStuckPointEditerController {
|
|
|
}
|
|
|
// 开始时间是服务器返回, 结果时间根据策略计算的
|
|
|
stuckPoints.insert(Float(CMTimeGetSeconds(playeTimeRange.start)), at: 0)
|
|
|
- stuckPoints.insert((Float(CMTimeGetSeconds(playeTimeRange.end))), at: stuckPoints.count)
|
|
|
+ stuckPoints.insert(Float(CMTimeGetSeconds(playeTimeRange.end)), at: stuckPoints.count)
|
|
|
|
|
|
for point in stuckPoints {
|
|
|
BFLog(message: "有 start end 计算后的卡点数\(point)")
|
|
@@ -746,7 +755,7 @@ extension PQStuckPointEditerController {
|
|
|
}
|
|
|
// 开始时间是服务器返回, 结果时间根据策略计算的
|
|
|
stuckPoints.insert(Float(CMTimeGetSeconds(playeTimeRange.start)), at: 0)
|
|
|
- stuckPoints.insert((Float(CMTimeGetSeconds(playeTimeRange.end))), at: stuckPoints.count)
|
|
|
+ stuckPoints.insert(Float(CMTimeGetSeconds(playeTimeRange.end)), at: stuckPoints.count)
|
|
|
|
|
|
for point in stuckPoints {
|
|
|
BFLog(message: "有 start end 计算后的卡点数\(point)")
|
|
@@ -805,12 +814,12 @@ extension PQStuckPointEditerController {
|
|
|
|
|
|
sticker.model_in = Double(index * spit)
|
|
|
sticker.out = sticker.model_in + Double(spit)
|
|
|
-
|
|
|
+
|
|
|
// let spit: Int = 2
|
|
|
// sticker.timelineIn = 57.5
|
|
|
// sticker.timelineOut = sticker.timelineIn + 24
|
|
|
// sticker.speedRate = index % 2 == 0 ? 0.1 : 2
|
|
|
-//// sticker.speedRate = 0.1
|
|
|
+ //// sticker.speedRate = 0.1
|
|
|
// sticker.model_in = 0
|
|
|
// sticker.out = sticker.model_in + 24
|
|
|
|
|
@@ -946,7 +955,7 @@ extension PQStuckPointEditerController {
|
|
|
material.asset == photo.asset
|
|
|
})
|
|
|
|
|
|
- if (fileName.count) > 0 {
|
|
|
+ if fileName.count > 0 {
|
|
|
createDirectory(path: photoLibraryDirectory)
|
|
|
let outFilePath = photoLibraryDirectory + fileName.md5 + ".mp4"
|
|
|
// 文件存在先删除老文件
|