-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle new handshake format in player
- Loading branch information
1 parent
32e06a4
commit 7ad3932
Showing
4 changed files
with
33 additions
and
57 deletions.
There are no files selected for viewing
39 changes: 11 additions & 28 deletions
39
src/nativeMain/kotlin/cinterop/mpv/MpvCommandInterface.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,16 @@ | ||
package cinterop.mpv | ||
|
||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.serialization.json.JsonElement | ||
import kotlinx.serialization.json.encodeToJsonElement | ||
import spms.player.Player | ||
import spms.server.SpMsServerState | ||
|
||
@Serializable | ||
data class ServerStatusData( | ||
val queue: List<String>, | ||
val state: Player.State, | ||
val is_playing: Boolean, | ||
val current_item_index: Int, | ||
val current_position_ms: Long, | ||
val duration_ms: Long, | ||
val repeat_mode: Player.RepeatMode, | ||
val volume: Double | ||
) | ||
|
||
fun Player.getCurrentStateJson(): JsonElement = | ||
Json.encodeToJsonElement( | ||
ServerStatusData( | ||
(0 until item_count).map { getItem(it) ?: "" }, | ||
state, | ||
is_playing, | ||
current_item_index, | ||
current_position_ms, | ||
duration_ms, | ||
repeat_mode, | ||
volume | ||
) | ||
fun Player.getCurrentStateJson(): SpMsServerState = | ||
SpMsServerState( | ||
(0 until item_count).map { getItem(it) ?: "" }, | ||
state, | ||
is_playing, | ||
current_item_index, | ||
current_position_ms.toInt(), | ||
duration_ms.toInt(), | ||
repeat_mode, | ||
volume.toFloat() | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters