|
@@ -19,13 +19,11 @@ import com.bomostory.sceneeditmodule.view.MovieSelectView
|
|
import com.example.tfat.myapplication.R
|
|
import com.example.tfat.myapplication.R
|
|
import com.google.gson.Gson
|
|
import com.google.gson.Gson
|
|
import io.reactivex.Observable
|
|
import io.reactivex.Observable
|
|
-import io.reactivex.android.schedulers.AndroidSchedulers
|
|
|
|
import io.reactivex.schedulers.Schedulers
|
|
import io.reactivex.schedulers.Schedulers
|
|
import kotlinx.android.synthetic.main.activity_movie_edit.*
|
|
import kotlinx.android.synthetic.main.activity_movie_edit.*
|
|
import com.example.exportmedia.MediaHelper
|
|
import com.example.exportmedia.MediaHelper
|
|
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 java.io.File
|
|
import java.io.File
|
|
import java.util.AbstractMap
|
|
import java.util.AbstractMap
|
|
import kotlin.math.pow
|
|
import kotlin.math.pow
|
|
@@ -250,16 +248,20 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
|
|
}
|
|
}
|
|
|
|
|
|
private fun saveMovie(view: View) {
|
|
private fun saveMovie(view: View) {
|
|
- Completable.create {
|
|
|
|
- val movieBuilder = MovieMaker.Builder(mediaHelper)
|
|
|
|
- movieBuilder.fps = FPS
|
|
|
|
- movieBuilder.audioSources = generateAudioSource()
|
|
|
|
- generateMovieFilms(movieBuilder).subscribe()
|
|
|
|
- movieBuilder.build().output(File(Environment.getExternalStorageDirectory(), "test.mp4")).subscribe()
|
|
|
|
- }
|
|
|
|
|
|
+ val movieBuilder = MovieMaker.Builder(mediaHelper)
|
|
|
|
+ movieBuilder.fps = FPS
|
|
|
|
+ movieBuilder.audioSources = generateAudioSource()
|
|
|
|
+ generateMovieFilms()
|
|
.subscribeOn(Schedulers.io())
|
|
.subscribeOn(Schedulers.io())
|
|
- .observeOn(AndroidSchedulers.mainThread())
|
|
|
|
- .subscribe({}, {})
|
|
|
|
|
|
+ .subscribe({
|
|
|
|
+ movieBuilder.addImage(it.key, it.value).subscribe()
|
|
|
|
+ }, {
|
|
|
|
+
|
|
|
|
+ }, {
|
|
|
|
+ val movieMaker = movieBuilder.build()
|
|
|
|
+ movieMaker.output(File(Environment.getExternalStorageDirectory(), "test.mp4")).subscribe()
|
|
|
|
+ })
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private fun generateAudioSource(): ArrayList<AudioSource> {
|
|
private fun generateAudioSource(): ArrayList<AudioSource> {
|
|
@@ -274,7 +276,7 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
|
|
return audioSources
|
|
return audioSources
|
|
}
|
|
}
|
|
|
|
|
|
- private fun generateMovieFilms(movieBuilder: MovieMaker.Builder): Observable<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
|
|
|
|
+ private fun generateMovieFilms(): Observable<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
var preBitmap: Bitmap?
|
|
var preBitmap: Bitmap?
|
|
return Observable.create<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
return Observable.create<AbstractMap.SimpleEntry<Int, Bitmap>> {
|
|
scene?.apply {
|
|
scene?.apply {
|
|
@@ -294,7 +296,7 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
|
|
}
|
|
}
|
|
}
|
|
}
|
|
bitmap?.apply {
|
|
bitmap?.apply {
|
|
- movieBuilder.addImage(bitmapIndex++, this).subscribe()
|
|
|
|
|
|
+ it.onNext(AbstractMap.SimpleEntry(bitmapIndex++, this))
|
|
Log.d("Debug", "Index: $bitmapIndex Time: $t")
|
|
Log.d("Debug", "Index: $bitmapIndex Time: $t")
|
|
}
|
|
}
|
|
}
|
|
}
|