audio only mode in player

This commit is contained in:
Bnyro 2022-07-10 18:04:58 +02:00
parent c8347637ae
commit 3207681760
4 changed files with 45 additions and 5 deletions

View File

@ -54,6 +54,7 @@ import com.github.libretube.obj.Streams
import com.github.libretube.obj.Subscribe
import com.github.libretube.preferences.PreferenceHelper
import com.github.libretube.services.IS_DOWNLOAD_RUNNING
import com.github.libretube.util.BackgroundMode
import com.github.libretube.util.CronetHelper
import com.github.libretube.util.DescriptionAdapter
import com.github.libretube.util.RetrofitInstance
@ -825,6 +826,20 @@ class PlayerFragment : Fragment() {
val shareDialog = ShareDialog(videoId!!, false)
shareDialog.show(childFragmentManager, "ShareDialog")
}
binding.relPlayerBackground.setOnClickListener {
// pause the current player
exoPlayer.pause()
// start the background mode
BackgroundMode
.getInstance()
.playOnBackgroundMode(
requireContext(),
videoId!!
)
}
// check if livestream
if (response.duration!! > 0) {
// download clicked
@ -893,7 +908,7 @@ class PlayerFragment : Fragment() {
if (token != "") {
val channelId = response.uploaderUrl?.replace("/channel/", "")
isSubscribed(binding.playerSubscribe, channelId!!)
binding.save.setOnClickListener {
binding.relPlayerSave.setOnClickListener {
val newFragment = AddtoPlaylistDialog()
val bundle = Bundle()
bundle.putString("videoId", videoId)

View File

@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#FF000000"
android:pathData="M16.4,42H9q-1.2,0 -2.1,-0.9Q6,40.2 6,39V24q0,-3.75 1.425,-7.025 1.425,-3.275 3.85,-5.7 2.425,-2.425 5.7,-3.85Q20.25,6 24,6q3.75,0 7.025,1.425 3.275,1.425 5.7,3.85 2.425,2.425 3.85,5.7Q42,20.25 42,24v15q0,1.2 -0.9,2.1 -0.9,0.9 -2.1,0.9h-7.4V27.2H39V24q0,-6.25 -4.375,-10.625T24,9q-6.25,0 -10.625,4.375T9,24v3.2h7.4Z" />
</vector>

View File

@ -2,9 +2,9 @@
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorControlNormal"
android:viewportWidth="320"
android:viewportHeight="320">
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:fillColor="#FF000000"
android:pathData="M311.34,8.67c-5.61,-5.61 -13.24,-8.73 -21.18,-8.66L194.28,0.85c-7.76,0.07 -15.17,3.18 -20.66,8.66L8.66,174.47c-11.55,11.55 -11.55,30.28 0,41.83l95.03,95.03c11.55,11.56 30.28,11.56 41.83,0l164.96,-164.96c5.48,-5.49 8.59,-12.9 8.66,-20.66l0.85,-95.88C320.07,21.91 316.95,14.27 311.34,8.67zM254.04,113.77c-13.2,13.21 -34.61,13.2 -47.81,0c-13.2,-13.2 -13.2,-34.6 0,-47.81c13.2,-13.2 34.61,-13.2 47.81,0C267.24,79.16 267.24,100.57 254.04,113.77z" />
android:pathData="m42,24 l-8.45,11.95q-0.65,0.9 -1.55,1.475 -0.9,0.575 -2,0.575H9q-1.25,0 -2.125,-0.875T6,35V13q0,-1.25 0.875,-2.125T9,10h21q1.1,0 2,0.575 0.9,0.575 1.55,1.475Z" />
</vector>

View File

@ -202,7 +202,22 @@
</LinearLayout>
<LinearLayout
android:id="@+id/save"
android:id="@+id/relPlayer_background"
style="@style/PlayerActionsLayout">
<ImageView
android:layout_width="24dp"
android:layout_height="25dp"
android:src="@drawable/ic_headphones" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio" />
</LinearLayout>
<LinearLayout
android:id="@+id/relPlayer_save"
style="@style/PlayerActionsLayout">
<ImageView