Skip to content

Commit

Permalink
restored auto_play files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghembs committed Nov 16, 2018
1 parent 93cafd9 commit ac14014
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/miscellanea/auto_play/UIConfig.json
@@ -0,0 +1,18 @@
{
"page": {
"label": "TRANSLATE.AUTO_PLAY_CONFIGURATION"
},
"sections": [
{
"id": "no_setting",
"element": "section",
"label": "TRANSLATE.HEADING",
"icon": "fa-plug",
"content": [
{
}
]
}
]

}
3 changes: 3 additions & 0 deletions plugins/miscellanea/auto_play/config.json
@@ -0,0 +1,3 @@
{
}

4 changes: 4 additions & 0 deletions plugins/miscellanea/auto_play/i18n/strings_en.json
@@ -0,0 +1,4 @@
{
"AUTO_PLAY_CONFIGURATION":"Autoplay",
"HEADING": "No Settings, just enable this plugin in order to play music when volumio starts"
}
108 changes: 108 additions & 0 deletions plugins/miscellanea/auto_play/index.js
@@ -0,0 +1,108 @@
'use strict';
var libQ = require('kew');
var MPD = require('node-mpd');


module.exports = ControllerAutoPlay;

function ControllerAutoPlay(context) {
var self = this;

this.context = context;
this.commandRouter = this.context.coreCommand;
this.logger = this.context.logger;
this.configManager = this.context.configManager;
}


/*
* This method can be defined by every plugin which needs to be informed of the startup of Volumio.
* The Core controller checks if the method is defined and executes it on startup if it exists.
*/
ControllerAutoPlay.prototype.onVolumioStart = function () {
var self = this;

var mpdPlugin = this.commandRouter.pluginManager.getPlugin('music_service', 'mpd');
var mpdHost = mpdPlugin.getConfigParam('nHost');
var mpdPort = mpdPlugin.getConfigParam('nPort');

self.logger.info('ControllerAutoPlay - connecting mpd on host: ' + mpdHost + '; port: ' + mpdPort);

var mpd = new MPD({
host : mpdHost,
port : mpdPort
});

mpd.on("ready", function() {
self.logger.info('ControllerAutoPlay - mpd ready');
mpd.disconnect();

setTimeout(function () {
self.logger.info('ControllerAutoPlay - getting queue');
var queue = self.commandRouter.volumioGetQueue();
if (queue && queue.length > 0) {
self.logger.info('ControllerAutoPlay - start playing -> queue is not empty');
self.commandRouter.volumioPlay();
}
}, 5000);
});

mpd.connect();

return libQ.resolve();
};


ControllerAutoPlay.prototype.onStart = function() {
var self = this;

return libQ.resolve();
};


ControllerAutoPlay.prototype.onStop = function () {
var self = this;
//Perform stop tasks here
};

ControllerAutoPlay.prototype.onRestart = function () {
var self = this;
//Perform restart tasks here
};

ControllerAutoPlay.prototype.onInstall = function () {
var self = this;
//Perform your installation tasks here
};

ControllerAutoPlay.prototype.onUninstall = function () {
var self = this;
//Perform your deinstallation tasks here
};

ControllerAutoPlay.prototype.getUIConfig = function() {
var defer = libQ.defer();
var self = this;

var lang_code = this.commandRouter.sharedVars.get('language_code');

self.commandRouter.i18nJson(__dirname+'/i18n/strings_'+lang_code+'.json',
__dirname+'/i18n/strings_en.json',
__dirname + '/UIConfig.json')
.then(function(uiconf)
{
defer.resolve(uiconf);
})
.fail(function()
{
defer.reject(new Error());
});

return defer.promise;
};


ControllerAutoPlay.prototype.setUIConfig = function(data)
{

};
2 changes: 2 additions & 0 deletions plugins/miscellanea/auto_play/install.sh
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
# NOP
20 changes: 20 additions & 0 deletions plugins/miscellanea/auto_play/package.json
@@ -0,0 +1,20 @@
{
"name": "auto_play",
"version": "1.0.0",
"description": "Autoplay plugin - Enable this plugin in order to let volumio start playing the last entry in the queue after a reboot.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Thomas Doerr",
"volumio_info": {
"prettyName": "Autoplay",
"icon": "fa-play-circle-o",
"plugin_type": "miscellanea",
"boot_priority": 10
},
"dependencies": {
"kew": "^0.7.0",
"node-mpd": "^0.0.1"
}
}
2 changes: 2 additions & 0 deletions plugins/miscellanea/auto_play/uninstall.sh
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
# NOP

0 comments on commit ac14014

Please sign in to comment.