Merge pull request #5400 from Bnyro/master

feat: start playing video when using add to queue action if queue empty
This commit is contained in:
Bnyro 2023-12-28 18:32:15 +01:00 committed by GitHub
commit 0534050f97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,7 @@ package com.github.libretube.ui.activities
import android.content.Intent
import android.os.Bundle
import androidx.core.net.toUri
import com.github.libretube.constants.IntentData
import com.github.libretube.ui.base.BaseActivity
import com.github.libretube.util.PlayingQueue
@ -29,10 +30,15 @@ class AddToQueueActivity : BaseActivity() {
if (videoId == null) videoId = uri.path!!.replace("/", "")
// if playing a video currently, the playing queue is not empty
if (PlayingQueue.isNotEmpty()) PlayingQueue.insertByVideoId(videoId!!)
val intent = packageManager.getLaunchIntentForPackage(packageName)
// if playing a video currently, the video will be added to the queue
if (PlayingQueue.isNotEmpty()) {
PlayingQueue.insertByVideoId(videoId!!)
} else {
intent?.putExtra(IntentData.videoId, videoId)
}
startActivity(intent)
finishAndRemoveTask()
}