boxeen

Boxee API wrapper

npm install boxeen
1 downloads in the last month

Boxeen

Boxee API wrapper for node

Install

$ npm install boxeen

Usage Example

var boxeen = require('boxeen');

boxeen.find(1000, function(hosts) {
    console.log('List of found hosts: \n' + JSON.stringify(hosts));

    boxeen.GetVolume(hosts[0], function(e, volume) {
        if(e) {
            console.log(e);
        } else {
            console.log('Volume: ' + volume);
        }
    });
});

API

find: Find hosts in the local network

  • @param {int} timeout in millisecons
  • @param {function(hosts)} callback (optional)

hosts:

[
    {
        host: 'hostname',
        port: 8800
    },
        ...
]

usage:

boxeen.find(1000, function(hosts) {
    console.log('List of found hosts: \n' + JSON.stringify(hosts));
});

GetVolume: Retrieves the current volume setting as a percentage of the maximum possible value.

  • @param {object} host
  • @param {function(error, volume)} callback (optional)

usage:

boxeen.GetVolume(host, function(e, volume) {
    if(e) {
        console.log(e);
    } else {
        console.log('Volume: ' + volume);
    }
});

SetVolume(percent): Sets the volume as a percentage of the maximum possible.

boxeen.SetVolume(host, 50, function(success) {
    if(success) {
        console.log('Volume changed');
    } else {
        console.log('Volume not changed');
    }
});

Mute: Toggles the sound on/off.

boxeen.Mute(host, function(success) {
    if(success) {
        console.log('Mute toggled');
    } else {
        console.log('Mute not toggled');
    }
});

Pause: Pauses the currently playing media.

boxeen.Pause(host, function(success) {
    if(success) {
        console.log('Pause toggled');
    } else {
        console.log('Pause not toggled');
    }
});

Stop: Stops the currently playing media.

boxeen.Stop(host, function(success) {
    if(success) {
        console.log('Stoped');
    } else {
        console.log('Not Stoped');
    }
});

PlayNext: Starts playing/showing the next media/image in the current playlist or, if currently showing a slidshow, the slideshow playlist.

boxeen.PlayNext(host, function(success) {
    if(success) {
        console.log('Playing Next');
    } else {
        console.log('Not Playing Next');
    }
});

PlayPrev: Starts playing/showing the previous media/image in the current playlist or, if currently showing a slidshow, the slideshow playlist.

boxeen.PlayPrev(host, function(success) {
    if(success) {
        console.log('Playing Prev');
    } else {
        console.log('Not Playing Prev');
    }
});

SeekPercentage(percentage): Sets the playing position of the currently playing media as a percentage of the media’s length.

boxeen.Stop(host, percentage, function(success) {
    if(success) {
        console.log('Stoped');
    } else {
        console.log('Not Stoped');
    }
});

SeekPercentageRelative(relative-percentage): Adds/Subtracts the current percentage on to the current postion in the song

boxeen.Stop(host, percentage, function(success) {
    if(success) {
        console.log('Stoped');
    } else {
        console.log('Not Stoped');
    }
});

GetPercentage: Retrieves the current playing position of the currently playing media as a percentage of the media’s length.

boxeen.Back(host, function(e, percentage) {
    if(success) {
        console.log('Back');
    } else {
        console.log('!Back');
    }
});

Up: Click on UP button

boxeen.Up(host, function(success) {
    if(success) {
        console.log('Up');
    } else {
        console.log('!Up');
    }
});

Down: Click on DOWN button

boxeen.Down(host, function(success) {
    if(success) {
        console.log('Down');
    } else {
        console.log('!Down');
    }
});

Left: Click on LEFT button

boxeen.Left(host, function(success) {
    if(success) {
        console.log('Left');
    } else {
        console.log('!Left');
    }
});

Right: Click on RIGHT button

boxeen.Right(host, function(success) {
    if(success) {
        console.log('Right');
    } else {
        console.log('!Right');
    }
});

Back: Click on BACK button

boxeen.Back(host, function(success) {
    if(success) {
        console.log('Back');
    } else {
        console.log('!Back');
    }
});

Backspace: Sends an backspace key (used in keyboard)

boxeen.Backspace(host, function(success) {
    if(success) {
        console.log('Backspace Successefull');
    } else {
        console.log('Backspace not successefull');
    }
});

SendKey(): Sends an ASCII key (used in keyboard)

boxeen.SendKey(host, 27, function(success) {
    if(success) {
        console.log('Key sent');
    } else {
        console.log('Key not sent');
    }
});

Node Compatibility

This is only compatible with older versions of node because dgram.setBroadcast(flag) is not implemented in the newest versions.

License

(The MIT License)

Copyright (c) 2009-2011 Sérgio Ramos <mail@sergioramos.me>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

npm loves you