diff --git a/app/src/main/java/com/github/libretube/helpers/IntentHelper.kt b/app/src/main/java/com/github/libretube/helpers/IntentHelper.kt
index af7aa8181..d770f7696 100644
--- a/app/src/main/java/com/github/libretube/helpers/IntentHelper.kt
+++ b/app/src/main/java/com/github/libretube/helpers/IntentHelper.kt
@@ -4,7 +4,9 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.ResolveInfo
+import android.net.Uri
import android.os.Build
+import android.widget.Toast
import androidx.core.net.toUri
import androidx.core.os.bundleOf
import androidx.fragment.app.FragmentManager
@@ -48,4 +50,21 @@ object IntentHelper {
.show(fragmentManager)
}
}
+
+ fun openWithExternalPlayer(context: Context, uri: Uri, title: String?, uploader: String?) {
+ // start an intent with video as mimetype using the hls stream
+ val intent = Intent(Intent.ACTION_VIEW).apply {
+ setDataAndType(uri, "video/*")
+ putExtra(Intent.EXTRA_TITLE, title)
+ putExtra("title", title)
+ putExtra("artist", uploader)
+ addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ }
+
+ try {
+ context.startActivity(intent)
+ } catch (e: Exception) {
+ Toast.makeText(context, R.string.no_player_found, Toast.LENGTH_SHORT).show()
+ }
+ }
}
diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt
index 79e307f3d..b29a2593b 100644
--- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt
+++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt
@@ -78,6 +78,7 @@ import com.github.libretube.extensions.togglePlayPauseState
import com.github.libretube.extensions.updateParameters
import com.github.libretube.helpers.BackgroundHelper
import com.github.libretube.helpers.ImageHelper
+import com.github.libretube.helpers.IntentHelper
import com.github.libretube.helpers.NavBarHelper
import com.github.libretube.helpers.NavigationHelper
import com.github.libretube.helpers.PlayerHelper
@@ -602,26 +603,16 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
newShareDialog.show(childFragmentManager, ShareDialog::class.java.name)
}
- binding.relPlayerShare.setOnLongClickListener {
- if (!this::streams.isInitialized || streams.hls == null) {
- return@setOnLongClickListener true
- }
+ binding.relPlayerExternalPlayer.setOnClickListener {
+ if (!this::streams.isInitialized || streams.hls == null) return@setOnClickListener
- // start an intent with video as mimetype using the hls stream
- val intent = Intent(Intent.ACTION_VIEW).apply {
- setDataAndType(streams.hls.orEmpty().toUri(), "video/*")
- putExtra(Intent.EXTRA_TITLE, streams.title)
- putExtra("title", streams.title)
- putExtra("artist", streams.uploader)
- addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ val context = requireContext()
+ lifecycleScope.launch {
+ val hlsStream = withContext(Dispatchers.IO) {
+ ProxyHelper.unwrapStreamUrl(streams.hls!!).toUri()
+ }
+ IntentHelper.openWithExternalPlayer(context, hlsStream, streams.title, streams.uploader)
}
-
- try {
- startActivity(intent)
- } catch (e: Exception) {
- Toast.makeText(context, R.string.no_player_found, Toast.LENGTH_SHORT).show()
- }
- true
}
binding.relPlayerBackground.setOnClickListener {
@@ -632,6 +623,10 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions {
playOnBackground()
}
+ binding.relPlayerPip.setOnClickListener {
+ PictureInPictureCompat.enterPictureInPictureMode(requireActivity(), pipParams)
+ }
+
binding.relatedRecView.layoutManager = LinearLayoutManager(
context,
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
diff --git a/app/src/main/res/layout-land/fragment_player.xml b/app/src/main/res/layout-land/fragment_player.xml
index 3146a0d2c..1b01aebf9 100644
--- a/app/src/main/res/layout-land/fragment_player.xml
+++ b/app/src/main/res/layout-land/fragment_player.xml
@@ -66,6 +66,18 @@
style="@style/PlayerActionsButton"
android:text="@string/audio"
app:icon="@drawable/ic_headphones" />
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml
index da40bb5d0..2b64dbc20 100644
--- a/app/src/main/res/layout/fragment_player.xml
+++ b/app/src/main/res/layout/fragment_player.xml
@@ -66,6 +66,18 @@
style="@style/PlayerActionsButton"
android:text="@string/audio"
app:icon="@drawable/ic_headphones" />
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ebfed8276..98c673ed2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -470,6 +470,7 @@
Audio language
Default
Behavior when minimized
+ External player
Import subscriptions from