View Source MpvJsonIpc.Mpv (mpv_json_ipc v0.1.0)

Main module to interract with an MPV instance.

Link to this section Summary

Functions

Registers a callback to call when the event name occurs.

Registers a callback to call when the key name is pressed.

Sends the command to the MPV instance.

Registers a callback to call when the property name changes.

Convenience to register a callback for the event name.

Convenience to register a callback for the key name.

Convenience to register a callback for the property name.

Deletes a property observer with given observer_id.

Link to this section Functions

Link to this function

bind_event(server, name, callback)

View Source

Registers a callback to call when the event name occurs.

examples

Examples

MpvJsonIpc.Mpv.bind_event(server, "seek", fn _ -> IO.inspect("seeking") end)
MpvJsonIpc.Mpv.bind_event(server, "end-file", fn data -> IO.inspect("end-file with reason #{data[:reason]}") end)
Link to this function

bind_key(server, name, callback)

View Source

Registers a callback to call when the key name is pressed.

examples

Examples

MpvJsonIpc.Mpv.bind_key(server, "g", fn _ -> IO.inspect("key g is pressed") end)
Link to this function

command(server, cmd, args \\ [])

View Source

Sends the command to the MPV instance.

Available commands are here.

examples

Examples

MpvJsonIpc.Mpv.command(server, "get_property", "playback-time")
MpvJsonIpc.Mpv.command(server, :get_property, :"playback-time")
MpvJsonIpc.Mpv.command(main, "expand-properties", ["print-text", "${playback-time}"])
MpvJsonIpc.Mpv.command(server, :set_property, [:pause, true])
MpvJsonIpc.Mpv.command(server, %{
  name: "loadfile",
  url:
    "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4",
  options: %{
    cache: "yes",
    "demuxer-max-bytes": "100MiB",
    "demuxer-max-back-bytes": "100MiB"
  }
})
Link to this function

observe_property(server, name, callback)

View Source

Registers a callback to call when the property name changes.

examples

Examples

MpvJsonIpc.Mpv.observe_property(server, "pause", fn pause -> IO.inspect("Property pause now has value #{pause}") end)
Link to this macro

on_event(server, name, list)

View Source (macro)

Convenience to register a callback for the event name.

examples

Examples

MpvJsonIpc.Mpv.on_event server, "seek" do
  IO.inspect("seeking")
end
Link to this macro

on_keypress(server, name, list)

View Source (macro)

Convenience to register a callback for the key name.

examples

Examples

MpvJsonIpc.Mpv.on_keypress server, "g" do
  IO.inspect("key g is pressed")
end
Link to this macro

property_observer(server, name, list)

View Source (macro)

Convenience to register a callback for the property name.

examples

Examples

MpvJsonIpc.Mpv.property_observer server, "pause" do
  if pause, do: IO.inspect("in pause"), else: IO.inspect("playing")
end
Link to this function

unobserve_property(server, observer_id)

View Source

Deletes a property observer with given observer_id.

examples

Examples

oid = MpvJsonIpc.Mpv.observe_property(server, "pause", fn pause -> IO.inspect("Property pause now has value #{pause}") end)
...
MpvJsonIpc.Mpv.unobserve_property(server, oid)