Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"page": { | ||
"label": "TRANSLATE.AUTO_PLAY_CONFIGURATION" | ||
}, | ||
"sections": [ | ||
{ | ||
"id": "no_setting", | ||
"element": "section", | ||
"label": "TRANSLATE.HEADING", | ||
"icon": "fa-plug", | ||
"content": [ | ||
{ | ||
} | ||
] | ||
} | ||
] | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"AUTO_PLAY_CONFIGURATION":"Autoplay", | ||
"HEADING": "No Settings, just enable this plugin in order to play music when volumio starts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
{ | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
# NOP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/usr/bin/env bash | ||
# NOP |