Browse Source

Show dialog that can launch player after encode

Wayne 6 years ago
parent
commit
4c329cd7ad
1 changed files with 18 additions and 1 deletions
  1. 18 1
      src/main/java/com/bomostory/sceneeditmodule/MovieEditActivity.kt

+ 18 - 1
src/main/java/com/bomostory/sceneeditmodule/MovieEditActivity.kt

@@ -3,6 +3,8 @@ package com.bomostory.sceneeditmodule
 import android.app.AlertDialog
 import android.app.ProgressDialog
 import android.content.DialogInterface
+import android.content.Intent
+import android.net.Uri
 import android.os.Bundle
 import android.os.Environment
 import android.os.Handler
@@ -11,6 +13,7 @@ import android.support.v7.app.AppCompatActivity
 import android.view.View
 import android.widget.CompoundButton
 import android.widget.SeekBar
+import android.widget.Toast
 import com.bomostory.sceneeditmodule.basicdata.*
 import com.bomostory.sceneeditmodule.utils.MoviePlayer
 import com.bomostory.sceneeditmodule.utils.MusicPlayer
@@ -277,7 +280,21 @@ class MovieEditActivity : AppCompatActivity(), DialogInterface.OnDismissListener
                 """.trimIndent()
                     AlertDialog.Builder(this).setMessage(msg).show()
                 }, {
-                    AlertDialog.Builder(this).setMessage("complete").show()
+                    AlertDialog.Builder(this)
+                            .setMessage("Complete")
+                            .setPositiveButton("Play") { _, _ ->
+                                val uri = Uri.parse(outputFile.absolutePath)
+                                val intent = Intent(Intent.ACTION_VIEW, uri).apply {
+                                    setDataAndType(uri, "video/mp4")
+                                }
+                                if (intent.resolveActivity(packageManager) != null) {
+                                    Intent.createChooser(intent, "").apply {
+                                        startActivity(this)
+                                    }
+                                } else {
+                                    Toast.makeText(this, "No app can play video", Toast.LENGTH_SHORT).show()
+                                }
+                            }.show()
                 })
     }