Giter Site home page Giter Site logo

mopidy's Introduction

Mopidy

A lightweight wrapper around the Mopidy music server API.

Installation

Add this line to your application's Gemfile:

gem 'mopidy'

And then execute:

$ bundle

Or install it yourself as:

$ gem install mopidy

Usage

The gem is divided into modules that reflect the controllers in the Mopidy core API. Currently, the supported modules are Library, Playback, Playlist, and Tracklist.

Configuration

To configure the url that the gem makes requests to:

Mopidy.configure do |config|
  config.mopidy_url = 'http://localhost:6680/mopidy/rpc' # This is the default
end

Tracklist

This is the module that interfaces with Mopidy's tracklist controller

To get the tracks in the tracklist:

Mopidy::Tracklist.tracks

To get the index of the currently playing track:

Mopidy::Tracklist.index

To get the tracks in the tracklist as TLTRacks

Mopidy::Tracklist.tl_tracks

To add a track to the tracklist:

Mopidy::Tracklist.add(uri: 'example-track-uri')

To get the length of the tracklist:

Mopidy::Tracklist.length

To clear the tracks from the tracklist:

Mopidy::Tracklist.clear

Library

This is the module that interfaces with Mopidy's Library controller

To search for tracks, artists, playlists, and albums using a keyword:

Mopidy::Library.search('queen')

To search for tracks by artist, album, or track:

Mopidy::Library.search_tracks('bicycle')

To lookup a track by it's uri:

Mopidy::Library.lookup('example-uri')

Playlist

This is the module that interfaces with Mopidy's Playlist controller

To get a list of playlists:

Mopidy::Playlist.as_list

To lookup a playlist by it's uri

Mopidy::Playlist.lookup('playlist-uri')

Playback

This is the module that interfaces with Mopidy's Playback controller

To play:

Mopidy::Playlist.play

To pause:

Mopidy::Playlist.pause

To resume:

Mopidy::Playlist.resume

To stop:

Mopidy::Playlist.stop

To get the playback state:

Mopidy::Playlist.state

To get the current time position:

Mopidy::Playlist.time_position

To seek to a time position:

time_position = 1000 # Time position in milliseconds
Mopidy::Playlist.seek(time_position)

To get the currently playing track:

Mopidy::Playlist.current_track

To skip to the next track:

Mopidy::Playlist.next

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec 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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/khisakuni/mopidy.

License

The gem is available as open source under the terms of the MIT License.

mopidy's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

ares

mopidy's Issues

Is this still alive?

Hello,

I just started to use the project. I realized I need to fix few things, since this gem seems dated. Do you accept PRs or should I continue with the fork? Also would you release a new version? If you add me as an owner on rubygems, I'm happy to do the release.

Need a way to see response from Mopidy server

Currently there's no way of seeing the response from the Mopidy server. If there's something wrong, an empty array or hash is returned. We need more info in the methods that return something from the Mopidy server

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.