Toggle skip silence when gapless config is changed
This commit is contained in:
parent
51321e33ca
commit
e46c39a33f
4 changed files with 9 additions and 2 deletions
|
@ -152,7 +152,7 @@ class SettingsActivity : SimpleControllerActivity() {
|
||||||
settings_gapless_playback.toggle()
|
settings_gapless_playback.toggle()
|
||||||
config.gaplessPlayback = settings_gapless_playback.isChecked
|
config.gaplessPlayback = settings_gapless_playback.isChecked
|
||||||
withPlayer {
|
withPlayer {
|
||||||
TODO("Toggle skip silence.")
|
sendCommand(CustomCommands.TOGGLE_SKIP_SILENCE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,8 @@ enum class CustomCommands(val customAction: String) {
|
||||||
CLOSE_PLAYER(customAction = PATH + "CLOSE_PLAYER"),
|
CLOSE_PLAYER(customAction = PATH + "CLOSE_PLAYER"),
|
||||||
RELOAD_CONTENT(customAction = PATH + "RELOAD_CONTENT"),
|
RELOAD_CONTENT(customAction = PATH + "RELOAD_CONTENT"),
|
||||||
SAVE_QUEUE(customAction = PATH + "SAVE_QUEUE"),
|
SAVE_QUEUE(customAction = PATH + "SAVE_QUEUE"),
|
||||||
TOGGLE_SLEEP_TIMER(customAction = PATH + "TOGGLE_SLEEP_TIMER");
|
TOGGLE_SLEEP_TIMER(customAction = PATH + "TOGGLE_SLEEP_TIMER"),
|
||||||
|
TOGGLE_SKIP_SILENCE(customAction = PATH + "TOGGLE_SKIP_SILENCE");
|
||||||
|
|
||||||
val sessionCommand = SessionCommand(customAction, Bundle.EMPTY)
|
val sessionCommand = SessionCommand(customAction, Bundle.EMPTY)
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import androidx.media3.session.MediaLibraryService.MediaLibrarySession
|
||||||
import com.google.common.util.concurrent.Futures
|
import com.google.common.util.concurrent.Futures
|
||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import com.google.common.util.concurrent.MoreExecutors
|
import com.google.common.util.concurrent.MoreExecutors
|
||||||
|
import com.simplemobiletools.musicplayer.extensions.config
|
||||||
import com.simplemobiletools.musicplayer.extensions.currentMediaItems
|
import com.simplemobiletools.musicplayer.extensions.currentMediaItems
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ internal fun PlaybackService.getMediaSessionCallback() = object : MediaLibrarySe
|
||||||
CustomCommands.RELOAD_CONTENT -> reloadContent()
|
CustomCommands.RELOAD_CONTENT -> reloadContent()
|
||||||
CustomCommands.SAVE_QUEUE -> saveRecentItems()
|
CustomCommands.SAVE_QUEUE -> saveRecentItems()
|
||||||
CustomCommands.TOGGLE_SLEEP_TIMER -> toggleSleepTimer()
|
CustomCommands.TOGGLE_SLEEP_TIMER -> toggleSleepTimer()
|
||||||
|
CustomCommands.TOGGLE_SKIP_SILENCE -> player.setSkipSilence(config.gaplessPlayback)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
|
return Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))
|
||||||
|
|
|
@ -28,4 +28,8 @@ class SimpleMusicPlayer(val exoPlayer: ExoPlayer) : ForwardingPlayer(exoPlayer)
|
||||||
override fun play() {
|
override fun play() {
|
||||||
playWhenReady = true
|
playWhenReady = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setSkipSilence(skipSilence: Boolean) {
|
||||||
|
exoPlayer.skipSilenceEnabled = skipSilence
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue