|
@@ -24,11 +24,11 @@ import com.bomostory.sceneeditmodule.screen.movie.music.MusicEditDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectDialog
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectFragment
|
|
import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectFragment
|
|
import com.bomostory.sceneeditmodule.share.ShareDialog
|
|
import com.bomostory.sceneeditmodule.share.ShareDialog
|
|
-import com.bomostory.sceneeditmodule.utils.MoviePlayer
|
|
|
|
-import com.bomostory.sceneeditmodule.utils.MusicPlayer
|
|
|
|
import com.bomostory.sceneeditmodule.screen.view.AudioTrackGroupView
|
|
import com.bomostory.sceneeditmodule.screen.view.AudioTrackGroupView
|
|
import com.bomostory.sceneeditmodule.screen.view.MovieSelectView
|
|
import com.bomostory.sceneeditmodule.screen.view.MovieSelectView
|
|
import com.bomostory.sceneeditmodule.share.ExportPdfDialog
|
|
import com.bomostory.sceneeditmodule.share.ExportPdfDialog
|
|
|
|
+import com.bomostory.sceneeditmodule.utils.MoviePlayerV2
|
|
|
|
+import com.bomostory.sceneeditmodule.utils.MusicPlayerV2
|
|
import com.example.exportmedia.MediaHelper
|
|
import com.example.exportmedia.MediaHelper
|
|
import com.example.tfat.myapplication.R
|
|
import com.example.tfat.myapplication.R
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
@@ -55,23 +55,28 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicPreCastClick(music: Music) {
|
|
override fun onMusicPreCastClick(music: Music) {
|
|
- musicPlayer.stop()
|
|
|
|
- musicPlayer.clear()
|
|
|
|
- musicPlayer.add(music)
|
|
|
|
- musicPlayer.play()
|
|
|
|
|
|
+ musicPlayer.apply {
|
|
|
|
+ this.music = music
|
|
|
|
+ stop()
|
|
|
|
+ init()
|
|
|
|
+ start()
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicPlayClick(music: Music, startPosition: Int) {
|
|
override fun onMusicPlayClick(music: Music, startPosition: Int) {
|
|
- musicPlayer.clear()
|
|
|
|
- musicPlayer.add(music)
|
|
|
|
- musicPlayer.playChangedListener = object : MusicPlayer.OnPlayChangedListener {
|
|
|
|
- override fun onPlayChanged(music: Music, position: Int) {
|
|
|
|
- runOnUiThread {
|
|
|
|
- musicEditDialog?.currentPosition = position
|
|
|
|
|
|
+ musicPlayer.apply {
|
|
|
|
+ this.music = music
|
|
|
|
+ playChangedListener = object : MusicPlayerV2.OnPlayChangedListener {
|
|
|
|
+ override fun OnPlayChanged(position: Int) {
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ musicEditDialog?.currentPosition = position
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ init()
|
|
|
|
+ seekTo(startPosition)
|
|
|
|
+ start()
|
|
}
|
|
}
|
|
- musicPlayer.play(startPosition)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicVolumeChanged(volume: Float) {
|
|
override fun onMusicVolumeChanged(volume: Float) {
|
|
@@ -87,30 +92,37 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMusicEditFinish(music: Music) {
|
|
override fun onMusicEditFinish(music: Music) {
|
|
- viewModel.exportEditAudio(music)
|
|
|
|
-// if (music.endTime - music.startTime > moviePlayer.totalPeriod) {
|
|
|
|
-// music.endTime = music.startTime + moviePlayer.totalPeriod
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-// val builder = AudioEditor.Builder(mediaHelper)
|
|
|
|
-// builder.editAudioFile = File(music.path)
|
|
|
|
-// builder.startTime = TimeUtils.getEncodeTimeFormt(music.startTime)
|
|
|
|
-// builder.endTime = TimeUtils.getEncodeTimeFormt(music.endTime)
|
|
|
|
-// builder.volume = music.volume
|
|
|
|
-//
|
|
|
|
-// val fileName = "test${System.currentTimeMillis()}.mp3"
|
|
|
|
-// val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
|
|
|
|
-// val audioEditor = builder.build()
|
|
|
|
-// audioEditor.output(outputFile).subscribe({
|
|
|
|
-// }, {
|
|
|
|
-// })
|
|
|
|
|
|
+ //TODO change path to correct path
|
|
|
|
+ val outputFile = File(Environment.getExternalStorageDirectory(), "test${System.currentTimeMillis()}.mp3")
|
|
|
|
+
|
|
|
|
+ val pd = ProgressDialog(this).apply {
|
|
|
|
+ setMessage("progressing")
|
|
|
|
+ setCancelable(false)
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ viewModel.exportEditAudio(music, outputFile)
|
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
+ .doOnSubscribe {
|
|
|
|
+ pd.show()
|
|
|
|
+ }
|
|
|
|
+ .doFinally {
|
|
|
|
+ pd.dismiss()
|
|
|
|
+ }
|
|
|
|
+ .subscribe({
|
|
|
|
+ music.path = outputFile.path
|
|
|
|
+
|
|
|
|
+ val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
|
|
|
|
+ musics[musics.indexOf(viewModel.musicLiveData.value)] = music
|
|
|
|
+ viewModel.musicListLiveData.value = musics
|
|
|
|
+ viewModel.musicLiveData.value = music
|
|
|
|
+ }, {
|
|
|
|
+
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
override fun onDismiss(dialog: DialogInterface?) {
|
|
override fun onDismiss(dialog: DialogInterface?) {
|
|
musicPlayer.stop()
|
|
musicPlayer.stop()
|
|
- musicPlayer.release()
|
|
|
|
-
|
|
|
|
delayedHide(100)
|
|
delayedHide(100)
|
|
}
|
|
}
|
|
|
|
|
|
@@ -134,9 +146,9 @@ class MovieEditActivity : AppCompatActivity(),
|
|
hide()
|
|
hide()
|
|
}
|
|
}
|
|
|
|
|
|
- private val moviePlayer = MoviePlayer()
|
|
|
|
|
|
+ private val moviePlayer = MoviePlayerV2()
|
|
|
|
|
|
- private val musicPlayer = MusicPlayer()
|
|
|
|
|
|
+ private val musicPlayer = MusicPlayerV2()
|
|
|
|
|
|
private val mediaHelper = MediaHelper()
|
|
private val mediaHelper = MediaHelper()
|
|
|
|
|
|
@@ -165,7 +177,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
})
|
|
})
|
|
viewModel.storyPeriodLiveData.observe(this, Observer {
|
|
viewModel.storyPeriodLiveData.observe(this, Observer {
|
|
movieEditView.period = it ?: 0
|
|
movieEditView.period = it ?: 0
|
|
- moviePlayer.totalPeriod = it ?: 0
|
|
|
|
|
|
+ moviePlayer.period = it ?: 0
|
|
})
|
|
})
|
|
viewModel.sceneLiveData.observe(this, Observer {
|
|
viewModel.sceneLiveData.observe(this, Observer {
|
|
movieView.scene = it
|
|
movieView.scene = it
|
|
@@ -173,7 +185,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
viewModel.musicListLiveData.observe(this, Observer {
|
|
viewModel.musicListLiveData.observe(this, Observer {
|
|
movieEditView.musics = it as ArrayList<Music>
|
|
movieEditView.musics = it as ArrayList<Music>
|
|
movieEditView.isAudioTrackGroupViewVisible = it.isNotEmpty()
|
|
movieEditView.isAudioTrackGroupViewVisible = it.isNotEmpty()
|
|
- moviePlayer.musics = it
|
|
|
|
|
|
+ moviePlayer.musicList = it
|
|
moviePlayer.init()
|
|
moviePlayer.init()
|
|
|
|
|
|
})
|
|
})
|
|
@@ -194,7 +206,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
movieEditView.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
|
movieEditView.onSeekBarChangeListener = object : SeekBar.OnSeekBarChangeListener {
|
|
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
override fun onProgressChanged(seekBar: SeekBar?, progress: Int, fromUser: Boolean) {
|
|
if (fromUser) {
|
|
if (fromUser) {
|
|
- moviePlayer.seekTo(progress)
|
|
|
|
|
|
+ moviePlayer.seekTo(progress.toLong())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -218,11 +230,14 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
movieEditView.onAudioTrackScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
|
|
movieEditView.onAudioTrackScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
|
|
override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
|
|
override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
|
|
- val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
|
|
|
|
- viewModel.sceneLiveData.value?.record?.period?.let {
|
|
|
|
- musics[position].offsetTime = (it * scrollRatio).toLong()
|
|
|
|
- }
|
|
|
|
- viewModel.musicListLiveData.value = musics
|
|
|
|
|
|
+ viewModel.musicListLiveData.value?.get(position)?.offsetTime = ((viewModel.storyPeriodLiveData.value
|
|
|
|
+ ?: 0) * scrollRatio).toLong()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ movieEditView.onAudioTrackLoopScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
|
|
|
|
+ override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
|
|
|
|
+ viewModel.musicListLiveData.value?.get(position)?.loopDuration = ((viewModel.storyPeriodLiveData.value
|
|
|
|
+ ?: 0) * scrollRatio).toLong()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
movieEditView.onLoopSwitchChangedListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
|
|
movieEditView.onLoopSwitchChangedListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
|
|
@@ -233,26 +248,34 @@ class MovieEditActivity : AppCompatActivity(),
|
|
viewModel.musicListLiveData.value = musics
|
|
viewModel.musicListLiveData.value = musics
|
|
}
|
|
}
|
|
|
|
|
|
- moviePlayer.moviePlayListener = object : MoviePlayer.OnMoviePlayListener {
|
|
|
|
|
|
+ moviePlayer.moviePlayListener = object : MoviePlayerV2.OnMoviePlayListener {
|
|
override fun onMovieSceneUpdate(scene: Scene) {
|
|
override fun onMovieSceneUpdate(scene: Scene) {
|
|
- if (viewModel.sceneLiveData.value != scene) {
|
|
|
|
- viewModel.sceneLiveData.value = scene
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ if (viewModel.sceneLiveData.value != scene) {
|
|
|
|
+ viewModel.sceneLiveData.value = scene
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMoviePlayComplete() {
|
|
override fun onMoviePlayComplete() {
|
|
- viewModel.project?.story?.let {
|
|
|
|
- viewModel.sceneLiveData.value = it.scenes[0]
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ viewModel.project?.story?.let {
|
|
|
|
+ viewModel.sceneLiveData.value = it.scenes[0]
|
|
|
|
+ }
|
|
|
|
+ movieEditView.isBtnPanelEnable = true
|
|
}
|
|
}
|
|
- movieEditView.isBtnPanelEnable = true
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMoviePlayViewUpdate(x: Int) {
|
|
override fun onMoviePlayViewUpdate(x: Int) {
|
|
- movieView.x = x
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ movieView.x = x
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override fun onMoviePlayTimeUpdate(time: Long) {
|
|
override fun onMoviePlayTimeUpdate(time: Long) {
|
|
- movieEditView.playTime = time
|
|
|
|
|
|
+ runOnUiThread {
|
|
|
|
+ movieEditView.playTime = time
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -277,7 +300,7 @@ class MovieEditActivity : AppCompatActivity(),
|
|
}
|
|
}
|
|
|
|
|
|
private fun playMovie(view: View) {
|
|
private fun playMovie(view: View) {
|
|
- moviePlayer.play()
|
|
|
|
|
|
+ moviePlayer.start()
|
|
movieEditView.isBtnPanelEnable = false
|
|
movieEditView.isBtnPanelEnable = false
|
|
}
|
|
}
|
|
|
|
|