You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+85-11
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,25 @@
1
1
# mpv-web-remote
2
2
3
-
Simple web remote control for the [mpv media player](https://mpv.io/), using the [JSON IPC interface](https://mpv.io/manual/stable/#json-ipc).
3
+
Simple zero-dependency web remote for the [mpv media player](https://mpv.io/), using the [JSON IPC interface](https://mpv.io/manual/stable/#json-ipc).
4
4
5
5

6
6
7
-
A single binary on the host machine connects to the mpv unix socket and exposes a remote control via a web server, that can be accessed from any device on the same network (e.g. a smartphone).
8
-
9
-
The web app announces itself via the [media session API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API), allowing control even when the app is in the background, or from connected devices (e.g. a smartwatch).
7
+
A single binary on the host machine connects to the mpv [unix socket](https://en.wikipedia.org/wiki/Unix_domain_socket) and exposes a remote control via a web server, which can be accessed from any device on the same network (e.g. a smartphone). The web app announces itself via the [media session API](https://developer.mozilla.org/en-US/docs/Web/API/Media_Session_API), allowing control even when the app is in the background, or from connected devices (e.g. a smartwatch).
10
8
11
9

12
10
13
11
The client code can also be used separately to interface with mpv from Rust in other use cases.
14
12
15
-
See https://c.pgdm.ch/eps-projects/mpv-web-remote
13
+
## Features
14
+
15
+
For now, only the following basic functions are supported:
16
+
17
+
- Play/pause
18
+
- Toggle full-screen
19
+
- Rewind 10 seconds (can be changed with the `--rewind-s` option)
20
+
- Visualize progress (current time, total time, percentage)
21
+
- Preview (updated every 3 seconds)
22
+
- Seek (by clicking on the progress bar)
16
23
17
24
## Installation
18
25
@@ -37,7 +44,8 @@ The web server will then be enabled shortly after a new instance of mpv is start
37
44
38
45
With the default parameters, the control interface will be accessible on <http://[ip]:3000>.
39
46
40
-
Warning: there is currently no authentication.
47
+
> [!WARNING]
48
+
> There is currently no authentication.
41
49
42
50
### Alternative: Manual installation
43
51
@@ -66,9 +74,75 @@ Options:
66
74
-h, --help Print help
67
75
```
68
76
69
-
## Other projects
77
+
## Implementation details
78
+
79
+
There are two components:
80
+
81
+
- the interface with mpv
82
+
- the web server
83
+
84
+
The web server is straightforward and is implemented with [axum](https://docs.rs/axum/latest/axum/). For page interactions, we simply use [jQuery](https://jquery.com/).
The `connect` constructor connects to the socket and creates a thread responsible for reading replies and events from the servers into a buffer. In particular, we are robust against changes to this implementation detail:
97
+
98
+
> "Currently, the mpv-side IPC implementation does not service the socket while a command is executed and the reply is written. It is for example not possible that other events, that happened during the execution of the command, are written to the socket before the reply is written.
99
+
>
100
+
> This might change in the future. The only guarantee is that replies to IPC messages are sent in sequence."
101
+
102
+
The `send` method writes a request to the socket, serialized using [`serde_json`](https://docs.rs/serde_json/latest/serde_json/). It then blocks until the server responds to that request.
103
+
104
+
A selection of [commands](https://mpv.io/manual/stable/#list-of-input-commands) is implemented:
This could also be encapsulated into higher-level methods (e.g. `get_playback_time() -> f64`).
138
+
139
+
Finally, the `wait_event` method simply blocks until an event occurs. This is for example useful to only trigger a screenshot at the new position after a seek has finished.
140
+
141
+
## Existing solutions
142
+
143
+
A quick search will reveal two "mpv remote" Android apps using the aforementioned mpv control interface. Naturally, they also require an additional component to run on the host machine to expose the API to the app.
144
+
145
+
-<https://github.com/husudosu/mpv-remote-app>, where a Node.JS server (<https://github.com/husudosu/mpv-remote-node>) runs as an mpv plugin and provides an API over HTTP.
146
+
-<https://github.com/mcastorina/mpv-remote-app>, where a separate Python server exposes an API over a network socket.
70
147
71
-
- Android apps:
72
-
-<https://github.com/husudosu/mpv-remote-app> with a Node.JS server.
73
-
-<https://github.com/mcastorina/mpv-remote-app> with a Python server.
74
-
-https://crates.io/crates/mpvipc: fairly complete Rust interface for the mpv control interface.
148
+
The [mpvipc](https://crates.io/crates/mpvipc) crate provides a similar and more complete interface, but the above was an opportunity to experiment with a different implementation, under a more permissive license.
0 commit comments