mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 16:00:31 +05:30
feat: start playing video when using add to queue action if queue empty
This commit is contained in:
parent
a6c82662c1
commit
6edc161cd4
@ -3,6 +3,7 @@ package com.github.libretube.ui.activities
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
|
import com.github.libretube.constants.IntentData
|
||||||
import com.github.libretube.ui.base.BaseActivity
|
import com.github.libretube.ui.base.BaseActivity
|
||||||
import com.github.libretube.util.PlayingQueue
|
import com.github.libretube.util.PlayingQueue
|
||||||
|
|
||||||
@ -29,10 +30,15 @@ class AddToQueueActivity : BaseActivity() {
|
|||||||
|
|
||||||
if (videoId == null) videoId = uri.path!!.replace("/", "")
|
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)
|
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)
|
startActivity(intent)
|
||||||
finishAndRemoveTask()
|
finishAndRemoveTask()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user