|
@@ -31,6 +31,14 @@ class PublishEditNewVideoView: UIView {
|
|
|
var isPlaying : Bool = true
|
|
|
|
|
|
var selectedIndex : Int = 0
|
|
|
+
|
|
|
+ var streamId : Int32? = -1
|
|
|
+
|
|
|
+ var originalSoundVolumn : Float = 50.0
|
|
|
+
|
|
|
+ var soundtrackVolumn : Float = 50.0
|
|
|
+
|
|
|
+ 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)
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
|
|
|
}
|
|
|
|
|
@@ -209,73 +211,105 @@ class PublishEditNewVideoView: UIView {
|
|
|
self?.showFilterNameLabel(aliyunEffectFilter: aliyunEffectFilter)
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ 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)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ 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)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ 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()
|
|
|
-
|
|
|
+ musicVolumeView.publishEditNewMusicView.listContainerView.reloadData()
|
|
|
}else {
|
|
|
offsetY = kSafeStatusBarHeight
|
|
|
-
|
|
|
- editorPreview.addTap()
|
|
|
}
|
|
|
UIView.animate(withDuration: 0.5, animations: {
|
|
|
[weak self] in
|
|
@@ -427,66 +456,12 @@ extension PublishEditNewVideoView {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ func setAudio(streamId:Int32?) {
|
|
|
+ self.streamId = streamId
|
|
|
+ editor?.setAudioWeight(Int32(soundtrackVolumn), streamId: streamId ?? -1)
|
|
|
+ editor?.setMainStreamsAudioWeight(Int32(originalSoundVolumn))
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|