mpv.cr

mpv.cr

🎥 libmpv - Command line media player - for Crystal

test Lines of Code

Installation

Add this shard to your shard.yml:

dependencies:
  mpv:
    github: kojix2/mpv.cr

Then install:

shards install

Quick start

require "mpv"

mpv = MPV::LibMPV.create
raise "mpv_create failed" if mpv.null?

MPV::LibMPV.set_option_string(mpv, "video", "no")
MPV::LibMPV.initialize(mpv)
MPV::LibMPV.command_string(mpv, %(loadfile "https://example.com/stream"))

loop do
  evp = MPV::LibMPV.wait_event(mpv, 0.5)
  ev = evp.value
  break if ev.event_id == MPV::LibMPV::EventID::SHUTDOWN
end

MPV::LibMPV.terminate_destroy(mpv)

Example

crystal build examples/play.cr

Pass a custom URL:

./play https://stream.live.vc.bbcmedia.co.uk/bbc_world_service

Play a local file:

./play /path/to/media

Development / Tests

crystal tool format
crystal spec

License

MIT License (see LICENSE).

Repository

mpv.cr

Owner
Statistic
  • 1
  • 0
  • 0
  • 1
  • 0
  • 4 days ago
  • October 14, 2025
License

MIT License

Links
Synced at

Sun, 19 Oct 2025 19:11:18 GMT

Languages