mpv

Version, currently main branch1 version
  • main branchlatestOct 15, 2025

github.com/kojix2/mpv.cr

No description declared in shard.yml.

1 stars
1 dependent
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  mpv:
    github: kojix2/mpv.cr
    branch: main

main is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
>= 1.17.1
License
MIT
Author
kojix2

Dependencies

This version declares no dependencies.

README

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).