Giter VIP home page Giter VIP logo

butter_remote.js's Introduction

butter_remote.js

butter_remote.js is a javascript library that provides an easy way to make an application or whatever you want to control the interface of butter through the json rpc protocol.
The plugin is developed with simplicity in mind so the methods name are the same that you can find in the butter documention and there are many other conveniences. So despite that doc has been written with the json rpc protocol in mind, the information about the usage of the methods are compatible for this library too... actually you will not even notice that you're using this library.

Download

You can get the plugin in two ways:

  1. Downloading the raw file in the dist folder choosing the clean or minified version.
  2. Go to the releases tab and download the Source code.zip

The website

Actually the website that you can find on the gh-pages branch hosted on butter.giacomocerquone.com is the coolest thing in here. It's just a draft to prove the potential of this library and what you can do with it. I'll do my best to improve it but I haven't so much free time so if you want to contribute I would really appreciate that!

Include and Initialize

Firstly you should obviously include the library on the page you want to use it:

<script src="butter_remote.min.js"></script>

After initialize the plugin in this way:

butter_remote.init(
//If you don't need to change these settings you can remove this whole part
  {
    username: "popcorn",
    password: "popcorn",
    ip: "127.0.0.1",
    port: "8008",
    debug: "false"
  }
//If you don't need to change these settings you can remove this whole part
);

Usage

As you can understand from the butter time documentation, there are "three kinds" of methods.

Methods which performs actions without any parameter needed.

These are {listing methods}:

butter_remote.ping();
Methods that need parameters to performs certain actions.

These are {listing methods}:

butter_remote.filtergenre(["Adventure"]);
Methods which performs actions and return some data.

Here you have a callback function and the data can be accessed in this way:

//This get the current volume in the player
butter_remote.volume(function(data) {
  console.log(data);
});
//This set the current volume in the player
butter_remote.volume([2]);
The listennotification function

I'd like to spend two words for this particular function. butter developers put this fundamental function in their API to know when something change on the desktop application. To listen these important events you need to use "setInterval" so you can call the function at specified intervals, here the example:

setInterval(function() {
    pr.listennotifications(function(data) {
        //Use the data object to read the notifications
        //and do wathever you need with the notifications you just took (changing commands etc.)
    })
}, 1000);

License

Released under the GNU 3 license.
If you distribute a copy or make a fork of the project, you have to credit this project as source.
Copyright © 2015, Giacomo cerquone.
All rights reserved.

butter_remote.js's People

Contributors

giacomocerquone avatar ntoonio avatar

Stargazers

Juan Rosero avatar Eduardo Poiate avatar

Watchers

 avatar Juan Rosero avatar

Forkers

bi1zi1 persei08

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.