|
@@ -49,22 +49,22 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
var mStickers: [PQEditVisionTrackMaterialsModel]?
|
|
|
|
|
|
var remindView: PQRemindView?
|
|
|
- //已经选择标题内容,加一个属性接收 使用有不在主线不能直接使用 titleLabel text
|
|
|
- var selectTitle:String = ""
|
|
|
-
|
|
|
- //add by ak 玩法类型 调用 producevideo/saveProject 时使用
|
|
|
- var rhythmMode:createStickersModel = .createStickersModelPoint
|
|
|
-
|
|
|
- //add by ak 设置的速度
|
|
|
- var syncedUpVideoSpeedMax:Float = 0.0
|
|
|
- var syncedUpVideoSpeedMin:Float = 0.0
|
|
|
-
|
|
|
- //add by ak 是否是再创作模式
|
|
|
- var isReCreate:Bool = false
|
|
|
-
|
|
|
- //最终使用的音频时长,用于拼接音乐使用
|
|
|
- var finallyUserAudioTime:Float = 0.0
|
|
|
- //拼接音乐的开始和结束位置
|
|
|
+ // 已经选择标题内容,加一个属性接收 使用有不在主线不能直接使用 titleLabel text
|
|
|
+ var selectTitle: String = ""
|
|
|
+
|
|
|
+ // add by ak 玩法类型 调用 producevideo/saveProject 时使用
|
|
|
+ var rhythmMode: createStickersModel = .createStickersModelPoint
|
|
|
+
|
|
|
+ // add by ak 设置的速度
|
|
|
+ var syncedUpVideoSpeedMax: Float = 0.0
|
|
|
+ var syncedUpVideoSpeedMin: Float = 0.0
|
|
|
+
|
|
|
+ // add by ak 是否是再创作模式
|
|
|
+ var isReCreate: Bool = false
|
|
|
+
|
|
|
+ // 最终使用的音频时长,用于拼接音乐使用
|
|
|
+ var finallyUserAudioTime: Float = 0.0
|
|
|
+ // 拼接音乐的开始和结束位置
|
|
|
var clipAudioRange: CMTimeRange = CMTimeRange.zero
|
|
|
// 导出的开始的开始和结束时间
|
|
|
var playeTimeRange: CMTimeRange = CMTimeRange()
|
|
@@ -161,14 +161,14 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
playerHeaderView.clipsToBounds = true
|
|
|
return playerHeaderView
|
|
|
}()
|
|
|
-
|
|
|
+
|
|
|
// add by ak 播放器的封面 为了不和原有的播放器层级单独添加一个 view
|
|
|
lazy var playerHeaderCoverImageView: UIImageView = {
|
|
|
- let playerHeaderCoverImageView = UIImageView.init()
|
|
|
+ let playerHeaderCoverImageView = UIImageView()
|
|
|
playerHeaderCoverImageView.isUserInteractionEnabled = true
|
|
|
playerHeaderCoverImageView.contentMode = .scaleAspectFit
|
|
|
playerHeaderCoverImageView.clipsToBounds = true
|
|
|
-
|
|
|
+
|
|
|
let playBtn = UIButton(type: .custom)
|
|
|
playBtn.setImage(UIImage().BF_Image(named: "icon_video_play"), for: .normal)
|
|
|
playBtn.tag = 4
|
|
@@ -184,7 +184,7 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: avPlayer.currentItem, queue: .main) { [weak self] notify in
|
|
|
BFLog(message: "AVPlayerItemDidPlayToEndTime = \(notify)")
|
|
|
avPlayer.seek(to: CMTime.zero)
|
|
|
- if(self?.playerHeaderCoverImageView.image != nil){
|
|
|
+ if self?.playerHeaderCoverImageView.image != nil {
|
|
|
self?.playerHeaderCoverImageView.isHidden = false
|
|
|
}
|
|
|
self?.playBtn.isHidden = false
|
|
@@ -248,7 +248,7 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
return progressView
|
|
|
}()
|
|
|
|
|
|
- //提示
|
|
|
+ // 提示
|
|
|
lazy var remindLab: UILabel = {
|
|
|
let remindLab = UILabel()
|
|
|
remindLab.font = UIFont.boldSystemFont(ofSize: 18)
|
|
@@ -259,8 +259,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
remindLab.text = "为你的大作起个响亮的标题\n分享秀一下🎉"
|
|
|
return remindLab
|
|
|
}()
|
|
|
-
|
|
|
- //输入框背景
|
|
|
+
|
|
|
+ // 输入框背景
|
|
|
lazy var inputBackView: UIView = {
|
|
|
let inputBackView = UIView()
|
|
|
inputBackView.backgroundColor = .clear
|
|
@@ -269,13 +269,15 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
inputBackView.layer.borderColor = UIColor.hexColor(hexadecimal: PQBFConfig.shared.styleColor.rawValue).cgColor
|
|
|
return inputBackView
|
|
|
}()
|
|
|
+
|
|
|
// 手势提示
|
|
|
lazy var pinView: UIImageView = {
|
|
|
let pinView = UIImageView()
|
|
|
pinView.kf.setImage(with: URL(fileURLWithPath: Bundle().BF_mainbundle().path(forResource: "editCoverPin", ofType: ".gif")!))
|
|
|
return pinView
|
|
|
}()
|
|
|
- //封面
|
|
|
+
|
|
|
+ // 封面
|
|
|
lazy var coverImageView: UIImageView = {
|
|
|
let coverImageView = UIImageView()
|
|
|
coverImageView.isUserInteractionEnabled = true
|
|
@@ -283,7 +285,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
coverImageView.contentMode = .scaleToFill
|
|
|
return coverImageView
|
|
|
}()
|
|
|
- //封面标题
|
|
|
+
|
|
|
+ // 封面标题
|
|
|
lazy var coverImageTitle: UILabel = {
|
|
|
let coverImageTitle = UILabel()
|
|
|
coverImageTitle.text = "换封面"
|
|
@@ -293,10 +296,10 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
coverImageTitle.textColor = .white
|
|
|
coverImageTitle.font = UIFont.boldSystemFont(ofSize: 12)
|
|
|
return coverImageTitle
|
|
|
-
|
|
|
+
|
|
|
}()
|
|
|
-
|
|
|
- //标题
|
|
|
+
|
|
|
+ // 标题
|
|
|
lazy var titleLabel: UILabel = {
|
|
|
let titleLabel = UILabel()
|
|
|
titleLabel.numberOfLines = 2
|
|
@@ -308,48 +311,45 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
titleLabel.addGestureRecognizer(ges)
|
|
|
return titleLabel
|
|
|
}()
|
|
|
-
|
|
|
- //编辑发布标题
|
|
|
+
|
|
|
+ // 编辑发布标题
|
|
|
lazy var publicTitleView: PQEditPublicTitleView = {
|
|
|
let publicTitleView = PQEditPublicTitleView()
|
|
|
publicTitleView.isHidden = true
|
|
|
publicTitleView.confirmBtnClock = { [weak self] title in
|
|
|
BFLog(message: "传出的 title is :\(String(describing: title))")
|
|
|
- if(title?.count != 0 && title != self?.titleLabel.text){
|
|
|
+ if title?.count != 0 && title != self?.titleLabel.text {
|
|
|
self?.changPlayerIsPause(isPause: false)
|
|
|
|
|
|
- //判断文字是否有效
|
|
|
+ // 判断文字是否有效
|
|
|
var inputText = ""
|
|
|
inputText = title?.replacingOccurrences(of: "\n", with: "") ?? ""
|
|
|
inputText = inputText.replacingOccurrences(of: " ", with: "")
|
|
|
-
|
|
|
- if(inputText.count > 0){
|
|
|
- self?.setTitleText(text: title ?? "",textColor: .black)
|
|
|
- //更新数据
|
|
|
+
|
|
|
+ if inputText.count > 0 {
|
|
|
+ self?.setTitleText(text: title ?? "", textColor: .black)
|
|
|
+ // 更新数据
|
|
|
self?.videoData?.title = title
|
|
|
self?.updateCoverImagegOrTitle()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
publicTitleView.viewIsHiddenCallBack = { [weak self] in
|
|
|
-
|
|
|
+
|
|
|
self?.changPlayerIsPause(isPause: false)
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return publicTitleView
|
|
|
}()
|
|
|
-
|
|
|
- //编辑发布封面
|
|
|
+
|
|
|
+ // 编辑发布封面
|
|
|
lazy var publicEditCoverView: PQEditPublicCoverImageView = {
|
|
|
- let publicEditCoverView = PQEditPublicCoverImageView.init(frame: CGRect.init(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
|
+ let publicEditCoverView = PQEditPublicCoverImageView(frame: CGRect(x: 0, y: 0, width: cScreenWidth, height: cScreenHeigth))
|
|
|
publicEditCoverView.isHidden = true
|
|
|
return publicEditCoverView
|
|
|
}()
|
|
|
-
|
|
|
- //分享到朋友圈
|
|
|
+
|
|
|
+ // 分享到朋友圈
|
|
|
lazy var shareWechatBtn: UIButton = {
|
|
|
let shareWechatBtn = UIButton(type: .custom)
|
|
|
shareWechatBtn.frame = CGRect(x: 0, y: 0, width: 70, height: 70)
|
|
@@ -360,7 +360,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
shareWechatBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
|
|
|
return shareWechatBtn
|
|
|
}()
|
|
|
- //分享到好友
|
|
|
+
|
|
|
+ // 分享到好友
|
|
|
lazy var shareFriendBtn: UIButton = {
|
|
|
let shareFriendBtn = UIButton(type: .custom)
|
|
|
shareFriendBtn.frame = CGRect(x: 0, y: 0, width: 70, height: 70)
|
|
@@ -371,8 +372,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
shareFriendBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
|
|
|
return shareFriendBtn
|
|
|
}()
|
|
|
-
|
|
|
- //关闭
|
|
|
+
|
|
|
+ // 关闭
|
|
|
lazy var finishedBtn: UIButton = {
|
|
|
let finishedBtn = UIButton(type: .custom)
|
|
|
finishedBtn.setTitle("完成", for: .normal)
|
|
@@ -383,7 +384,7 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
finishedBtn.addCorner(corner: 3)
|
|
|
finishedBtn.addTarget(self, action: #selector(btnClick(sender:)), for: .touchUpInside)
|
|
|
return finishedBtn
|
|
|
-
|
|
|
+
|
|
|
}()
|
|
|
|
|
|
/// 背景View
|
|
@@ -392,15 +393,14 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
oprationBgView.backgroundColor = .clear
|
|
|
return oprationBgView
|
|
|
}()
|
|
|
-
|
|
|
- //除了播放器以外的 下半部分操作区
|
|
|
+
|
|
|
+ // 除了播放器以外的 下半部分操作区
|
|
|
lazy var bottomOprationBgView: UIView = {
|
|
|
let bottomOprationBgView = UIView(frame: CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei + maxHeight, width: cScreenWidth, height: view.frame.height - cDevice_iPhoneNavBarAndStatusBarHei - maxHeight))
|
|
|
bottomOprationBgView.backgroundColor = .clear
|
|
|
bottomOprationBgView.isHidden = true
|
|
|
return bottomOprationBgView
|
|
|
}()
|
|
|
-
|
|
|
|
|
|
override func backBtnClick() {
|
|
|
if isExportSuccess {
|
|
@@ -440,8 +440,7 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
playerHeaderView.frame = CGRect(origin: CGPoint(x: (cScreenWidth - preViewSize.width) / 2, y: (maxHeight - preViewSize.height) / 2), size: preViewSize)
|
|
|
let ges = UITapGestureRecognizer(target: self, action: #selector(playVideo))
|
|
|
playerHeaderView.addGestureRecognizer(ges)
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
if playerLayer.superlayer == nil {
|
|
|
playerHeaderView.layer.insertSublayer(playerLayer, at: 0)
|
|
|
}
|
|
@@ -449,18 +448,17 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
playerHeaderView.addSubview(progressView)
|
|
|
view.addSubview(oprationBgView)
|
|
|
oprationBgView.addSubview(progressTipsLab)
|
|
|
-
|
|
|
+
|
|
|
// 添加导出view
|
|
|
bgTopView.addSubview(playerHeaderView)
|
|
|
-
|
|
|
+
|
|
|
playerHeaderCoverImageView.frame = playerHeaderView.frame
|
|
|
playerHeaderCoverImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(playVideo)))
|
|
|
-
|
|
|
+
|
|
|
(playerHeaderCoverImageView.viewWithTag(4))?.frame =
|
|
|
- CGRect(x: (preViewSize.width - cDefaultMargin * 5) / 2, y: (preViewSize.height - cDefaultMargin * 5) / 2, width: cDefaultMargin * 5, height: cDefaultMargin * 5)
|
|
|
+ CGRect(x: (preViewSize.width - cDefaultMargin * 5) / 2, y: (preViewSize.height - cDefaultMargin * 5) / 2, width: cDefaultMargin * 5, height: cDefaultMargin * 5)
|
|
|
bgTopView.addSubview(playerHeaderCoverImageView)
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
view.addSubview(bottomOprationBgView)
|
|
|
bottomOprationBgView.addSubview(remindLab)
|
|
|
bottomOprationBgView.addSubview(shareWechatBtn)
|
|
@@ -471,13 +469,13 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
inputBackView.addSubview(coverImageView)
|
|
|
coverImageView.addSubview(coverImageTitle)
|
|
|
inputBackView.addSubview(titleLabel)
|
|
|
-
|
|
|
+
|
|
|
view.addSubview(publicTitleView)
|
|
|
view.addSubview(publicEditCoverView)
|
|
|
-
|
|
|
+
|
|
|
coverImageTitle.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(settingCoverImage)))
|
|
|
coverImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(settingCoverImage)))
|
|
|
-
|
|
|
+
|
|
|
progressView.snp.makeConstraints { make in
|
|
|
make.left.right.centerY.equalTo(playerHeaderView)
|
|
|
make.height.equalTo(3)
|
|
@@ -504,36 +502,35 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
make.left.equalTo(view.snp_centerX).offset(cDefaultMargin)
|
|
|
make.width.bottom.height.equalTo(shareWechatBtn)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
inputBackView.snp.makeConstraints { make in
|
|
|
make.centerX.equalToSuperview()
|
|
|
make.bottom.equalTo(shareWechatBtn.snp_top).offset(-16)
|
|
|
make.width.equalTo(343)
|
|
|
make.height.equalTo(109)
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
- //根据横竖屏设置不同的 UI
|
|
|
- let isWidth:Bool = (Float(editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) / Float(editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) ) >= 1
|
|
|
+
|
|
|
+ // 根据横竖屏设置不同的 UI
|
|
|
+ let isWidth: Bool = (Float(editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) / Float(editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0)) >= 1
|
|
|
var coverImageViewHeight = 50.0 * Float(editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) / Float(editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)
|
|
|
- if(coverImageViewHeight > 89){
|
|
|
+ if coverImageViewHeight > 89 {
|
|
|
coverImageViewHeight = 89
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
coverImageView.snp.makeConstraints { make in
|
|
|
make.left.equalToSuperview().offset(12)
|
|
|
make.width.equalTo(50)
|
|
|
make.top.equalToSuperview().offset(10)
|
|
|
make.height.equalTo(coverImageViewHeight)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
coverImageTitle.snp.makeConstraints { make in
|
|
|
make.left.equalToSuperview()
|
|
|
make.width.equalTo(50)
|
|
|
make.top.equalTo(coverImageView.snp_bottom).offset(isWidth ? 0 : -23)
|
|
|
make.height.equalTo(23)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
remindLab.snp.makeConstraints { make in
|
|
|
make.centerX.equalToSuperview()
|
|
|
make.bottom.equalTo(inputBackView.snp_top).offset(-16).priorityHigh()
|
|
@@ -541,27 +538,26 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
make.top.greaterThanOrEqualTo(5)
|
|
|
make.bottom.lessThanOrEqualTo(inputBackView.snp_top).offset(-5)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
titleLabel.snp.makeConstraints { make in
|
|
|
make.height.equalTo(48)
|
|
|
make.left.equalTo(coverImageView.snp_right).offset(12)
|
|
|
make.right.equalToSuperview().offset(-14)
|
|
|
make.top.equalToSuperview().offset(10)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
pinView.snp.makeConstraints { make in
|
|
|
make.height.width.equalTo(72)
|
|
|
make.right.equalToSuperview()
|
|
|
make.bottom.equalTo(inputBackView.snp_bottom)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
publicTitleView.snp.makeConstraints { make in
|
|
|
make.height.equalTo(cScreenHeigth)
|
|
|
make.width.equalTo(cScreenWidth)
|
|
|
make.bottom.equalToSuperview()
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
// 取消所有的导出
|
|
|
PQSingletoMemoryUtil.shared.allExportSession.forEach { _, exportSession in
|
|
|
exportSession.cancelExport()
|
|
@@ -572,8 +568,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
saveDraftbox()
|
|
|
// 曝光上报:窗口曝光
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_windowView, objectType: .ot_view_publishSyncedUp, pageSource: .sp_stuck_publishSyncedUp, extParams: nil, remindmsg: "卡点视频数据上报-(曝光上报:窗口曝光)")
|
|
|
-
|
|
|
- //取推荐标题
|
|
|
+
|
|
|
+ // 取推荐标题
|
|
|
getTitles()
|
|
|
}
|
|
|
|
|
@@ -582,9 +578,8 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
PQNotification.addObserver(self, selector: #selector(enterBackground), name: UIApplication.didEnterBackgroundNotification, object: nil)
|
|
|
PQNotification.addObserver(self, selector: #selector(willEnterForeground), name: UIApplication.willEnterForegroundNotification, object: nil)
|
|
|
UIApplication.shared.isIdleTimerDisabled = true
|
|
|
-
|
|
|
-
|
|
|
- //从相册选择一个照片后回调
|
|
|
+
|
|
|
+ // 从相册选择一个照片后回调
|
|
|
addNotification(self, selector: #selector(imageSelectedImage(notify:)), name: cSelectedImageSuccessKey, object: nil)
|
|
|
|
|
|
#if swift(>=4.2)
|
|
@@ -631,50 +626,46 @@ class PQStuckPointPublicController: PQBaseViewController {
|
|
|
extension PQStuckPointPublicController {
|
|
|
/// fp1 - 导出视频
|
|
|
/// 开始导出视频
|
|
|
-
|
|
|
+
|
|
|
/// 合并声音
|
|
|
/// - Parameter urls: 所有音频的URL 是全路径方便复用
|
|
|
/// - Parameter completeHander: 返回的 URL 全路径的 URL 如果要保存替换掉前缀
|
|
|
- func mergeAudios(originAsset: AVURLAsset, mTotalDuration: Float,clipAudioRange: CMTimeRange = CMTimeRange.zero,mStartTime:CMTime = .zero , completeHander: @escaping (_ fileURL: URL?) -> Void) {
|
|
|
-
|
|
|
-
|
|
|
+ func mergeAudios(originAsset: AVURLAsset, mTotalDuration: Float, clipAudioRange: CMTimeRange = CMTimeRange.zero, mStartTime _: CMTime = .zero, completeHander: @escaping (_ fileURL: URL?) -> Void) {
|
|
|
let timeInterval: TimeInterval = Date().timeIntervalSince1970
|
|
|
let composition = AVMutableComposition()
|
|
|
-
|
|
|
+
|
|
|
let originaDuration = CMTimeGetSeconds(clipAudioRange.duration)
|
|
|
BFLog(message: "处理主音频 原始时长startTime = \(originaDuration) 要显示时长totalDuration = \(mTotalDuration)")
|
|
|
-
|
|
|
- if(Float64(mTotalDuration) <= originaDuration){
|
|
|
-
|
|
|
+
|
|
|
+ if Float64(mTotalDuration) <= originaDuration {
|
|
|
BFLog(message: "不用拼接音频文件 \(originAsset.url) 时长is \(CMTimeGetSeconds(originAsset.duration))")
|
|
|
completeHander(originAsset.url)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- //整倍数
|
|
|
+
|
|
|
+ // 整倍数
|
|
|
let count = Int(mTotalDuration) / Int(originaDuration)
|
|
|
|
|
|
- //有余数多 clip 一整段
|
|
|
+ // 有余数多 clip 一整段
|
|
|
let row = mTotalDuration - Float(count) * Float(originaDuration)
|
|
|
- //已经拼接的总时长
|
|
|
+ // 已经拼接的总时长
|
|
|
var totalDuration: CMTime = .zero
|
|
|
- //第一段的时长
|
|
|
+ // 第一段的时长
|
|
|
var duration: CMTime = .zero
|
|
|
- //第一段的区间
|
|
|
- var timeRange:CMTimeRange = CMTimeRange.zero
|
|
|
+ // 第一段的区间
|
|
|
+ var timeRange: CMTimeRange = CMTimeRange.zero
|
|
|
if count > 0 {
|
|
|
for index in 0 ..< count {
|
|
|
- //第0段从0开始到推荐的结束,播放器的开始时间不是从0开始的
|
|
|
+ // 第0段从0开始到推荐的结束,播放器的开始时间不是从0开始的
|
|
|
duration = CMTime(value: CMTimeValue((CMTimeGetSeconds(clipAudioRange.end)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt)
|
|
|
BFLog(message: "每一个文件的 duration \(CMTimeGetSeconds(duration))")
|
|
|
var timeRange = CMTimeRangeMake(start: .zero, duration: duration)
|
|
|
-
|
|
|
- if(index != 0){
|
|
|
- //(CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))为用户选择的第一段时长
|
|
|
+
|
|
|
+ if index != 0 {
|
|
|
+ // (CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))为用户选择的第一段时长
|
|
|
timeRange = clipAudioRange
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
BFLog(message: "合并的文件地址: \(originAsset.url)")
|
|
|
let audioAsset = originAsset
|
|
|
let tracks = audioAsset.tracks(withMediaType: .audio)
|
|
@@ -683,56 +674,47 @@ extension PQStuckPointPublicController {
|
|
|
break
|
|
|
}
|
|
|
let assetTrack: AVAssetTrack = tracks[0]
|
|
|
-
|
|
|
+
|
|
|
let compositionAudioTrack: AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: CMPersistentTrackID())!
|
|
|
-
|
|
|
+
|
|
|
do {
|
|
|
//
|
|
|
try compositionAudioTrack.insertTimeRange(timeRange, of: assetTrack, at: totalDuration)
|
|
|
|
|
|
} catch {
|
|
|
-
|
|
|
BFLog(message: "error is \(error)")
|
|
|
completeHander(URL(string: ""))
|
|
|
return
|
|
|
}
|
|
|
totalDuration = CMTimeAdd(totalDuration, timeRange.duration)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if(row > 0){
|
|
|
+
|
|
|
+ if row > 0 {
|
|
|
duration = CMTime(value: CMTimeValue(Float(CMTimeGetSeconds(totalDuration)) * Float(playerTimescaleInt)), timescale: playerTimescaleInt)
|
|
|
timeRange = CMTimeRange(start: clipAudioRange.start, duration: CMTime(value: Int64(Double(row) * Double(playerTimescaleInt)), timescale: playerTimescaleInt))
|
|
|
-
|
|
|
- BFLog(message: "合并的文件地址: \(originAsset.url)")
|
|
|
- let audioAsset = originAsset
|
|
|
- let tracks = audioAsset.tracks(withMediaType: .audio)
|
|
|
- if tracks.count == 0 {
|
|
|
- BFLog(message: "音频数据无效不进行合并,所有任务结束要确保输入的数据都正常! \(originAsset.url)")
|
|
|
|
|
|
- }
|
|
|
+ BFLog(message: "合并的文件地址: \(originAsset.url)")
|
|
|
+ let audioAsset = originAsset
|
|
|
+ let tracks = audioAsset.tracks(withMediaType: .audio)
|
|
|
+ if tracks.count == 0 {
|
|
|
+ BFLog(message: "音频数据无效不进行合并,所有任务结束要确保输入的数据都正常! \(originAsset.url)")
|
|
|
+ }
|
|
|
let assetTrack: AVAssetTrack = tracks[0]
|
|
|
-
|
|
|
+
|
|
|
let compositionAudioTrack: AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: CMPersistentTrackID())!
|
|
|
-
|
|
|
+
|
|
|
do {
|
|
|
//
|
|
|
try compositionAudioTrack.insertTimeRange(timeRange, of: assetTrack, at: totalDuration)
|
|
|
|
|
|
} catch {
|
|
|
-
|
|
|
BFLog(message: "error is \(error)")
|
|
|
completeHander(URL(string: ""))
|
|
|
return
|
|
|
}
|
|
|
totalDuration = CMTimeAdd(totalDuration, timeRange.duration)
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
|
|
|
let assetExport = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetAppleM4A)
|
|
|
BFLog(message: "assetExport.supportedFileTypes is \(String(describing: assetExport?.supportedFileTypes))")
|
|
@@ -753,7 +735,7 @@ extension PQStuckPointPublicController {
|
|
|
assetExport?.exportAsynchronously {
|
|
|
if assetExport!.status == .completed {
|
|
|
let audioAsset = AVURLAsset(url: fileUrl, options: avAssertOptions)
|
|
|
- BFLog(1,message: "拼接声音文件 完成 \(fileUrl) 时长is \(CMTimeGetSeconds(audioAsset.duration))")
|
|
|
+ BFLog(1, message: "拼接声音文件 完成 \(fileUrl) 时长is \(CMTimeGetSeconds(audioAsset.duration))")
|
|
|
completeHander(fileUrl)
|
|
|
|
|
|
} else {
|
|
@@ -764,20 +746,18 @@ extension PQStuckPointPublicController {
|
|
|
}
|
|
|
|
|
|
func appendAudio() {
|
|
|
-
|
|
|
let inputAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + (audioMixModel?.localPath ?? "")), options: nil)
|
|
|
- mergeAudios(originAsset: inputAsset, mTotalDuration: finallyUserAudioTime,clipAudioRange: clipAudioRange,mStartTime: CMTime(value: CMTimeValue((mStickers?.first?.timelineIn ?? 0.0) * Float64(playerTimescaleInt)), timescale: playerTimescaleInt)) { [weak self] completURL in
|
|
|
-
|
|
|
- if(completURL != nil){
|
|
|
+ mergeAudios(originAsset: inputAsset, mTotalDuration: finallyUserAudioTime, clipAudioRange: clipAudioRange, mStartTime: CMTime(value: CMTimeValue((mStickers?.first?.timelineIn ?? 0.0) * Float64(playerTimescaleInt)), timescale: playerTimescaleInt)) { [weak self] completURL in
|
|
|
+
|
|
|
+ if completURL != nil {
|
|
|
let asset = AVURLAsset(url: completURL!, options: nil)
|
|
|
FilterLog(message: "拼接后音频时长\(asset.duration.seconds) url is \(String(describing: completURL))")
|
|
|
self?.beginExport(inputAsset: asset)
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- func beginExport(inputAsset:AVURLAsset!) {
|
|
|
+
|
|
|
+ func beginExport(inputAsset: AVURLAsset!) {
|
|
|
if !(editProjectModel?.sData?.sections != nil && (editProjectModel?.sData?.sections.count ?? 0) > 0) {
|
|
|
BFLog(message: "项目段落错误❌")
|
|
|
return
|
|
@@ -791,19 +771,12 @@ extension PQStuckPointPublicController {
|
|
|
outPutMP4Path.append("video_\(String.qe.timestamp()).mp4")
|
|
|
let outPutMP4URL = URL(fileURLWithPath: outPutMP4Path)
|
|
|
BFLog(message: "导出视频地址 \(outPutMP4URL)")
|
|
|
-// let inputAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + (audioMixModel?.localPath ?? "")), options: nil)
|
|
|
-
|
|
|
- // 每次初始化的时候设置初始值 为 nIl
|
|
|
- var audioMix: AVMutableAudioMix?
|
|
|
- var composition: AVMutableComposition?
|
|
|
-// if(finallyUserAudioTime != 0 && finallyUserAudioTime > Float(inputAsset.duration.seconds)){
|
|
|
-// (audioMix, composition) = PQPlayerViewModel.setupAudioMix(originAsset: inputAsset, bgmData:nil, videoStickers: nil,originMusicDuration:finallyUserAudioTime,clipAudioRange: clipAudioRange,startTime:CMTime(value: CMTimeValue((mStickers?.first?.timelineIn ?? 0.0) * Float64(playerTimescaleInt)), timescale: playerTimescaleInt))
|
|
|
-// }
|
|
|
+
|
|
|
exporter = PQCompositionExporter(asset: inputAsset, videoComposition: nil, audioMix: audioMix, filters: nil, stickers: mStickers, animationTool: nil, exportURL: outPutMP4URL)
|
|
|
|
|
|
var orgeBitRate = (editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0) * (editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0) * 3
|
|
|
|
|
|
- if(mStickers != nil){
|
|
|
+ if mStickers != nil {
|
|
|
for stick in mStickers! {
|
|
|
if stick.type == StickerType.VIDEO.rawValue {
|
|
|
let asset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + stick.locationPath), options: avAssertOptions)
|
|
@@ -831,8 +804,8 @@ extension PQStuckPointPublicController {
|
|
|
}
|
|
|
}
|
|
|
exporter.completion = { [weak self] url in
|
|
|
- BFLog(message: "MovieOutput total frames appended:导了完成: \(url) 生成视频时长为:\(CMTimeGetSeconds(AVAsset.init(url: url).duration))")
|
|
|
-
|
|
|
+ BFLog(message: "MovieOutput total frames appended:导了完成: \(url) 生成视频时长为:\(CMTimeGetSeconds(AVAsset(url: url).duration))")
|
|
|
+
|
|
|
// 导出完成后取消导出
|
|
|
if self?.exporter != nil {
|
|
|
self?.exporter.cancel()
|
|
@@ -841,8 +814,8 @@ extension PQStuckPointPublicController {
|
|
|
if !(self?.isExportSuccess ?? false) {
|
|
|
self?.isExportSuccess = true
|
|
|
self?.exportEndDate = Date().timeIntervalSince1970
|
|
|
- BFLog(message: "视频导出完成-开始去发布视频 总时长为\( (self?.exportEndDate ?? 0) - (self?.startExportDate ?? 0) * 1000)")
|
|
|
-
|
|
|
+ BFLog(message: "视频导出完成-开始去发布视频 总时长为\((self?.exportEndDate ?? 0) - (self?.startExportDate ?? 0) * 1000)")
|
|
|
+
|
|
|
self?.exportLocalURL = url
|
|
|
/// fp2-1-1 - 请求权限
|
|
|
// self?.authorizationStatus()
|
|
@@ -935,13 +908,13 @@ extension PQStuckPointPublicController {
|
|
|
if isSaveDraftSuccess {
|
|
|
let sdata = editProjectModel?.sData?.toJSONString(prettyPrint: false) ?? ""
|
|
|
let draftboxId: String? = editProjectModel?.draftboxId
|
|
|
- PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint,rhythmMode: rhythmMode) { [weak self] projectId, msg in
|
|
|
+ PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint, rhythmMode: rhythmMode) { [weak self] projectId, msg in
|
|
|
BFLog(message: "生成的项目id1111 :\(projectId ?? ""),msg = \(msg ?? "")")
|
|
|
if projectId == nil || (projectId?.count ?? 0) <= 0 {
|
|
|
- PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint,rhythmMode: self?.rhythmMode ?? .createStickersModelPoint) { [weak self] projectId, msg in
|
|
|
+ PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint, rhythmMode: self?.rhythmMode ?? .createStickersModelPoint) { [weak self] projectId, msg in
|
|
|
BFLog(message: "生成的项目id222 :\(projectId ?? ""),msg = \(msg ?? "")")
|
|
|
if projectId == nil || (projectId?.count ?? 0) <= 0 {
|
|
|
- PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint,rhythmMode: self?.rhythmMode ?? .createStickersModelPoint) { [weak self] projectId, msg in
|
|
|
+ PQBaseViewModel.saveProject(draftboxId: draftboxId, sdata: sdata, videoFromScene: .stuckPoint, rhythmMode: self?.rhythmMode ?? .createStickersModelPoint) { [weak self] projectId, msg in
|
|
|
BFLog(message: "生成的项目id 3333:\(projectId ?? ""),msg = \(msg ?? "")")
|
|
|
if projectId != nil, (projectId?.count ?? 0) > 0 {
|
|
|
self?.editProjectModel?.projectId = projectId ?? ""
|
|
@@ -1246,11 +1219,11 @@ extension PQStuckPointPublicController {
|
|
|
eventTrackData.syncedUpOriginalMaterialDuration = selectedTotalDuration * 1000
|
|
|
eventTrackData.syncedUpRhythmNumber = audioMixModel?.speed ?? 2
|
|
|
eventTrackData.syncedUpVideoDuration = ((audioMixModel?.endTime ?? 0) - (audioMixModel?.startTime ?? 0)) * 1000
|
|
|
- //add by ak
|
|
|
+ // add by ak
|
|
|
eventTrackData.syncedUpVideoType = rhythmMode
|
|
|
eventTrackData.syncedUpVideoSpeedMax = syncedUpVideoSpeedMax
|
|
|
eventTrackData.syncedUpVideoSpeedMin = syncedUpVideoSpeedMin
|
|
|
-
|
|
|
+
|
|
|
return eventTrackData
|
|
|
}
|
|
|
|
|
@@ -1258,9 +1231,8 @@ extension PQStuckPointPublicController {
|
|
|
/// - Returns: description
|
|
|
@objc func playVideo() {
|
|
|
playBtn.isHidden = !playBtn.isHidden
|
|
|
-
|
|
|
+
|
|
|
changPlayerIsPause(isPause: !playBtn.isHidden)
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// 按钮点击事件
|
|
@@ -1304,15 +1276,13 @@ extension PQStuckPointPublicController {
|
|
|
PQBaseViewModel.h5ShareLinkInfo(videoId: videoData?.uniqueId ?? "", pageSource: videoData?.pageSource ?? .sp_category) { [weak self] path, _ in
|
|
|
cHiddenHUB(superView: nil)
|
|
|
if path != nil {
|
|
|
-
|
|
|
- PQBaseViewModel.wxFriendShareInfo(videoId: (self?.videoData?.uniqueId)!) { [weak self] imagePath, title, shareWeappRawId, msg in
|
|
|
+ PQBaseViewModel.wxFriendShareInfo(videoId: (self?.videoData?.uniqueId)!) { [weak self] imagePath, _, _, msg in
|
|
|
if msg != nil {
|
|
|
cShowHUB(superView: nil, msg: "网络不佳哦")
|
|
|
return
|
|
|
}
|
|
|
self?.isShared = true
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
PQSingletoWXApiUtil.shared.share(type: 1, scene: Int32(WXSceneTimeline.rawValue), title: self?.videoData?.title ?? "\(BFLoginUserInfo.shared.nickName)made a music video for you", description: "", imageUrl: imagePath, path: path, videoId: (self?.videoData?.uniqueId)!, pageSource: self?.videoData?.pageSource ?? .sp_category, shareId: shareId).wxApiUtilHander = { _, _ in
|
|
|
}
|
|
|
}
|
|
@@ -1323,14 +1293,13 @@ extension PQStuckPointPublicController {
|
|
|
// 点击上报:分享朋友圈
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_shareWechatMoment, pageSource: .sp_stuck_publishSyncedUp, extParams: ["videoId": videoData?.uniqueId ?? ""], remindmsg: "卡点视频数据上报-(点击上报:分享朋友圈)")
|
|
|
case 3:
|
|
|
-
|
|
|
+
|
|
|
// 点击上报:完成
|
|
|
PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_click_finished, pageSource: .sp_stuck_publishSyncedUp, extParams: ["videoId": videoData?.uniqueId ?? ""], remindmsg: "卡点视频数据上报-(点击上报:完成)")
|
|
|
navigationController?.viewControllers = [(navigationController?.viewControllers.first)!]
|
|
|
// 发送通知
|
|
|
postNotification(name: cFinishedPublishedNotiKey)
|
|
|
|
|
|
-
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
@@ -1366,10 +1335,9 @@ extension PQStuckPointPublicController {
|
|
|
if !isExportSuccess {
|
|
|
appendAudio()
|
|
|
}
|
|
|
-
|
|
|
- playBtn.isHidden = true
|
|
|
- avPlayer.play()
|
|
|
-
|
|
|
+
|
|
|
+ playBtn.isHidden = true
|
|
|
+ avPlayer.play()
|
|
|
}
|
|
|
|
|
|
@objc func didBecomeActiveNotification() {
|
|
@@ -1392,81 +1360,75 @@ extension PQStuckPointPublicController {
|
|
|
attributedText.addAttributes([.font: UIFont.systemFont(ofSize: 34)], range: NSRange(location: 0, length: "\(exportProgrss)%".count))
|
|
|
progressTipsLab.attributedText = attributedText
|
|
|
}
|
|
|
-
|
|
|
- func changPlayerIsPause(isPause:Bool) {
|
|
|
- if(isPause){
|
|
|
+
|
|
|
+ func changPlayerIsPause(isPause: Bool) {
|
|
|
+ if isPause {
|
|
|
playBtn.isHidden = false
|
|
|
avPlayer.pause()
|
|
|
playerHeaderCoverImageView.isHidden = false
|
|
|
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
playBtn.isHidden = true
|
|
|
avPlayer.play()
|
|
|
playerHeaderCoverImageView.isHidden = true
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- @objc func titleLabelClick() {
|
|
|
+
|
|
|
+ @objc func titleLabelClick() {
|
|
|
BFLog(message: "点击输入框")
|
|
|
changPlayerIsPause(isPause: true)
|
|
|
-
|
|
|
+
|
|
|
pinView.isHidden = true
|
|
|
publicTitleView.show()
|
|
|
-
|
|
|
- if(publicTitleView.inputTV.text.count > 0){
|
|
|
+
|
|
|
+ if publicTitleView.inputTV.text.count > 0 {
|
|
|
publicTitleView.inputTV.text = titleLabel.text
|
|
|
}
|
|
|
-
|
|
|
- PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_clickButton_changeTitle, pageSource: .sp_stuck_publishSyncedUp, eventData: ["videoId":videoData?.uniqueId ?? "","rootPageSource":isReCreate ? "shanyinApp-main-syncedUpMusicRecreate" :"shanyinApp-main-syncedUpMusic"], remindmsg: "")
|
|
|
+
|
|
|
+ PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_clickButton_changeTitle, pageSource: .sp_stuck_publishSyncedUp, eventData: ["videoId": videoData?.uniqueId ?? "", "rootPageSource": isReCreate ? "shanyinApp-main-syncedUpMusicRecreate" : "shanyinApp-main-syncedUpMusic"], remindmsg: "")
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@objc func settingCoverImage() {
|
|
|
-
|
|
|
- if(exportLocalURL == nil){
|
|
|
+ if exportLocalURL == nil {
|
|
|
BFLog(message: "导出的视频地址错误???。。。")
|
|
|
return
|
|
|
}
|
|
|
changPlayerIsPause(isPause: true)
|
|
|
-
|
|
|
+
|
|
|
let asset = AVURLAsset(url: exportLocalURL!, options: nil)
|
|
|
|
|
|
publicEditCoverView.show(videoURL: exportLocalURL!, duration: CMTimeGetSeconds(asset.duration))
|
|
|
-
|
|
|
- //点击了确认 btn
|
|
|
+
|
|
|
+ // 点击了确认 btn
|
|
|
publicEditCoverView.selectImageCallBack = { [weak self] imageData in
|
|
|
-
|
|
|
+
|
|
|
self?.changPlayerIsPause(isPause: false)
|
|
|
- if(imageData != nil){
|
|
|
-
|
|
|
+ if imageData != nil {
|
|
|
self?.coverImageView.image = imageData
|
|
|
self?.playerHeaderCoverImageView.image = imageData
|
|
|
- self?.uploadData?.image = imageData
|
|
|
+ self?.uploadData?.image = imageData
|
|
|
self?.updateCoverImagegOrTitle()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- //点击了从相册选择
|
|
|
+ // 点击了从相册选择
|
|
|
publicEditCoverView.selectPhotoBtnCallBack = { [weak self] in
|
|
|
let imageSelected = PQImageSelectedController()
|
|
|
- imageSelected.isAssetImage = true
|
|
|
+ imageSelected.isAssetImage = true
|
|
|
|
|
|
- imageSelected.videoWidth = CGFloat(self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)
|
|
|
- imageSelected.videoHeight = CGFloat(self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0)
|
|
|
+ imageSelected.videoWidth = CGFloat(self?.editProjectModel?.sData?.videoMetaData?.videoWidth ?? 0)
|
|
|
+ imageSelected.videoHeight = CGFloat(self?.editProjectModel?.sData?.videoMetaData?.videoHeight ?? 0)
|
|
|
// imageSelected.uploadData = uploadData
|
|
|
- // imageSelected.updataVideoData = updataVideoData
|
|
|
+ // imageSelected.updataVideoData = updataVideoData
|
|
|
self?.navigationController?.pushViewController(imageSelected, animated: true)
|
|
|
}
|
|
|
-
|
|
|
- PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_clickButton_changeCover, pageSource: .sp_stuck_publishSyncedUp, eventData: ["videoId":videoData?.uniqueId ?? "","rootPageSource":isReCreate ? "shanyinApp-main-syncedUpMusicRecreate" :"shanyinApp-main-syncedUpMusic"], remindmsg: "")
|
|
|
-
|
|
|
+
|
|
|
+ PQEventTrackViewModel.baseReportUpload(businessType: .bt_buttonClick, objectType: .ot_shanyinApp_clickButton_changeCover, pageSource: .sp_stuck_publishSyncedUp, eventData: ["videoId": videoData?.uniqueId ?? "", "rootPageSource": isReCreate ? "shanyinApp-main-syncedUpMusicRecreate" : "shanyinApp-main-syncedUpMusic"], remindmsg: "")
|
|
|
}
|
|
|
-
|
|
|
- //更新标题或封面
|
|
|
+
|
|
|
+ // 更新标题或封面
|
|
|
func updateCoverImagegOrTitle() {
|
|
|
-
|
|
|
PQLoadingHUB.shared.showHUB(isMode: true)
|
|
|
-
|
|
|
+
|
|
|
PQBaseViewModel.ossTempToken { [weak self] response, msg in
|
|
|
let image: UIImage = (self?.uploadData?.image)!
|
|
|
let data = image.jpegData(compressionQuality: 1)
|
|
@@ -1486,22 +1448,21 @@ extension PQStuckPointPublicController {
|
|
|
|
|
|
.uploadObjectAsync(bucketName: bucketName, objectKey: objectKey, data: data!, fileExtensions: "png", imageUploadBlock: { _, code, ossObjectKey, _ in
|
|
|
if code == 1 && ossObjectKey == objectKey && ossObjectKey.count > 0 {
|
|
|
- //add by ak 这里会在服务器生成分享使用的图片到1-2S 时间
|
|
|
+ // add by ak 这里会在服务器生成分享使用的图片到1-2S 时间
|
|
|
PQUploadViewModel.updateVideo(title: self?.videoData?.title ?? "", videoId: self?.videoData?.uniqueId ?? "", coverImgPath: objectKey, descr: "") { newVideoData, msg in
|
|
|
-
|
|
|
+
|
|
|
if newVideoData == nil {
|
|
|
cShowHUB(superView: self?.view, msg: msg)
|
|
|
- //可能有敏感词 要刷一组新标题并自动更新
|
|
|
- let numberRandom: UInt32 = UInt32(arc4random_uniform(UInt32( self?.publicTitleView.titles.count ?? 0)))
|
|
|
-
|
|
|
- self?.setTitleText(text: self?.publicTitleView.titles[Int(numberRandom)] ?? "")
|
|
|
+ // 可能有敏感词 要刷一组新标题并自动更新
|
|
|
+ let numberRandom: UInt32 = UInt32(arc4random_uniform(UInt32(self?.publicTitleView.titles.count ?? 0)))
|
|
|
+
|
|
|
+ self?.setTitleText(text: self?.publicTitleView.titles[Int(numberRandom)] ?? "")
|
|
|
self?.updateCoverImagegOrTitle()
|
|
|
sleep(UInt32(1.5))
|
|
|
PQLoadingHUB.shared.dismissHUB()
|
|
|
-
|
|
|
+
|
|
|
return
|
|
|
- }else{
|
|
|
-
|
|
|
+ } else {
|
|
|
PQLoadingHUB.shared.dismissHUB()
|
|
|
}
|
|
|
}
|
|
@@ -1509,47 +1470,44 @@ extension PQStuckPointPublicController {
|
|
|
PQLoadingHUB.shared.dismissHUB()
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
- }}
|
|
|
- func setTitleText(text:String ,textColor:UIColor = UIColor.hexColor(hexadecimal: "#ABABAB")) {
|
|
|
-
|
|
|
+
|
|
|
+ } }
|
|
|
+
|
|
|
+ func setTitleText(text: String, textColor: UIColor = UIColor.hexColor(hexadecimal: "#ABABAB")) {
|
|
|
selectTitle = text
|
|
|
- //更新 UI
|
|
|
+ // 更新 UI
|
|
|
titleLabel.text = text
|
|
|
titleLabel.textColor = textColor
|
|
|
publicTitleView.inputTV.placeHolder = text
|
|
|
- //更新数据
|
|
|
+ // 更新数据
|
|
|
videoData?.title = text
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
- //取推荐的10个标题
|
|
|
- func getTitles(){
|
|
|
- PQBaseViewModel.getBaseConfig(completeHander: {[weak self] titles in
|
|
|
-
|
|
|
- if((titles?.count ?? 0) > 0){
|
|
|
+
|
|
|
+ // 取推荐的10个标题
|
|
|
+ func getTitles() {
|
|
|
+ PQBaseViewModel.getBaseConfig(completeHander: { [weak self] titles in
|
|
|
+
|
|
|
+ if (titles?.count ?? 0) > 0 {
|
|
|
self?.publicTitleView.titles = titles!
|
|
|
-
|
|
|
+
|
|
|
let numberRandom: UInt32 = UInt32(arc4random_uniform(UInt32(titles!.count)))
|
|
|
BFLog(message: "接收到的 titles\(String(describing: titles))")
|
|
|
self?.setTitleText(text: titles?[Int(numberRandom)] ?? "")
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@objc func imageSelectedImage(notify: Notification) {
|
|
|
let imageData: UIImage? = notify.userInfo?["image"] as? UIImage
|
|
|
- if imageData != nil {
|
|
|
+ if imageData != nil {
|
|
|
changPlayerIsPause(isPause: false)
|
|
|
BFLog(message: "从系统相册选择了一个照片")
|
|
|
publicEditCoverView.isHidden = true
|
|
|
coverImageView.image = imageData
|
|
|
playerHeaderCoverImageView.image = imageData
|
|
|
- uploadData?.image = imageData
|
|
|
+ uploadData?.image = imageData
|
|
|
updateCoverImagegOrTitle()
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|