ready4testing
This commit is contained in:
@@ -55,24 +55,6 @@ exports.timeSince = function timeSince(date) {
|
||||
return Math.floor(seconds) + " seconds";
|
||||
}
|
||||
|
||||
exports.isResultAvailable = function(res) {
|
||||
return (
|
||||
typeof res !== 'undefined' &&
|
||||
res != null &&
|
||||
typeof res.result !== 'undefined' &&
|
||||
res.result != null
|
||||
);
|
||||
}
|
||||
|
||||
exports.isTypeAvailable = function(res) {
|
||||
return (
|
||||
typeof res !== 'undefined' &&
|
||||
res != null &&
|
||||
typeof res.type !== 'undefined' &&
|
||||
res.type != null
|
||||
);
|
||||
}
|
||||
|
||||
exports.isJSON = function(toCheck) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
// load the things we need
|
||||
//nothing yet
|
||||
var Mplayer = require('node-mplayer');
|
||||
|
||||
|
||||
var App = null;
|
||||
@@ -15,6 +15,8 @@ var Log = null
|
||||
var Helper = null;
|
||||
var Conf = null;
|
||||
|
||||
var player = new Mplayer();
|
||||
|
||||
|
||||
exports.init = function(Express, Configuration) {
|
||||
App = Express;
|
||||
@@ -37,4 +39,46 @@ exports.countChannels = function() {
|
||||
|
||||
exports.getChannels = function() {
|
||||
return Conf.channels;
|
||||
}
|
||||
|
||||
exports.getChannel = function(idx) {
|
||||
if(Helper.isDefinedAndNotNull(Conf.channels[idx])) {
|
||||
return Conf.channels[idx];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
exports.play = function(idx) {
|
||||
var channel = Conf.channels[idx];
|
||||
if(channel !== undefined) {
|
||||
var stream2play;
|
||||
|
||||
try {
|
||||
var parsers = require("playlist-parser");
|
||||
var M3U = parsers.M3U;
|
||||
|
||||
var fs = require("fs");
|
||||
var playlist = M3U.parse(fs.readFileSync('/Users/gerrit/Downloads/swr3_m.m3u', { encoding: "utf8" }));
|
||||
Log.inspect('Radio: playlist', playlist);
|
||||
|
||||
if(Helper.isDefinedAndNotNull(playlist[0])) {
|
||||
stream2play = playlist[0].file;
|
||||
}
|
||||
} catch(e) {
|
||||
Log.error(e);
|
||||
}
|
||||
|
||||
|
||||
if(Helper.isDefinedAndNotNull(stream2play)) {
|
||||
Log.debug('Radio: Load stream: ' + stream2play);
|
||||
|
||||
player.setFile(stream2play);
|
||||
player.play();
|
||||
} else {
|
||||
Log.error('Radio: No stream defined!');
|
||||
}
|
||||
} else {
|
||||
Log.error('Radio: No channel defined!');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user