Yet another Music Player Daemon (MPD) client library written entirely in Ruby.
mpd_client is a Ruby port of the python-mpd library.
Add this line to your application Gemfile:
gem'mpd_client'And then execute:
$ bundle
Or install it yourself as:
$ gem install mpd_client
All functionality is contained in the MPDClient class. Creating an instance of this class is as simple as:
client=MPDClient.newOnce you have an instance of the MPDClient class, start by connecting to the server:
client.connect('localhost',6600)or Unix domain socket
client.connect('/var/run/mpd/socket')The client library can be used as follows:
putsclient.mpd_version# print the mpd versionputsclient.search('title','ruby')# print the result of the command 'search title ruby'client.close# send the close commandclient.disconect# disconnect from the serverCommand lists are also supported using command_list_ok_begin and command_list_end:
client.command_list_ok_begin# start a command listclient.update# insert the update command into the listclient.status# insert the status command into the listclient.command_list_end# result will be a Array with the resultsSome commands(e.g. move, delete, load, shuffle, playlistinfo) support integer ranges([START:END]) as argument. This is done in mpd_client by using two element array:
# move the first three songs after the fifth number in the playlistclient.move([0,3],5)Second element can be omitted. MPD will assumes the biggest possible number then:
# delete all songs from the current playlist, except for the firts tenclient.delete([10,])Default logger for all MPDClient instances:
require'logger'require'mpd_client'MPDClient.log=Logger.new($stderr)client=MPDClient.newSets the logger used by this instance of MPDClient:
require'logger'require'mpd_client'client=MPDClient.newclient.log=Logger.new($stderr)For more information about logging configuration, see http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html
After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
Copyright (c) 2013-2017 by Anton Maminov
This library is distributed under the MIT license. Please see the LICENSE file.