mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Merge pull request #7042 from Bnyro/master
feat: remember repeat mode across app restarts
This commit is contained in:
commit
0dc3b951a9
@ -90,6 +90,7 @@ object PreferenceKeys {
|
|||||||
const val SHOW_TIME_LEFT = "show_time_left"
|
const val SHOW_TIME_LEFT = "show_time_left"
|
||||||
const val ALLOW_PLAYBACK_DURING_CALL = "playback_during_call"
|
const val ALLOW_PLAYBACK_DURING_CALL = "playback_during_call"
|
||||||
const val BEHAVIOR_WHEN_MINIMIZED = "behavior_when_minimized"
|
const val BEHAVIOR_WHEN_MINIMIZED = "behavior_when_minimized"
|
||||||
|
const val REPEAT_MODE = "repeat_mode"
|
||||||
|
|
||||||
// SponsorBlock
|
// SponsorBlock
|
||||||
const val SB_USER_ID = "sb_user_id"
|
const val SB_USER_ID = "sb_user_id"
|
||||||
|
@ -375,6 +375,12 @@ object PlayerHelper {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var repeatMode: Int
|
||||||
|
get() = PreferenceHelper.getInt(PreferenceKeys.REPEAT_MODE, Player.REPEAT_MODE_OFF)
|
||||||
|
set(value) {
|
||||||
|
PreferenceHelper.putInt(PreferenceKeys.REPEAT_MODE, value)
|
||||||
|
}
|
||||||
|
|
||||||
fun isAutoPlayEnabled(isPlaylist: Boolean = false): Boolean {
|
fun isAutoPlayEnabled(isPlaylist: Boolean = false): Boolean {
|
||||||
return autoPlayEnabled || (isPlaylist && PreferenceHelper
|
return autoPlayEnabled || (isPlaylist && PreferenceHelper
|
||||||
.getBoolean(PreferenceKeys.AUTOPLAY_PLAYLISTS, false))
|
.getBoolean(PreferenceKeys.AUTOPLAY_PLAYLISTS, false))
|
||||||
|
@ -98,8 +98,6 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
|
|||||||
): ListenableFuture<SessionResult> {
|
): ListenableFuture<SessionResult> {
|
||||||
when (customCommand.customAction) {
|
when (customCommand.customAction) {
|
||||||
START_SERVICE_ACTION -> {
|
START_SERVICE_ACTION -> {
|
||||||
PlayingQueue.resetToDefaults()
|
|
||||||
|
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
onServiceCreated(args)
|
onServiceCreated(args)
|
||||||
notificationProvider?.intentActivity = getIntentActivity()
|
notificationProvider?.intentActivity = getIntentActivity()
|
||||||
@ -361,8 +359,6 @@ abstract class AbstractPlayerService : MediaLibraryService(), MediaLibrarySessio
|
|||||||
// java.lang.SecurityException: Session rejected the connection request.
|
// java.lang.SecurityException: Session rejected the connection request.
|
||||||
// because there can't be two active playerControllers at the same time.
|
// because there can't be two active playerControllers at the same time.
|
||||||
handler.postDelayed(50) {
|
handler.postDelayed(50) {
|
||||||
PlayingQueue.resetToDefaults()
|
|
||||||
|
|
||||||
saveWatchPosition()
|
saveWatchPosition()
|
||||||
|
|
||||||
notificationProvider = null
|
notificationProvider = null
|
||||||
|
@ -242,7 +242,6 @@ class PlaylistFragment : DynamicLayoutManagerFragment(R.layout.fragment_playlist
|
|||||||
binding.bookmark.text = getString(R.string.shuffle)
|
binding.bookmark.text = getString(R.string.shuffle)
|
||||||
binding.bookmark.setOnClickListener {
|
binding.bookmark.setOnClickListener {
|
||||||
val queue = playlistFeed.shuffled()
|
val queue = playlistFeed.shuffled()
|
||||||
PlayingQueue.resetToDefaults()
|
|
||||||
PlayingQueue.add(*queue.toTypedArray())
|
PlayingQueue.add(*queue.toTypedArray())
|
||||||
NavigationHelper.navigateVideo(
|
NavigationHelper.navigateVideo(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
|
@ -178,7 +178,6 @@ class WatchHistoryFragment : DynamicLayoutManagerFragment(R.layout.fragment_watc
|
|||||||
val watchHistory = history.filterByStatusAndWatchPosition()
|
val watchHistory = history.filterByStatusAndWatchPosition()
|
||||||
|
|
||||||
binding.playAll.setOnClickListener {
|
binding.playAll.setOnClickListener {
|
||||||
PlayingQueue.resetToDefaults()
|
|
||||||
PlayingQueue.add(
|
PlayingQueue.add(
|
||||||
*watchHistory.reversed().map(WatchHistoryItem::toStreamItem).toTypedArray()
|
*watchHistory.reversed().map(WatchHistoryItem::toStreamItem).toTypedArray()
|
||||||
)
|
)
|
||||||
|
@ -19,7 +19,12 @@ object PlayingQueue {
|
|||||||
|
|
||||||
private val queueJobs = mutableListOf<Job>()
|
private val queueJobs = mutableListOf<Job>()
|
||||||
|
|
||||||
var repeatMode: Int = Player.REPEAT_MODE_OFF
|
// wrapper around PlayerHelper#repeatMode for compatibility
|
||||||
|
var repeatMode: Int
|
||||||
|
get() = PlayerHelper.repeatMode
|
||||||
|
set(value) {
|
||||||
|
PlayerHelper.repeatMode = value
|
||||||
|
}
|
||||||
|
|
||||||
fun clear() {
|
fun clear() {
|
||||||
queueJobs.forEach {
|
queueJobs.forEach {
|
||||||
@ -216,8 +221,4 @@ object PlayingQueue {
|
|||||||
|
|
||||||
add(*streams.filter { !it.isLive }.toTypedArray(), skipExisting = true)
|
add(*streams.filter { !it.isLive }.toTypedArray(), skipExisting = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToDefaults() {
|
|
||||||
repeatMode = Player.REPEAT_MODE_OFF
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user