Add control to open the video from the audio player

This commit is contained in:
Bnyro 2023-01-21 11:53:52 +01:00
parent 7ffe3a6ed9
commit ee0607fb07
4 changed files with 27 additions and 7 deletions

View File

@ -12,6 +12,7 @@ import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.navigation.fragment.findNavController
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.obj.StreamItem import com.github.libretube.api.obj.StreamItem
import com.github.libretube.databinding.FragmentAudioPlayerBinding import com.github.libretube.databinding.FragmentAudioPlayerBinding
@ -24,6 +25,7 @@ import com.github.libretube.ui.base.BaseFragment
import com.github.libretube.ui.dialogs.ShareDialog import com.github.libretube.ui.dialogs.ShareDialog
import com.github.libretube.ui.sheets.PlaybackOptionsSheet import com.github.libretube.ui.sheets.PlaybackOptionsSheet
import com.github.libretube.ui.sheets.PlayingQueueSheet import com.github.libretube.ui.sheets.PlayingQueueSheet
import com.github.libretube.util.BackgroundHelper
import com.github.libretube.util.ImageHelper import com.github.libretube.util.ImageHelper
import com.github.libretube.util.NavigationHelper import com.github.libretube.util.NavigationHelper
import com.github.libretube.util.PlayingQueue import com.github.libretube.util.PlayingQueue
@ -101,6 +103,17 @@ class AudioPlayerFragment : BaseFragment() {
} }
} }
binding.openVideo.setOnClickListener {
NavigationHelper.navigateVideo(
context = requireContext(),
videoId = PlayingQueue.getCurrent()?.url?.toID(),
keepQueue = true,
forceVideo = true
)
BackgroundHelper.stopBackgroundPlay(requireContext())
findNavController().popBackStack()
}
binding.share.setOnClickListener { binding.share.setOnClickListener {
val currentVideo = PlayingQueue.getCurrent() ?: return@setOnClickListener val currentVideo = PlayingQueue.getCurrent() ?: return@setOnClickListener
ShareDialog( ShareDialog(

View File

@ -60,11 +60,12 @@ object NavigationHelper {
playlistId: String? = null, playlistId: String? = null,
channelId: String? = null, channelId: String? = null,
keepQueue: Boolean = false, keepQueue: Boolean = false,
timeStamp: Long? = null timeStamp: Long? = null,
forceVideo: Boolean = false
) { ) {
if (videoId == null) return if (videoId == null) return
if (PreferenceHelper.getBoolean(PreferenceKeys.AUDIO_ONLY_MODE, false)) { if (PreferenceHelper.getBoolean(PreferenceKeys.AUDIO_ONLY_MODE, false) && !forceVideo) {
BackgroundHelper.stopBackgroundPlay(context) BackgroundHelper.stopBackgroundPlay(context)
BackgroundHelper.playOnBackground( BackgroundHelper.playOnBackground(
context, context,

View File

@ -1,5 +1,10 @@
<vector android:height="24dp" android:tint="#000000" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportHeight="24" android:viewportWidth="24" android:width="24dp"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:height="24dp"
<path android:fillColor="@android:color/white" android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12zM16,11l-7,4L9,7z"/> android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M21,3L3,3c-1.11,0 -2,0.89 -2,2v12c0,1.1 0.89,2 2,2h5v2h8v-2h5c1.1,0 1.99,-0.9 1.99,-2L23,5c0,-1.11 -0.9,-2 -2,-2zM21,17L3,17L3,5h18v12zM16,11l-7,4L9,7z" />
</vector> </vector>

View File

@ -84,7 +84,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginVertical="36dp"> android:layout_marginTop="24dp"
android:layout_marginBottom="36dp">
<ImageView <ImageView
android:id="@+id/prev" android:id="@+id/prev"