[Android] Fix video player dialogs

Nicolas Pomepuy git at videolan.org
Wed Jan 20 09:54:28 UTC 2021


vlc-android | branch: 3.3.x | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Jan 12 14:10:35 2021 +0100| [4a6596e538ada43e099ad7465ca107f9135f3b26] | committer: Nicolas Pomepuy

Fix video player dialogs

Fixes the chromecasting issues when the media needs to be transcoded

(cherry picked from commit 61c548846b3289f5b4e60b883fa270b621cf068e)

> https://code.videolan.org/videolan/vlc-android/commit/4a6596e538ada43e099ad7465ca107f9135f3b26
---

 .../videolan/vlc/gui/video/VideoPlayerActivity.kt   | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 8cfb73bad..3d60586eb 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -51,7 +51,6 @@ import android.widget.SeekBar
 import android.widget.SeekBar.OnSeekBarChangeListener
 import android.widget.TextView
 import android.widget.Toast
-import androidx.annotation.WorkerThread
 import androidx.appcompat.app.AlertDialog
 import androidx.appcompat.app.AppCompatActivity
 import androidx.appcompat.widget.PopupMenu
@@ -74,6 +73,7 @@ import kotlinx.android.synthetic.main.player_overlay_volume.*
 import kotlinx.coroutines.*
 import kotlinx.coroutines.flow.launchIn
 import kotlinx.coroutines.flow.onEach
+import org.videolan.libvlc.Dialog
 import org.videolan.libvlc.MediaPlayer
 import org.videolan.libvlc.interfaces.IMedia
 import org.videolan.libvlc.util.AndroidUtil
@@ -88,6 +88,7 @@ import org.videolan.tools.*
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.PlaybackService
 import org.videolan.vlc.R
+import org.videolan.vlc.gui.DialogActivity
 import org.videolan.vlc.gui.audio.EqualizerFragment
 import org.videolan.vlc.gui.audio.PlaylistAdapter
 import org.videolan.vlc.gui.browser.EXTRA_MRL
@@ -98,9 +99,8 @@ import org.videolan.vlc.gui.helpers.hf.StoragePermissionsDelegate
 import org.videolan.vlc.interfaces.IPlaybackSettingsController
 import org.videolan.vlc.repository.ExternalSubRepository
 import org.videolan.vlc.repository.SlaveRepository
+import org.videolan.vlc.util.*
 import org.videolan.vlc.util.FileUtils
-import org.videolan.vlc.util.Permissions
-import org.videolan.vlc.util.Util
 import org.videolan.vlc.viewmodels.PlaylistModel
 import java.lang.Runnable
 import kotlin.math.roundToInt
@@ -108,7 +108,7 @@ import kotlin.math.roundToInt
 @Suppress("DEPRECATION")
 @ObsoleteCoroutinesApi
 @ExperimentalCoroutinesApi
-open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, PlaylistAdapter.IPlayer, OnClickListener, OnLongClickListener, StoragePermissionsDelegate.CustomActionController, TextWatcher {
+open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback, PlaylistAdapter.IPlayer, OnClickListener, OnLongClickListener, StoragePermissionsDelegate.CustomActionController, TextWatcher, IDialogManager {
 
     private var subtitlesExtraPath: String? = null
     private lateinit var startedScope : CoroutineScope
@@ -171,6 +171,9 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
     val overlayDelegate: VideoPlayerOverlayDelegate by lazy(LazyThreadSafetyMode.NONE) { VideoPlayerOverlayDelegate(this at VideoPlayerActivity) }
     var isTv: Boolean = false
 
+    private val dialogsDelegate = DialogDelegate()
+
+
     /**
      * Flag to indicate whether the media should be paused once loaded
      * (e.g. lock screen, or to restore the pause state)
@@ -367,6 +370,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
 
+        dialogsDelegate.observeDialogs(this, this)
         Util.checkCpuCompatibility(this)
 
         settings = Settings.getInstance(this)
@@ -468,6 +472,15 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
         overlayDelegate.pauseToPlay = AnimatedVectorDrawableCompat.create(this, R.drawable.anim_pause_play_video)!!
     }
 
+    override fun fireDialog(dialog: Dialog) {
+        DialogActivity.dialog = dialog
+        startActivity(Intent(DialogActivity.KEY_DIALOG, null, this, DialogActivity::class.java))
+    }
+
+    override fun dialogCanceled(dialog: Dialog?) {
+        (dialog?.context as? DialogFragment)?.dismiss()
+    }
+
     override fun afterTextChanged(s: Editable?) {
     }
 



More information about the Android mailing list