Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ object NavigationHelper {
@SuppressLint("UnsafeOptInUsageError")
fun navigateVideo(
context: Context,
videoUrlOrId: String?,
videoId: String?,
playlistId: String? = null,
channelId: String? = null,
keepQueue: Boolean = false,
Expand All @@ -58,15 +58,15 @@ object NavigationHelper {
forceVideo: Boolean = false,
audioOnlyPlayerRequested: Boolean = false,
) {
if (videoUrlOrId == null) return
if (videoId == null) return

// attempt to attach to the current media session first by using the corresponding
// video/audio player instance
val activity = ContextHelper.unwrapActivity<MainActivity>(context)
val attachedToRunningPlayer = activity.runOnPlayerFragment {
try {
PlayingQueue.clear()
this.playNextVideo(videoUrlOrId.toID())
this.playNextVideo(videoId.toID())

if (audioOnlyPlayerRequested) {
// switch to audio only player
Expand All @@ -86,11 +86,11 @@ object NavigationHelper {

val attachedToRunningAudioPlayer = activity.runOnAudioPlayerFragment {
PlayingQueue.clear()
this.playNextVideo(videoUrlOrId.toID())
this.playNextVideo(videoId.toID())

if (!audioOnlyPlayerRequested) {
// switch to video only player
this.switchToVideoMode(videoUrlOrId.toID())
this.switchToVideoMode(videoId.toID())
} else {
// maximize player
this.binding.playerMotionLayout.transitionToStart()
Expand All @@ -106,7 +106,7 @@ object NavigationHelper {
// its own!
BackgroundHelper.playOnBackground(
context,
videoUrlOrId.toID(),
videoId.toID(),
timestamp,
playlistId,
channelId,
Expand All @@ -117,7 +117,7 @@ object NavigationHelper {
} else {
openVideoPlayerFragment(
context,
videoUrlOrId.toID(),
videoId.toID(),
playlistId,
channelId,
keepQueue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class MainActivity : BaseActivity() {
override fun onGlobalLayout() {
NavigationHelper.navigateVideo(
context = this@MainActivity,
videoUrlOrId = it,
videoId = it,
timestamp = intent.getLongExtra(IntentData.timeStamp, 0L)
)

Expand All @@ -533,7 +533,7 @@ class MainActivity : BaseActivity() {
} else {
NavigationHelper.navigateVideo(
context = this@MainActivity,
videoUrlOrId = it,
videoId = it,
timestamp = intent.getLongExtra(IntentData.timeStamp, 0L)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.core.view.updatePadding
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R
import com.github.libretube.api.PlaylistsHelper
import com.github.libretube.api.obj.Playlists
import com.github.libretube.api.obj.StreamItem
import com.github.libretube.constants.IntentData
import com.github.libretube.databinding.VideoRowBinding
Expand Down Expand Up @@ -106,9 +105,13 @@ class PlaylistAdapter(
) { _, _ ->
notifyItemChanged(position)
}
val sheet = VideoOptionsBottomSheet()
sheet.arguments = bundleOf(IntentData.streamItem to streamItem)
sheet.show(fragmentManager, VideoOptionsBottomSheet::class.java.name)
VideoOptionsBottomSheet().apply {
arguments = bundleOf(
IntentData.streamItem to streamItem,
IntentData.playlistId to playlistId
)
}
.show(fragmentManager, VideoOptionsBottomSheet::class.java.name)
true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class SubscriptionsFragment : DynamicLayoutManagerFragment(R.layout.fragment_sub

NavigationHelper.navigateVideo(
requireContext(),
videoUrlOrId = streams.first().url,
videoId = streams.first().url,
keepQueue = true
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DownloadOptionsBottomSheet : BaseBottomSheet() {
}

R.string.go_to_video -> {
NavigationHelper.navigateVideo(requireContext(), videoUrlOrId = videoId)
NavigationHelper.navigateVideo(requireContext(), videoId = videoId)
}

R.string.share -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class VideoOptionsBottomSheet : BaseBottomSheet() {

override fun onCreate(savedInstanceState: Bundle?) {
streamItem = arguments?.parcelable(IntentData.streamItem)!!
val playlistId = arguments?.getString(IntentData.playlistId)

val videoId = streamItem.url?.toID() ?: return

Expand All @@ -57,7 +58,12 @@ class VideoOptionsBottomSheet : BaseBottomSheet() {
when (optionsList[which]) {
// Start the background mode
R.string.playOnBackground -> {
NavigationHelper.navigateVideo(requireContext(), videoId, audioOnlyPlayerRequested = true)
NavigationHelper.navigateVideo(
requireContext(),
videoId = videoId,
playlistId = playlistId,
audioOnlyPlayerRequested = true
)
}
// Add Video to Playlist Dialog
R.string.addToPlaylist -> {
Expand Down
Loading