View Source MpvJsonIpc.Mpv.Sup (mpv_json_ipc v0.1.0)
A Supervisor for an MPV instance.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the the server instance that you can interract with using Mpv
Starts the the supervisor.
Stops the supervisor.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Returns the the server instance that you can interract with using Mpv
examples
Examples
{:ok, sup} = MpvJsonIpc.Mpv.Sup.start_link()
main = MpvJsonIpc.Mpv.Sup.main(sup)
# When you don't know the supervisor pid (e.g. MpvJsonIpc.Mpv.Sup directly started in the supervision tree)
{_, sup} = MpvJsonIpc.running_sups() |> List.first()
main = MpvJsonIpc.Mpv.Sup.main(sup)
MpvJsonIpc.Mpv.command(main, "get_property", "playback-time")
Starts the the supervisor.
The following options can be set:
:start_mpv
- Whether to start an MPV instance; default:true
. If this is set tofalse
,:ipc_server
must also be set.:ipc_server
- the path of the IPC server, of the already running MPV instance.:path
- the path of the MPV executable. If this is not set, it looks for MPV in the$PATH
.:log_level
- Whether to receive log messages from the MPV instance. If this is set,:log_handler
must also be set. Available levels are described here:log_handler
- a function that process log messages.
examples
Examples
# Uses the MPV executable found in the `$PATH`
MpvJsonIpc.Mpv.Sup.start_link()
# Uses a running MPV connected to /tmp/mpvsocket
MpvJsonIpc.Mpv.Sup.start_link(start_mpv: false, ipc_server: "/tmp/mpvsocket")
# Uses the MPV executable found at /path/to/mpv
MpvJsonIpc.Mpv.Sup.start_link(path: "/path/to/mpv")
# Calls `IO.inspect/1` on all messages with level `:debug` or above
MpvJsonIpc.Mpv.Sup.start_link(log_level: :debug, log_handler: &IO.inspect/1)
Stops the supervisor.