Quellcode durchsuchen

New: mvvm to movie edit activity

liweihao vor 6 Jahren
Ursprung
Commit
a04eeb014d

+ 3 - 0
build.gradle

@@ -35,6 +35,9 @@ dependencies {
     implementation 'com.android.support:support-v4:28.0.0-rc02'
     testImplementation 'junit:junit:4.12'
 
+    implementation "android.arch.lifecycle:extensions:1.1.0"
+    implementation "android.arch.lifecycle:viewmodel:1.1.0"
+
     androidTestImplementation 'com.android.support.test:rules:1.0.2'
     androidTestImplementation 'com.android.support.test:runner:1.0.2'
     androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

+ 1 - 28
src/main/java/com/bomostory/sceneeditmodule/basicdata/DataParser.kt

@@ -1,39 +1,12 @@
 package com.bomostory.sceneeditmodule.basicdata
 
 import android.content.ContentResolver
-import android.media.MediaMetadataRetriever
-import android.os.Environment
 import android.provider.MediaStore
-import org.json.JSONObject
 import java.io.File
 
 object DataParser {
 
-    fun parseMusicSource(contentResolver: ContentResolver,libraryPaths:List<String>):MusicSource{
-        val musicSource = MusicSource()
-        musicSource.library = parseMusic(libraryPaths)
-        musicSource.device = parseMusic(contentResolver,libraryPaths)
-        return musicSource
-    }
-
-    private fun parseMusic(paths: List<String>): ArrayList<Music> {
-        val mediaMetadataRetriever = MediaMetadataRetriever()
-        val musics = ArrayList<Music>()
-
-        for (path in paths) {
-            val file = File(path)
-            mediaMetadataRetriever.setDataSource(path)
-
-            val music = Music()
-            music.name = file.name
-            music.path = path
-            music.duration = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION).toLong()
-            musics.add(music)
-        }
-        return musics
-    }
-
-    private fun parseMusic(contentResolver: ContentResolver,paths: List<String>): ArrayList<Music>{
+     fun parseMusic(contentResolver: ContentResolver, paths: ArrayList<String?>): ArrayList<Music>{
         val selection = MediaStore.Audio.Media.IS_MUSIC + " != 0"
         val projection = arrayOf(
                 MediaStore.Audio.Media.TITLE,

+ 1 - 0
src/main/java/com/bomostory/sceneeditmodule/basicdata/Music.kt

@@ -9,4 +9,5 @@ class Music {
     var endTime:Long = 0
     var duration: Long = 0
     var volume: Float = 0.5f
+    var isLoop:Boolean= false
 }

+ 92 - 108
src/main/java/com/bomostory/sceneeditmodule/screen/movie/MovieEditActivity.kt

@@ -2,6 +2,8 @@ package com.bomostory.sceneeditmodule.screen.movie
 
 import android.app.AlertDialog
 import android.app.ProgressDialog
+import android.arch.lifecycle.Observer
+import android.arch.lifecycle.ViewModelProviders
 import android.content.DialogInterface
 import android.content.Intent
 import android.net.Uri
@@ -14,20 +16,20 @@ import android.view.View
 import android.widget.CompoundButton
 import android.widget.SeekBar
 import android.widget.Toast
-import com.bomostory.sceneeditmodule.*
+import com.bomostory.sceneeditmodule.Config
+import com.bomostory.sceneeditmodule.PdfMaker
+import com.bomostory.sceneeditmodule.SuperMovieMaker
 import com.bomostory.sceneeditmodule.basicdata.*
 import com.bomostory.sceneeditmodule.screen.movie.music.MusicEditDialog
 import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectDialog
 import com.bomostory.sceneeditmodule.screen.movie.music.MusicSelectFragment
-import com.bomostory.sceneeditmodule.share.ExportPdfDialog
 import com.bomostory.sceneeditmodule.share.ShareDialog
 import com.bomostory.sceneeditmodule.utils.MoviePlayer
 import com.bomostory.sceneeditmodule.utils.MusicPlayer
-import com.bomostory.sceneeditmodule.utils.TimeUtils
 import com.bomostory.sceneeditmodule.screen.view.AudioTrackGroupView
 import com.bomostory.sceneeditmodule.screen.view.MovieSelectView
+import com.bomostory.sceneeditmodule.share.ExportPdfDialog
 import com.example.exportmedia.MediaHelper
-import com.example.exportmedia.audio.AudioEditor
 import com.example.tfat.myapplication.R
 import com.google.gson.Gson
 import io.reactivex.Observable
@@ -43,10 +45,10 @@ class MovieEditActivity : AppCompatActivity(),
         MusicEditDialog.OnFragmentInteractionListener {
 
     override fun onMusicImportClick(music: Music) {
+        val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
         musics.add(music)
-        moviePlayer.init()
-        moviePlayer.addMusic(music)
-        movieEditView.musics = musics
+        viewModel.musicListLiveData.value = musics
+        viewModel.musicLiveData.value = music
 
         val dialogFragment = supportFragmentManager.findFragmentByTag(MUSIC_SELECT_DIALOG_TAG) as DialogFragment
         dialogFragment.dismiss()
@@ -67,8 +69,6 @@ class MovieEditActivity : AppCompatActivity(),
                 runOnUiThread {
                     musicEditDialog?.currentPosition = position
                 }
-
-
             }
         }
         musicPlayer.play(startPosition)
@@ -87,22 +87,23 @@ class MovieEditActivity : AppCompatActivity(),
     }
 
     override fun onMusicEditFinish(music: 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({
-        }, {
-        })
+        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({
+//        }, {
+//        })
 
     }
 
@@ -113,8 +114,8 @@ class MovieEditActivity : AppCompatActivity(),
         delayedHide(100)
     }
 
-    private val shareDialog = ShareDialog()
     private var musicEditDialog: MusicEditDialog? = null
+    private val shareDialog = ShareDialog()
 
     private val mHideHandler = Handler()
     private val mHidePart2Runnable = Runnable {
@@ -133,51 +134,10 @@ class MovieEditActivity : AppCompatActivity(),
         hide()
     }
 
-    private var project: Project? = null
-        set(value) {
-            field = value
-            value?.let {
-                story = it.story
-            }
-        }
-
-    private var story: Story? = null
-        set(value) {
-            field = value
-            moviePlayer.story = value
-            movieEditView.story = value
-            value?.let {
-                scene = it.scenes[0]
-            }
-        }
-
-    private var scene: Scene? = null
-        set(value) {
-            field = value
-            value?.let {
-                movieView.scene = value
-            }
-        }
-
-    private var isLoop = false
-        set(value) {
-            field = value
-            movieEditView.isLoop = value
-        }
-
-    private var currentAudioPosition = 0
-        set(value) {
-            field = value
-            movieEditView.currentAudioPosition = value
-        }
-
-
     private val moviePlayer = MoviePlayer()
 
     private val musicPlayer = MusicPlayer()
 
-    private val musics = ArrayList<Music>()
-
     private val mediaHelper = MediaHelper()
 
     companion object {
@@ -188,13 +148,42 @@ class MovieEditActivity : AppCompatActivity(),
         private const val UI_ANIMATION_DELAY = 300
     }
 
+    private lateinit var viewModel: MovieEditViewModel
+
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
         setContentView(R.layout.activity_movie_edit)
 
-        supportActionBar?.setDisplayHomeAsUpEnabled(true)
+        mediaHelper.init(this)
 
-        project = Gson().fromJson<Project>(intent.extras.getString(PROJECT_KEY), Project::class.java)
+        viewModel = ViewModelProviders.of(this).get(MovieEditViewModel::class.java)
+        viewModel.mediaHelper = mediaHelper
+        viewModel.project = Gson().fromJson<Project>(intent.extras.getString(PROJECT_KEY), Project::class.java)
+        viewModel.storyLiveData.observe(this, Observer {
+            movieEditView.story = it
+            moviePlayer.story = it
+        })
+        viewModel.storyPeriodLiveData.observe(this, Observer {
+            movieEditView.period = it ?: 0
+            moviePlayer.totalPeriod = it ?: 0
+        })
+        viewModel.sceneLiveData.observe(this, Observer {
+            movieView.scene = it
+        })
+        viewModel.musicListLiveData.observe(this, Observer {
+            movieEditView.musics = it as ArrayList<Music>
+            movieEditView.isAudioTrackGroupViewVisible = it.isNotEmpty()
+            moviePlayer.musics = it
+            moviePlayer.init()
+
+        })
+        viewModel.musicLiveData.observe(this, Observer {
+            viewModel.musicListLiveData.value?.apply {
+                movieEditView.currentAudioPosition = indexOf(it)
+            }
+        })
+
+        supportActionBar?.setDisplayHomeAsUpEnabled(true)
 
         movieEditView.onPlayClickListener = View.OnClickListener(this::playMovie)
         movieEditView.onPauseClickListener = View.OnClickListener(this::pauseMovie)
@@ -217,35 +206,43 @@ class MovieEditActivity : AppCompatActivity(),
         }
         movieEditView.onMovieSelectListener = object : MovieSelectView.OnMovieSelectListener {
             override fun onMoveSelect(scene: Scene) {
-                this@MovieEditActivity.scene = scene
+                viewModel.sceneLiveData.value = scene
             }
         }
         movieEditView.onAudioTrackSelectListener = object : AudioTrackGroupView.OnAudioTrackSelectListener {
             override fun onAudioTrackSelect(position: Int) {
-                currentAudioPosition = position
+                viewModel.musicListLiveData.value?.let {
+                    viewModel.musicLiveData.value = it[position]
+                }
             }
         }
         movieEditView.onAudioTrackScrollListener = object : AudioTrackGroupView.OnAudioTrackScrollListener {
             override fun onAudioTrackScroll(position: Int, scrollRatio: Double) {
-                scene?.record?.period?.let {
+                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
             }
         }
         movieEditView.onLoopSwitchChangedListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
-            isLoop = isChecked
+            val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
+            for (music in musics) {
+                music.isLoop = isChecked
+            }
+            viewModel.musicListLiveData.value = musics
         }
 
         moviePlayer.moviePlayListener = object : MoviePlayer.OnMoviePlayListener {
             override fun onMovieSceneUpdate(scene: Scene) {
-                if (scene != this@MovieEditActivity.scene) {
-                    this@MovieEditActivity.scene = scene
+                if (viewModel.sceneLiveData.value != scene) {
+                    viewModel.sceneLiveData.value = scene
                 }
             }
 
             override fun onMoviePlayComplete() {
-                story?.scenes?.let {
-                    this@MovieEditActivity.scene = it[0]
+                viewModel.project?.story?.let {
+                    viewModel.sceneLiveData.value = it.scenes[0]
                 }
                 movieEditView.isBtnPanelEnable = true
             }
@@ -259,9 +256,10 @@ class MovieEditActivity : AppCompatActivity(),
             }
         }
 
-        mediaHelper.init(this)
+
     }
 
+
     override fun onPostResume() {
         super.onPostResume()
         delayedHide(100)
@@ -289,39 +287,26 @@ class MovieEditActivity : AppCompatActivity(),
     }
 
     private fun addMusic(view: View) {
-        val libraryPaths = ArrayList<String>()
+        viewModel.parseDeviceMusic(contentResolver)
 
-        project?.let {
-            val assetFolder = it.assetFolder.path
-            it.themeAssetIndex.contains.music.values.forEach {
-                libraryPaths.add("$assetFolder/$it")
-            }
-        }
-
-        val musicSource = DataParser.parseMusicSource(contentResolver, libraryPaths)
-        val musicSelectDialog = MusicSelectDialog.newInstance(Gson().toJson(musicSource))
+        val musicSelectDialog = MusicSelectDialog.newInstance(Gson().toJson(viewModel.musicSource))
         musicSelectDialog.show(supportFragmentManager, MUSIC_SELECT_DIALOG_TAG)
     }
 
     private fun editMusic(view: View) {
-        musicEditDialog = MusicEditDialog.newInstance(Gson().toJson(musics[currentAudioPosition]))
+        musicEditDialog = MusicEditDialog.newInstance(Gson().toJson(viewModel.musicLiveData.value))
         musicEditDialog?.show(supportFragmentManager, MUSIC_EDIT_DIALOG_TAG)
     }
 
     private fun deleteMusic(view: View) {
-        if (currentAudioPosition in 0 until musics.size) {
-            moviePlayer.init()
-            moviePlayer.removeMusic(musics[currentAudioPosition])
-
-            musics.removeAt(currentAudioPosition)
-
-            movieEditView.musics = musics
-        }
+        val musics: ArrayList<Music> = viewModel.musicListLiveData.value as ArrayList<Music>
+        musics.remove(viewModel.musicLiveData.value)
+        viewModel.musicListLiveData.value = musics
     }
 
     private fun onClickSaveAndShareBtn(view: View) {
         shareDialog.apply {
-            project = this@MovieEditActivity.project ?: return@apply
+            project = viewModel.project ?: return@apply
             onClickBomo = Runnable { saveMovie() }
             onClickExportPdf = Runnable { onClickExportPdf() }
         }.show(supportFragmentManager)
@@ -329,28 +314,28 @@ class MovieEditActivity : AppCompatActivity(),
 
     private fun onClickExportPdf() {
         ExportPdfDialog().also { exportPdfDialog ->
-            exportPdfDialog.image1Path = project?.scene1File?.path ?: ""
-            exportPdfDialog.image2Path = project?.scene2File?.path ?: ""
+            exportPdfDialog.image1Path = viewModel.project?.scene1File?.path ?: ""
+            exportPdfDialog.image2Path = viewModel.project?.scene2File?.path ?: ""
             exportPdfDialog.onClickPrint = Runnable {
                 when (exportPdfDialog.type) {
                     ExportPdfDialog.Type.Standard -> {
-                        val name = "standard_${project?.name}_${System.currentTimeMillis()}.pdf"
+                        val name = "standard_${viewModel.project?.name}_${System.currentTimeMillis()}.pdf"
                         if (!Config.PDF_FOLDER.exists()) {
                             Config.PDF_FOLDER.mkdirs()
                         }
                         val file = File(Config.PDF_FOLDER, name)
                         file.createNewFile()
-                        val observable = PdfMaker.makeStandard(this@MovieEditActivity, project!!, file)
+                        val observable = PdfMaker.makeStandard(this@MovieEditActivity, viewModel.project!!, file)
                         Pair(file, observable)
                     }
                     ExportPdfDialog.Type.Booklet -> {
-                        val name = "booklet_${project?.name}_${System.currentTimeMillis()}.pdf"
+                        val name = "booklet_${viewModel.project?.name}_${System.currentTimeMillis()}.pdf"
                         if (!Config.PDF_FOLDER.exists()) {
                             Config.PDF_FOLDER.mkdirs()
                         }
                         val file = File(Config.PDF_FOLDER, name)
                         file.createNewFile()
-                        val observable = PdfMaker.makeBooklet(this@MovieEditActivity, project!!, file)
+                        val observable = PdfMaker.makeBooklet(this@MovieEditActivity, viewModel.project!!, file)
                         Pair(file, observable)
                     }
                 }.apply {
@@ -369,7 +354,7 @@ class MovieEditActivity : AppCompatActivity(),
         val scaleHeight = resources.getDimensionPixelSize(R.dimen.movie_height)
 
         val pd = ProgressDialog(this).apply {
-            val t = scene?.record?.period ?: 0
+            val t = viewModel.storyPeriodLiveData.value ?: 0
             max = (t / 33).toInt()
             setMessage("progressing")
             setCancelable(false)
@@ -377,12 +362,12 @@ class MovieEditActivity : AppCompatActivity(),
 
         val fileName = "test${System.currentTimeMillis()}.mp4"
         val outputFile = File(Environment.getExternalStorageDirectory(), fileName)
-        val project = project ?: return
+        val project = viewModel.project ?: return
 
         SuperMovieMaker().make(
                 outputFile,
                 project,
-                musics,
+                viewModel.musicListLiveData.value ?: ArrayList<Music>(),
                 scaledWidth,
                 scaleHeight,
                 mediaHelper)
@@ -464,5 +449,4 @@ class MovieEditActivity : AppCompatActivity(),
                     }
                 }.show()
     }
-
 }

+ 117 - 0
src/main/java/com/bomostory/sceneeditmodule/screen/movie/MovieEditViewModel.kt

@@ -0,0 +1,117 @@
+package com.bomostory.sceneeditmodule.screen.movie
+
+import android.arch.lifecycle.MutableLiveData
+import android.arch.lifecycle.ViewModel
+import android.content.ContentResolver
+import android.media.MediaMetadataRetriever
+import android.os.Environment
+import com.bomostory.sceneeditmodule.basicdata.*
+import com.bomostory.sceneeditmodule.utils.TimeUtils
+import com.example.exportmedia.MediaHelper
+import com.example.exportmedia.audio.AudioEditor
+import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.schedulers.Schedulers
+import java.io.File
+
+class MovieEditViewModel : ViewModel() {
+
+    val storyLiveData = MutableLiveData<Story>()
+
+    val storyPeriodLiveData = MutableLiveData<Long>()
+
+    val sceneLiveData = MutableLiveData<Scene>()
+
+    val musicLiveData = MutableLiveData<Music>()
+
+    val musicListLiveData = MutableLiveData<List<Music>>().apply {
+        value = ArrayList()
+    }
+
+    lateinit var mediaHelper: MediaHelper
+
+    var project: Project? = null
+        set(value) {
+            field = value
+            value?.let {
+                musicSource.library = parseThemeMusic(it)
+
+                it.story?.let {
+                    storyLiveData.value = it
+                    storyPeriodLiveData.value = parseStoryPeriod(it)
+                    sceneLiveData.value = it.scenes[0]
+                }
+            }
+        }
+
+    var musicSource = MusicSource()
+
+
+    fun parseDeviceMusic(contentResolver: ContentResolver) {
+        val libMusicPaths = ArrayList<String?>()
+        for (libMusic in musicSource.library) {
+            libMusicPaths.add(libMusic.path)
+        }
+
+        musicSource.device = DataParser.parseMusic(contentResolver, libMusicPaths)
+    }
+
+    fun exportEditAudio(music: Music) {
+        if (music.endTime - music.startTime > storyPeriodLiveData.value ?: 0) {
+            music.endTime = music.startTime + (storyPeriodLiveData.value ?: 0)
+        }
+
+        val audioEditorBuilder = AudioEditor.Builder(mediaHelper)
+        audioEditorBuilder.editAudioFile = File(music.path)
+        audioEditorBuilder.startTime = TimeUtils.getEncodeTimeFormt(music.startTime)
+        audioEditorBuilder.endTime = TimeUtils.getEncodeTimeFormt(music.endTime)
+        audioEditorBuilder.volume = music.volume
+
+        //TODO change path to correct path
+        val outputFile = File(Environment.getExternalStorageDirectory(), "test${System.currentTimeMillis()}.mp3")
+
+        val audioEditor = audioEditorBuilder.build()
+        audioEditor.output(outputFile)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe({
+                    music.path = outputFile.path
+
+                    val musics: ArrayList<Music> = musicListLiveData.value as ArrayList<Music>
+                    musics[musics.indexOf(musicLiveData.value)] = music
+                    musicListLiveData.value = musics
+                    musicLiveData.value = music
+                }, {
+
+                })
+    }
+
+    private fun parseThemeMusic(project: Project): ArrayList<Music> {
+        val musics = ArrayList<Music>()
+        val mediaMetadataRetriever = MediaMetadataRetriever()
+        val assetFolder = project.assetFolder
+
+        project.themeAssetIndex.contains.music.values.forEach {
+            val musicPath = "$assetFolder/$it"
+            val file = File(musicPath)
+
+            mediaMetadataRetriever.setDataSource(musicPath)
+
+            val music = Music()
+            music.name = file.name
+            music.path = file.path
+            music.duration = mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION).toLong()
+            musics.add(music)
+        }
+        return musics
+    }
+
+    private fun parseStoryPeriod(story: Story): Long {
+        var totalPeriod: Long = 0
+        for (scene in story.scenes) {
+            val period = scene.record?.period ?: 0
+            totalPeriod += period
+        }
+        return totalPeriod
+    }
+
+}

+ 2 - 2
src/main/java/com/bomostory/sceneeditmodule/screen/view/AudioTrackGroupView.kt

@@ -143,8 +143,8 @@ class AudioTrackGroupView : ConstraintLayout {
                     musics[p1].name?.let {
                         loopAudioTrackView.innerText = it
                     }
-                    
-                    loopAudioTrackView.isLoop = isLoop
+
+                    loopAudioTrackView.isLoop = musics[p1].isLoop
                     loopAudioTrackView.isSelect = (p1 == currentPosition)
                     loopAudioTrackView.onSelectListener = object : LoopAudioTrackView.OnSelectListener {
                         override fun onSelect() {

+ 5 - 14
src/main/java/com/bomostory/sceneeditmodule/screen/view/MovieEditView.kt

@@ -17,14 +17,6 @@ class MovieEditView : ConstraintLayout {
     var story: Story? = null
         set(value) {
             movieSelectView.story = value
-
-            value?.apply {
-                for (scene in scenes) {
-                    scene.record?.let {
-                        period += it.period
-                    }
-                }
-            }
         }
 
     var period: Long = 0
@@ -103,18 +95,17 @@ class MovieEditView : ConstraintLayout {
         set(value) {
             movieEditBtnPanel.isMusicEmpty = value.isEmpty()
             audioTrackGroupView.musics = value
-            if (value.isNotEmpty()) {
+        }
+
+    var isAudioTrackGroupViewVisible = false
+        set(value) {
+            if (value) {
                 audioTrackGroupView.visibility = View.VISIBLE
             } else {
                 audioTrackGroupView.visibility = View.GONE
             }
         }
 
-    var isLoop = false
-        set(value) {
-            audioTrackGroupView.isLoop = value
-        }
-
     var isBtnPanelEnable = true
         set(value) {
             movieEditBtnPanel.isEnable = value

+ 0 - 1
src/main/java/com/bomostory/sceneeditmodule/screen/view/MovieSelectView.kt

@@ -33,7 +33,6 @@ class MovieSelectView : ConstraintLayout {
             movieList?.apply {
                 adapter = MovieAdapter()
             }
-
         }
 
     constructor(context: Context) : super(context) {

+ 5 - 10
src/main/java/com/bomostory/sceneeditmodule/utils/MoviePlayer.kt

@@ -24,21 +24,16 @@ class MoviePlayer {
     }
 
     var story: Story? = null
-        set(value) {
-            field = value
-            value?.apply {
-                for (scene in scenes) {
-                    scene.record?.period?.let {
-                        totalPeriod += it
-                    }
-                }
-            }
-        }
 
     var totalPeriod = 0L
 
     var musicPlayer = MusicPlayer()
 
+    var musics = ArrayList<Music>()
+    set(value) {
+        musicPlayer.musics = value
+    }
+
     var moviePlayListener: OnMoviePlayListener? = null
     private val lastTick = AtomicLong(0L)
     private var disposable: Disposable? = null

+ 1 - 1
src/main/java/com/bomostory/sceneeditmodule/utils/MusicPlayer.kt

@@ -10,7 +10,7 @@ class MusicPlayer {
         fun onPlayChanged(music: Music, position: Int)
     }
 
-    private var musics = ArrayList<Music>()
+     var musics = ArrayList<Music>()
     private var mediaPlayers = ArrayList<MediaPlayer>()
 
     private var isPause = false

+ 1 - 1
src/main/res/layout/movie_edit_btn_panel_view.xml

@@ -45,7 +45,7 @@
     <!--TODO : Remove enabled and drawableTint after implement this function-->
     <Button
         android:drawableTint="@color/brown_grey"
-        android:enabled="false"
+        android:enabled="true"
         android:id="@+id/edit"
         android:layout_width="96dp"
         android:layout_height="36dp"