This document aims to explain the design of mpv-remote-app for anyone curious.
mpv-remote-app uses an HMAC with a preshared key to ensure message authenticity and integrity. Every message excluding "health" is wrapped in this HMAC in the following format:
{
"message": "{\"time\": 123, \"command\": \"hi\"}",
"hmac": "89e9d274c49e7bd7a58778208df4d51d"
}
The messages exchanged between server and client are a few generic white-listed commands:
command | required args | optional args |
---|---|---|
health | ||
play | path (string) | |
pause | state (boolean) | |
stop | ||
seek | seconds (integer) | |
set_volume | volume (integer) | |
set_subtitles | track (integer) | |
set_audio | track (integer) | |
fullscreen | state (boolean) | |
mute | state (boolean) | |
repeat | args (string array) | delay (float), speedup (boolean) |
list | directory (string) | |
show | property (string) | pre (string), post (string) |
tracks |
Input Output health { "action": null, "message": null, "result": true, "time": 123 } { "command": "play", "path": "path/to/file.mkv", "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "pause", "state": true, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "stop", "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "seek", "seconds": 5, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "set_volume", "volume": 95, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "set_subtitles", "track": 1, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "set_audio", "track": 1, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "fullscreen", "state": true, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "mute", "state": false, "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "repeat", "delay": 0.1, "speedup": true, "args": [ "seek", "seconds", "5" ] "time": 123 } { "action": 123, "message": null, "result": true, "time": 124 } { "command": "list", "directory": ".", "time": 123 } { "action": 123, "message": { "directories": [ "videos" ], "files": [ "outkast-roses.mp3" ] } "result": true, "time": 124 } { "command": "show", "property": "volume", "pre": "Volume: ", "post": "%", "time": 123 } { "action": 123, "message": null, "result": "", "time": 124 } { "command": "tracks", "time": 123 } { "action": 123, "message": { "audio": [ "1: eng", "2: jpn" ], "subtitle": [ "1: jpn" ] }, "result": true, "time": 124 }