mirror of
https://gitlab.com/ultrasonic/ultrasonic.git
synced 2025-04-17 09:42:25 +03:00
Merge branch 'wifiPerf' into 'develop'
Add a ClearJukebox method See merge request ultrasonic/ultrasonic!1141
This commit is contained in:
commit
ddfaf520e5
@ -320,7 +320,7 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun updateJukeboxPlaylist(ids: List<String>?): JukeboxStatus {
|
||||
override fun updateJukeboxPlaylist(ids: List<String>): JukeboxStatus {
|
||||
return musicService.updateJukeboxPlaylist(ids)
|
||||
}
|
||||
|
||||
@ -334,6 +334,11 @@ class CachedMusicService(private val musicService: MusicService) : MusicService,
|
||||
return musicService.stopJukebox()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun clearJukebox(): JukeboxStatus {
|
||||
return musicService.clearJukebox()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun startJukebox(): JukeboxStatus {
|
||||
return musicService.startJukebox()
|
||||
|
@ -53,7 +53,7 @@ private const val QUEUE_POLL_INTERVAL_SECONDS = 1L
|
||||
* TODO: Persist RC state?
|
||||
* TODO: Minimize status updates.
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
@Suppress("TooManyFunctions", "DeprecatedCallableAddReplaceWith")
|
||||
@SuppressLint("UnsafeOptInUsageError")
|
||||
class JukeboxMediaPlayer : JukeboxUnimplementedFunctions(), Player {
|
||||
private val tasks = TaskQueue()
|
||||
@ -314,6 +314,7 @@ class JukeboxMediaPlayer : JukeboxUnimplementedFunctions(), Player {
|
||||
|
||||
override fun increaseDeviceVolume(flags: Int) {
|
||||
gain = (gain + 1).coerceAtMost(MAX_GAIN)
|
||||
@Suppress("DEPRECATION")
|
||||
deviceVolume = gain
|
||||
}
|
||||
|
||||
@ -324,6 +325,7 @@ class JukeboxMediaPlayer : JukeboxUnimplementedFunctions(), Player {
|
||||
|
||||
override fun decreaseDeviceVolume(flags: Int) {
|
||||
gain = (gain - 1).coerceAtLeast(0)
|
||||
@Suppress("DEPRECATION")
|
||||
deviceVolume = gain
|
||||
}
|
||||
|
||||
@ -334,6 +336,7 @@ class JukeboxMediaPlayer : JukeboxUnimplementedFunctions(), Player {
|
||||
|
||||
override fun setDeviceMuted(muted: Boolean, flags: Int) {
|
||||
gain = 0
|
||||
@Suppress("DEPRECATION")
|
||||
deviceVolume = gain
|
||||
}
|
||||
|
||||
@ -583,7 +586,13 @@ class JukeboxMediaPlayer : JukeboxUnimplementedFunctions(), Player {
|
||||
for (item in playlist) {
|
||||
ids.add(item.mediaId)
|
||||
}
|
||||
tasks.add(SetPlaylist(ids))
|
||||
|
||||
if (ids.isNotEmpty()) {
|
||||
tasks.add(SetPlaylist(ids))
|
||||
} else {
|
||||
tasks.add(ClearPlaylist())
|
||||
}
|
||||
|
||||
Handler(Looper.getMainLooper()).post {
|
||||
listeners.sendEvent(
|
||||
Player.EVENT_TIMELINE_CHANGED
|
||||
@ -684,6 +693,13 @@ class JukeboxMediaPlayer : JukeboxUnimplementedFunctions(), Player {
|
||||
}
|
||||
}
|
||||
|
||||
private inner class ClearPlaylist : JukeboxTask() {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(): JukeboxStatus {
|
||||
return musicService.clearJukebox()
|
||||
}
|
||||
}
|
||||
|
||||
private inner class Start : JukeboxTask() {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(): JukeboxStatus {
|
||||
|
@ -23,7 +23,7 @@ import androidx.media3.common.Tracks
|
||||
* This class helps to hide the unused (thus unimplemented) functions
|
||||
* of the crowded Player interface, so the JukeboxMediaPlayer class can be a bit clearer.
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
@Suppress("TooManyFunctions", "DeprecatedCallableAddReplaceWith")
|
||||
@SuppressLint("UnsafeOptInUsageError")
|
||||
abstract class JukeboxUnimplementedFunctions : Player {
|
||||
|
||||
|
@ -141,7 +141,7 @@ interface MusicService {
|
||||
fun isJukeboxAvailable(): Boolean
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun updateJukeboxPlaylist(ids: List<String>?): JukeboxStatus
|
||||
fun updateJukeboxPlaylist(ids: List<String>): JukeboxStatus
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun skipJukebox(index: Int, offsetSeconds: Int): JukeboxStatus
|
||||
@ -149,6 +149,9 @@ interface MusicService {
|
||||
@Throws(Exception::class)
|
||||
fun stopJukebox(): JukeboxStatus
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun clearJukebox(): JukeboxStatus
|
||||
|
||||
@Throws(Exception::class)
|
||||
fun startJukebox(): JukeboxStatus
|
||||
|
||||
|
@ -340,7 +340,7 @@ class OfflineMusicService : MusicService, KoinComponent {
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun updateJukeboxPlaylist(ids: List<String>?): JukeboxStatus {
|
||||
override fun updateJukeboxPlaylist(ids: List<String>): JukeboxStatus {
|
||||
throw OfflineException("Jukebox not available in offline mode")
|
||||
}
|
||||
|
||||
@ -353,6 +353,10 @@ class OfflineMusicService : MusicService, KoinComponent {
|
||||
override fun stopJukebox(): JukeboxStatus {
|
||||
throw OfflineException("Jukebox not available in offline mode")
|
||||
}
|
||||
@Throws(Exception::class)
|
||||
override fun clearJukebox(): JukeboxStatus {
|
||||
throw OfflineException("Jukebox not available in offline mode")
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun startJukebox(): JukeboxStatus {
|
||||
|
@ -511,7 +511,7 @@ open class RESTMusicService(
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun updateJukeboxPlaylist(
|
||||
ids: List<String>?
|
||||
ids: List<String>
|
||||
): JukeboxStatus {
|
||||
val response = API.jukeboxControl(JukeboxAction.SET, null, null, ids, null)
|
||||
.execute().throwOnFailure()
|
||||
@ -538,6 +538,14 @@ open class RESTMusicService(
|
||||
return response.body()!!.jukebox.toDomainEntity()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun clearJukebox(): JukeboxStatus {
|
||||
val response = API.jukeboxControl(JukeboxAction.CLEAR, null, null, null, null)
|
||||
.execute().throwOnFailure()
|
||||
|
||||
return response.body()!!.jukebox.toDomainEntity()
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
override fun startJukebox(): JukeboxStatus {
|
||||
val response = API.jukeboxControl(JukeboxAction.START, null, null, null, null)
|
||||
|
Loading…
x
Reference in New Issue
Block a user