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