|
@@ -1,12 +1,15 @@
|
|
package com.bomostory.sceneeditmodule
|
|
package com.bomostory.sceneeditmodule
|
|
|
|
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
|
|
+import android.media.MediaMetadataRetriever
|
|
|
|
+import android.os.Environment
|
|
import android.util.Log
|
|
import android.util.Log
|
|
import com.bomostory.sceneeditmodule.screen.movie.MovieEditActivity.Companion.FPS
|
|
import com.bomostory.sceneeditmodule.screen.movie.MovieEditActivity.Companion.FPS
|
|
import com.bomostory.sceneeditmodule.basicdata.Music
|
|
import com.bomostory.sceneeditmodule.basicdata.Music
|
|
import com.bomostory.sceneeditmodule.basicdata.Project
|
|
import com.bomostory.sceneeditmodule.basicdata.Project
|
|
import com.bomostory.sceneeditmodule.basicdata.Scene
|
|
import com.bomostory.sceneeditmodule.basicdata.Scene
|
|
import com.example.exportmedia.MediaHelper
|
|
import com.example.exportmedia.MediaHelper
|
|
|
|
+import com.example.exportmedia.audio.AudioLooper
|
|
import com.example.exportmedia.data.AudioSource
|
|
import com.example.exportmedia.data.AudioSource
|
|
import com.example.exportmedia.vedio.MovieMaker
|
|
import com.example.exportmedia.vedio.MovieMaker
|
|
import io.reactivex.Completable
|
|
import io.reactivex.Completable
|
|
@@ -31,7 +34,7 @@ class SuperMovieMaker {
|
|
return Observable.create<String> { emitter ->
|
|
return Observable.create<String> { emitter ->
|
|
val movieBuilder = MovieMaker.Builder(mediaHelper)
|
|
val movieBuilder = MovieMaker.Builder(mediaHelper)
|
|
movieBuilder.fps = FPS
|
|
movieBuilder.fps = FPS
|
|
- movieBuilder.audioSources = generateAudioSource(musics)
|
|
|
|
|
|
+ movieBuilder.audioSources = generateAudioSource(musics,mediaHelper)
|
|
|
|
|
|
val inputSceneStatus = LinkedHashMap<Int, Int>()
|
|
val inputSceneStatus = LinkedHashMap<Int, Int>()
|
|
val frameDataList = generateFrameDataList(project)
|
|
val frameDataList = generateFrameDataList(project)
|
|
@@ -71,13 +74,26 @@ class SuperMovieMaker {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private fun generateAudioSource(musics: List<Music>): ArrayList<AudioSource> {
|
|
|
|
|
|
+ private fun generateAudioSource(musics: List<Music>,mediaHelper: MediaHelper): ArrayList<AudioSource> {
|
|
val audioSources = ArrayList<AudioSource>()
|
|
val audioSources = ArrayList<AudioSource>()
|
|
for (music in musics) {
|
|
for (music in musics) {
|
|
|
|
+ val fileName = "test${System.currentTimeMillis()}.mp3"
|
|
|
|
+ val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
|
|
|
|
+
|
|
|
|
+ val audioLooperBuilder = AudioLooper.Builder(mediaHelper)
|
|
|
|
+ audioLooperBuilder.loopAudioFile = File(music.path)
|
|
|
|
+ audioLooperBuilder.loopDuration = music.loopDuration.toInt()
|
|
|
|
+
|
|
|
|
+ val audioLooper = audioLooperBuilder.build()
|
|
|
|
+ audioLooper.output(outputFile).blockingFirst()
|
|
|
|
+
|
|
|
|
+ val mediaMetadataRetriever = MediaMetadataRetriever()
|
|
|
|
+ mediaMetadataRetriever.setDataSource(outputFile.path)
|
|
|
|
+
|
|
val audioSource = AudioSource()
|
|
val audioSource = AudioSource()
|
|
- audioSource.duration = music.duration
|
|
|
|
|
|
+ audioSource.path = outputFile.path
|
|
|
|
+ audioSource.duration = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION).toLong()
|
|
audioSource.offsetSec = music.offsetTime.toFloat() / 1000
|
|
audioSource.offsetSec = music.offsetTime.toFloat() / 1000
|
|
- audioSource.path = music.path
|
|
|
|
audioSources.add(audioSource)
|
|
audioSources.add(audioSource)
|
|
}
|
|
}
|
|
return audioSources
|
|
return audioSources
|