|
@@ -31,6 +31,14 @@ class PublishEditNewVideoView: UIView {
|
|
|
var isPlaying : Bool = true
|
|
|
/// 滤镜选中的selected
|
|
|
var selectedIndex : Int = 0
|
|
|
+ /// 音乐的streamId存放
|
|
|
+ var streamId : Int32? = -1
|
|
|
+ /// 原音音量
|
|
|
+ var originalSoundVolumn : Float = 50.0
|
|
|
+ /// 配乐音量
|
|
|
+ var soundtrackVolumn : Float = 50.0
|
|
|
+ /// 音选中的sIndex
|
|
|
+ var segmentIndex : Int = 0
|
|
|
|
|
|
override init(frame: CGRect) {
|
|
|
super.init(frame: frame)
|
|
@@ -77,6 +85,13 @@ class PublishEditNewVideoView: UIView {
|
|
|
/// 设置数据
|
|
|
func setupData() {
|
|
|
publishEditNewVideoSetView.playProgressView.slider.maximumValue = Float(player?.getDuration() ?? 0.0)
|
|
|
+ if PublishNewMusicView.publishNewMusicUseURL != nil {
|
|
|
+ let effectMusic = AliyunEffectMusic(file: PublishNewMusicView.publishNewMusicUseURL?.path)
|
|
|
+ editor?.apply(effectMusic)
|
|
|
+ setAudio(streamId:effectMusic?.effectVid())
|
|
|
+ }else {
|
|
|
+ setAudio(streamId:-1)
|
|
|
+ }
|
|
|
// 播放器视频
|
|
|
player?.play()
|
|
|
// 返回
|
|
@@ -87,8 +102,10 @@ class PublishEditNewVideoView: UIView {
|
|
|
// 音乐
|
|
|
publishEditNewVideoSetView.musicButton.rx.tap.subscribe(onNext: {[weak self] (data) in
|
|
|
guard let strongSelf = self else { return }
|
|
|
- if strongSelf.player?.isPlaying() ?? true {
|
|
|
- strongSelf.player?.pause()
|
|
|
+ if strongSelf.segmentIndex == 0 {
|
|
|
+ if strongSelf.player?.isPlaying() ?? true {
|
|
|
+ strongSelf.player?.pause()
|
|
|
+ }
|
|
|
}
|
|
|
strongSelf.musicVolumeViewisHidden(isHidden: false)
|
|
|
}).disposed(by: disposeBag)
|
|
@@ -169,21 +186,6 @@ class PublishEditNewVideoView: UIView {
|
|
|
|
|
|
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)
|
|
|
-// }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -209,73 +211,105 @@ 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)
|
|
|
+ // 关闭音乐按钮
|
|
|
+ musicVolumeView.publishEditNewMusicView.closeButton.rx.tap.subscribe(onNext: { [weak self] (data) in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
|
|
|
+ strongSelf.musicVolumeViewisHidden(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)
|
|
|
+ // 不使用音乐按钮
|
|
|
+ musicVolumeView.publishEditNewMusicView.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.musicVolumeViewisHidden(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()
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
+ // 使用音乐
|
|
|
+ musicVolumeView.publishEditNewMusicView.userMusicClosure = {
|
|
|
+ [weak self] in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ if PublishNewMusicView.publishNewMusicUseURL?.path == nil {
|
|
|
+ PublishNewMusicView.publishNewMusicUseIndexPath = nil
|
|
|
+ strongSelf.musicVolumeViewisHidden(isHidden: true)
|
|
|
+ SwiftProgressHUD.shared().showText("使用音乐错误,请您重新选择!!!")
|
|
|
+ }else {
|
|
|
+ strongSelf.editor?.removeMusics()
|
|
|
+ PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
|
|
|
+ let effectMusic = AliyunEffectMusic(file: PublishNewMusicView.publishNewMusicUseURL?.path)
|
|
|
+ strongSelf.editor?.apply(effectMusic)
|
|
|
+ strongSelf.streamId = effectMusic?.effectVid()
|
|
|
+ strongSelf.musicVolumeViewisHidden(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()
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
+ // 选中音乐/音量
|
|
|
+ musicVolumeView.didSelectedItem = {
|
|
|
+ [weak self] index in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ AliPlayerManager.shared.audioPlayer?.stop()
|
|
|
+ strongSelf.segmentIndex = index
|
|
|
+ //音乐
|
|
|
+ if index == 0 {
|
|
|
+ // 暂停播放
|
|
|
+ strongSelf.player?.pause()
|
|
|
+ }
|
|
|
+ //音量
|
|
|
+ if index == 1 {
|
|
|
+ PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
|
|
|
+ strongSelf.musicVolumeView.publishEditNewMusicView.listContainerView.reloadData()
|
|
|
+ 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()
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // 音量点击空白处隐藏
|
|
|
+ musicVolumeView.tapClosure = {
|
|
|
+ [weak self] in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
|
|
|
+ strongSelf.musicVolumeViewisHidden(isHidden: true)
|
|
|
+ if strongSelf.isPlaying {
|
|
|
+ strongSelf.resumePlay()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 原音音量
|
|
|
+ musicVolumeView.publishEditNewVolumeView.originalSoundClosure = {
|
|
|
+ [weak self] originalSoundVolumn in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ strongSelf.originalSoundVolumn = originalSoundVolumn
|
|
|
+ strongSelf.setAudio(streamId: self?.streamId)
|
|
|
+
|
|
|
+ }
|
|
|
+ // 配乐音量
|
|
|
+ musicVolumeView.publishEditNewVolumeView.soundtrackSoundClosure = {
|
|
|
+ [weak self] soundtrackVolumn in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ strongSelf.soundtrackVolumn = soundtrackVolumn
|
|
|
+ strongSelf.setAudio(streamId: self?.streamId)
|
|
|
+
|
|
|
+ }
|
|
|
+ // 应用音量
|
|
|
+ musicVolumeView.publishEditNewVolumeView.sureButton.rx.tap.subscribe(onNext: { [weak self] (_) in
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ PublishNewMusicView.publishNewMusicSelectedIndexPath = nil
|
|
|
+ strongSelf.musicVolumeViewisHidden(isHidden: true)
|
|
|
+ if strongSelf.isPlaying {
|
|
|
+ strongSelf.resumePlay()
|
|
|
+ }
|
|
|
+ }).disposed(by: disposeBag)
|
|
|
|
|
|
}
|
|
|
|
|
@@ -284,9 +318,6 @@ class PublishEditNewVideoView: UIView {
|
|
|
let editor = AliyunEditor(path: taskPath, preview: editorPreview)
|
|
|
editor?.delegate = self
|
|
|
editor?.startEdit()
|
|
|
- if PublishNewMusicView.publishNewMusicUseURL != nil {
|
|
|
- editor?.apply(AliyunEffectMusic(file: PublishNewMusicView.publishNewMusicUseURL?.path))
|
|
|
- }
|
|
|
return editor
|
|
|
}()
|
|
|
|
|
@@ -323,6 +354,8 @@ class PublishEditNewVideoView: UIView {
|
|
|
/// 音乐/音量
|
|
|
lazy var musicVolumeView : PublishEditNewMusicVolumeView = {
|
|
|
let musicVolumeView = PublishEditNewMusicVolumeView(frame: CGRect(x: 0, y: kScreenHeight, width: kScreenWidth, height: kScreenHeight - kSafeStatusBarHeight))
|
|
|
+ musicVolumeView.publishEditNewVolumeView.originSlider.value = 0.5
|
|
|
+ musicVolumeView.publishEditNewVolumeView.soundtrackSlider.value = 0.5
|
|
|
return musicVolumeView
|
|
|
}()
|
|
|
|
|
@@ -405,13 +438,9 @@ extension PublishEditNewVideoView {
|
|
|
var offsetY : CGFloat = kScreenHeight
|
|
|
if isHidden {
|
|
|
offsetY = kScreenHeight
|
|
|
- // 移除点击手势
|
|
|
- editorPreview.removetap()
|
|
|
-// musicView.listContainerView.reloadData()
|
|
|
+ musicVolumeView.publishEditNewMusicView.listContainerView.reloadData()
|
|
|
}else {
|
|
|
offsetY = kSafeStatusBarHeight
|
|
|
- // 添加点击手势
|
|
|
- editorPreview.addTap()
|
|
|
}
|
|
|
UIView.animate(withDuration: 0.5, animations: {
|
|
|
[weak self] in
|
|
@@ -427,66 +456,12 @@ extension PublishEditNewVideoView {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-// /// 音乐是否显示
|
|
|
-// ///
|
|
|
-// /// - 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
|
|
|
-// }
|
|
|
-// })
|
|
|
-// }
|
|
|
+ /// 设置音效
|
|
|
+ func setAudio(streamId:Int32?) {
|
|
|
+ self.streamId = streamId
|
|
|
+ editor?.setAudioWeight(Int32(soundtrackVolumn), streamId: streamId ?? -1)
|
|
|
+ editor?.setMainStreamsAudioWeight(Int32(originalSoundVolumn))
|
|
|
+ }
|
|
|
|
|
|
/// 滑块需要显示的时间
|
|
|
/// - Parameter playSec: 时间
|