Toggle skip silence when gapless config is changed

This commit is contained in:
Naveen 2023-08-20 23:54:33 +05:30
parent 51321e33ca
commit e46c39a33f
No known key found for this signature in database
GPG key ID: 0E155DAD31671DA3
4 changed files with 9 additions and 2 deletions

View file

@ -152,7 +152,7 @@ class SettingsActivity : SimpleControllerActivity() {
settings_gapless_playback.toggle()
config.gaplessPlayback = settings_gapless_playback.isChecked
withPlayer {
TODO("Toggle skip silence.")
sendCommand(CustomCommands.TOGGLE_SKIP_SILENCE)
}
}
}

View file

@ -14,7 +14,8 @@ enum class CustomCommands(val customAction: String) {
CLOSE_PLAYER(customAction = PATH + "CLOSE_PLAYER"),
RELOAD_CONTENT(customAction = PATH + "RELOAD_CONTENT"),
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)

View file

@ -10,6 +10,7 @@ import androidx.media3.session.MediaLibraryService.MediaLibrarySession
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
import com.google.common.util.concurrent.MoreExecutors
import com.simplemobiletools.musicplayer.extensions.config
import com.simplemobiletools.musicplayer.extensions.currentMediaItems
import java.util.concurrent.Executors
@ -68,6 +69,7 @@ internal fun PlaybackService.getMediaSessionCallback() = object : MediaLibrarySe
CustomCommands.RELOAD_CONTENT -> reloadContent()
CustomCommands.SAVE_QUEUE -> saveRecentItems()
CustomCommands.TOGGLE_SLEEP_TIMER -> toggleSleepTimer()
CustomCommands.TOGGLE_SKIP_SILENCE -> player.setSkipSilence(config.gaplessPlayback)
}
return Futures.immediateFuture(SessionResult(SessionResult.RESULT_SUCCESS))

View file

@ -28,4 +28,8 @@ class SimpleMusicPlayer(val exoPlayer: ExoPlayer) : ForwardingPlayer(exoPlayer)
override fun play() {
playWhenReady = true
}
fun setSkipSilence(skipSilence: Boolean) {
exoPlayer.skipSilenceEnabled = skipSilence
}
}