behavior: add option to pause when a song repeats
Add a new option to pause playback whenever a song loops [e.g while in LoopMode.TRACK]. This does mean that we can no longer use exoplayer's native looping system, but it doesn't seem to be that much of an issue. Resolves #29.
This commit is contained in:
parent
33332dbf6b
commit
2e278aef8a
5 changed files with 29 additions and 11 deletions
|
@ -160,7 +160,7 @@ class PlaybackNotification private constructor(
|
|||
iconRes, actionName,
|
||||
PendingIntent.getBroadcast(
|
||||
context, REQUEST_CODE,
|
||||
Intent(actionName), PendingIntent.FLAG_UPDATE_CURRENT
|
||||
Intent(actionName), PendingIntent.FLAG_UPDATE_CURRENT,
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -188,7 +188,17 @@ class PlaybackService : Service(), Player.Listener, PlaybackStateManager.Callbac
|
|||
releaseWakelock()
|
||||
}
|
||||
|
||||
Player.STATE_ENDED -> playbackManager.next()
|
||||
Player.STATE_ENDED -> {
|
||||
if (playbackManager.loopMode == LoopMode.TRACK) {
|
||||
playbackManager.rewind()
|
||||
|
||||
if (settingsManager.pauseOnLoop) {
|
||||
playbackManager.setPlaying(false)
|
||||
}
|
||||
} else {
|
||||
playbackManager.next()
|
||||
}
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
|
@ -249,12 +259,6 @@ class PlaybackService : Service(), Player.Listener, PlaybackStateManager.Callbac
|
|||
}
|
||||
|
||||
override fun onLoopUpdate(loopMode: LoopMode) {
|
||||
player.repeatMode = if (loopMode == LoopMode.TRACK) {
|
||||
Player.REPEAT_MODE_ONE
|
||||
} else {
|
||||
Player.REPEAT_MODE_OFF
|
||||
}
|
||||
|
||||
if (!settingsManager.useAltNotifAction) {
|
||||
notification.setLoop(this, loopMode)
|
||||
|
||||
|
|
|
@ -97,6 +97,10 @@ class SettingsManager private constructor(context: Context) :
|
|||
val rewindWithPrev: Boolean
|
||||
get() = sharedPrefs.getBoolean(KEY_PREV_REWIND, true)
|
||||
|
||||
/** Whether [LoopMode.TRACK] should pause when the track repeats */
|
||||
val pauseOnLoop: Boolean
|
||||
get() = sharedPrefs.getBoolean(KEY_LOOP_PAUSE, false)
|
||||
|
||||
/** The current [SortMode] of the library. */
|
||||
var librarySortMode: SortMode
|
||||
get() = sharedPrefs.getData(KEY_LIB_SORT_MODE, SortMode::fromInt) ?: SortMode.ALPHA_DOWN
|
||||
|
@ -214,6 +218,7 @@ class SettingsManager private constructor(context: Context) :
|
|||
const val KEY_SONG_PLAYBACK_MODE = "KEY_SONG_PLAY_MODE2"
|
||||
const val KEY_KEEP_SHUFFLE = "KEY_KEEP_SHUFFLE"
|
||||
const val KEY_PREV_REWIND = "KEY_PREV_REWIND"
|
||||
const val KEY_LOOP_PAUSE = "KEY_LOOP_PAUSE"
|
||||
|
||||
const val KEY_SAVE_STATE = "KEY_SAVE_STATE"
|
||||
const val KEY_BLACKLIST = "KEY_BLACKLIST"
|
||||
|
|
|
@ -62,8 +62,8 @@
|
|||
<string name="setting_theme_day">Light</string>
|
||||
<string name="setting_theme_night">Dark</string>
|
||||
<string name="setting_accent">Accent</string>
|
||||
<string name="setting_black_mode">Black night theme</string>
|
||||
<string name="setting_black_mode_desc">Use a pure-black night theme</string>
|
||||
<string name="setting_black_mode">Black theme</string>
|
||||
<string name="setting_black_mode_desc">Use a pure-black dark theme</string>
|
||||
|
||||
<string name="setting_display">Display</string>
|
||||
<string name="setting_lib_display">Library Items</string>
|
||||
|
@ -89,6 +89,8 @@
|
|||
<string name="setting_behavior_keep_shuffle_desc">Keep shuffle on when playing a new song</string>
|
||||
<string name="setting_behavior_rewind_prev">Rewind before skipping back</string>
|
||||
<string name="setting_behavior_rewind_prev_desc">Rewind before skipping to the previous song</string>
|
||||
<string name="setting_behavior_loop_pause">Pause on repeat</string>
|
||||
<string name="setting_behavior_loop_pause_desc">Pause when a song repeats</string>
|
||||
|
||||
<string name="setting_content">Content</string>
|
||||
<string name="setting_content_save">Save playback state</string>
|
||||
|
@ -157,7 +159,6 @@
|
|||
<string name="format_next_from">Next From: %s</string>
|
||||
<string name="format_songs_loaded">Songs loaded: %d</string>
|
||||
|
||||
|
||||
<plurals name="format_song_count">
|
||||
<item quantity="one">%d Song</item>
|
||||
<item quantity="other">%d Songs</item>
|
||||
|
|
|
@ -126,6 +126,14 @@
|
|||
app:summary="@string/setting_behavior_rewind_prev_desc"
|
||||
app:title="@string/setting_behavior_rewind_prev" />
|
||||
|
||||
<SwitchPreference
|
||||
app:allowDividerBelow="false"
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="KEY_LOOP_PAUSE"
|
||||
app:summary="@string/setting_behavior_loop_pause_desc"
|
||||
app:title="@string/setting_behavior_loop_pause" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
|
Loading…
Reference in a new issue