• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

mm-music-player errors

Scheduled Pinned Locked Moved Troubleshooting
13 Posts 5 Posters 5.9k Views 5 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    johnnyboy @robertoOk
    last edited by johnnyboy Jun 10, 2017, 12:26 PM Apr 11, 2017, 4:33 PM

    This post is deleted!
    1 Reply Last reply Reply Quote 0
    • R Offline
      robertoOk
      last edited by Apr 12, 2017, 2:51 PM

      /* Magic Mirror

      • The Core App (Server)
      • By Michael Teeuw http://michaelteeuw.nl
      • MIT Licensed.
        */

      var fs = require(“fs”);
      var Server = require(__dirname + “/server.js”);
      var defaultModules = require(__dirname + “/…/modules/default/defaultmodules.js”);
      var path = require(“path”);

      // Get version number.
      global.version = JSON.parse(fs.readFileSync(“package.json”, “utf8”)).version;
      console.log(“Starting MagicMirror: v” + global.version);

      // global absolute root path
      global.root_path = path.resolve(__dirname + “/…/”);

      // The next part is here to prevent a major exception when there
      // is no internet connection. This could probable be solved better.
      process.on(“uncaughtException”, function (err) {
      console.log(“Whoops! There was an uncaught exception…”);
      console.error(err);
      console.log(“MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?”);
      console.log(“If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues”);
      });

      /* App - The core app.
      */
      var App = function() {
      var nodeHelpers = [];

      /* loadConfig(callback)
       * Loads the config file. combines it with the defaults,
       * and runs the callback with the found config as argument.
       *
       * argument callback function - The callback function.
       */
      
      var loadConfig = function(callback) {
      	console.log("Loading config ...");
      	var defaults = require(__dirname + "/defaults.js");
      	var configFilename = path.resolve(global.root_path + "/config/config.js");
      	try {
      		fs.accessSync(configFilename, fs.F_OK);
      		var c = require(configFilename);
      		var config = Object.assign(defaults, c);
      		callback(config);
      	} catch (e) {
      		if (e.code == "ENOENT") {
      			console.error("WARNING! Could not find config file. Please create one. Starting with default configuration.");
      			callback(defaults);
      		} else if (e instanceof ReferenceError || e instanceof SyntaxError) {
      			console.error("WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.");
      			callback(defaults);
      		} else {
      			console.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e);
      			callback(defaults);
      		}
      	}
      };
      
      /* loadModule(module)
       * Loads a specific module.
       *
       * argument module string - The name of the module (including subpath).
       */
      var loadModule = function(module) {
      
      	var elements = module.split("/");
      	var moduleName = elements[elements.length - 1];
      	var moduleFolder =  __dirname + "/../modules/" + module;
      
      	if (defaultModules.indexOf(moduleName) !== -1) {
      		moduleFolder =  __dirname + "/../modules/default/" + module;
      	}
      
      	var helperPath = moduleFolder + "/node_helper.js";
      
      	var loadModule = true;
      	try {
      		fs.accessSync(helperPath, fs.R_OK);
      	} catch (e) {
      		loadModule = false;
      		console.log("No helper found for module: " + moduleName + ".");
      	}
      
      	if (loadModule) {
      		var Module = require(helperPath);
      		var m = new Module();
      
      		if (m.requiresVersion) {
      			console.log("Check MagicMirror version for node helper '" + moduleName + "' - Minimum version:  " + m.requiresVersion + " - Current version: " + global.version);
      			if (cmpVersions(global.version, m.requiresVersion) >= 0) {
      				console.log("Version is ok!");
      			} else {
      				console.log("Version is incorrect. Skip module: '" + moduleName + "'");
      				return;
      			}
      		}
      
      		m.setName(moduleName);
      		m.setPath(path.resolve(moduleFolder));
      		nodeHelpers.push(m);
      	}
      };
      
      /* loadModules(modules)
       * Loads all modules.
       *
       * argument module string - The name of the module (including subpath).
       */
      var loadModules = function(modules) {
      	console.log("Loading module helpers ...");
      
      	for (var m in modules) {
      		loadModule(modules[m]);
      	}
      
      	console.log("All module helpers loaded.");
      };
      
      /* cmpVersions(a,b)
       * Compare two symantic version numbers and return the difference.
       *
       * argument a string - Version number a.
       * argument a string - Version number b.
       */
      function cmpVersions(a, b) {
      	var i, diff;
      	var regExStrip0 = /(\.0+)+$/;
      	var segmentsA = a.replace(regExStrip0, "").split(".");
      	var segmentsB = b.replace(regExStrip0, "").split(".");
      	var l = Math.min(segmentsA.length, segmentsB.length);
      
      	for (i = 0; i < l; i++) {
      		diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
      		if (diff) {
      			return diff;
      		}
      	}
      	return segmentsA.length - segmentsB.length;
      }
      
      /* start(callback)
       * This methods starts the core app.
       * It loads the config, then it loads all modules.
       * When it"s done it executs the callback with the config as argument.
       *
       * argument callback function - The callback function.
       */
      this.start = function(callback) {
      
      	loadConfig(function(c) {
      		config = c;
      
      		var modules = [];
      
      		for (var m in config.modules) {
      			var module = config.modules[m];
      			if (modules.indexOf(module.module) === -1 && !module.disabled) {
      				modules.push(module.module);
      			}
      		}
      
      		loadModules(modules);
      
      		var server = new Server(config, function(app, io) {
      			console.log("Server started ...");
      
      			for (var h in nodeHelpers) {
      				var nodeHelper = nodeHelpers[h];
      				nodeHelper.setExpressApp(app);
      				nodeHelper.setSocketIO(io);
      				nodeHelper.start();
      			}
      
      			console.log("Sockets connected & modules started ...");
      
      			if (typeof callback === "function") {
      				callback(config);/* Magic Mirror
      
      • The Core App (Server)
      • By Michael Teeuw http://michaelteeuw.nl
      • MIT Licensed.
        */

      var fs = require(“fs”);
      var Server = require(__dirname + “/server.js”);
      var defaultModules = require(__dirname + “/…/modules/default/defaultmodules.js”);
      var path = require(“path”);

      // Get version number.
      global.version = JSON.parse(fs.readFileSync(“package.json”, “utf8”)).version;
      console.log(“Starting MagicMirror: v” + global.version);

      // global absolute root path
      global.root_path = path.resolve(__dirname + “/…/”);

      // The next part is here to prevent a major exception when there
      // is no internet connection. This could probable be solved better.
      process.on(“uncaughtException”, function (err) {
      console.log(“Whoops! There was an uncaught exception…”);
      console.error(err);
      console.log(“MagicMirror will not quit, but it might be a good idea to check why this happened. Maybe no internet connection?”);
      console.log(“If you think this really is an issue, please open an issue on GitHub: https://github.com/MichMich/MagicMirror/issues”);
      });

      /* App - The core app.
      */
      var App = function() {
      var nodeHelpers = [];

      /* loadConfig(callback)
       * Loads the config file. combines it with the defaults,
       * and runs the callback with the found config as argument.
       *
       * argument callback function - The callback function.
       */
      
      var loadConfig = function(callback) {
      	console.log("Loading config ...");
      	var defaults = require(__dirname + "/defaults.js");
      	var configFilename = path.resolve(global.root_path + "/config/config.js");
      	try {
      		fs.accessSync(configFilename, fs.F_OK);
      		var c = require(configFilename);
      		var config = Object.assign(defaults, c);
      		callback(config);
      	} catch (e) {
      		if (e.code == "ENOENT") {
      			console.error("WARNING! Could not find config file. Please create one. Starting with default configuration.");
      			callback(defaults);
      		} else if (e instanceof ReferenceError || e instanceof SyntaxError) {
      			console.error("WARNING! Could not validate config file. Please correct syntax errors. Starting with default configuration.");
      			callback(defaults);
      		} else {
      			console.error("WARNING! Could not load config file. Starting with default configuration. Error found: " + e);
      			callback(defaults);
      		}
      	}
      };
      
      /* loadModule(module)
       * Loads a specific module.
       *
       * argument module string - The name of the module (including subpath).
       */
      var loadModule = function(module) {
      
      	var elements = module.split("/");
      	var moduleName = elements[elements.length - 1];
      	var moduleFolder =  __dirname + "/../modules/" + module;
      
      	if (defaultModules.indexOf(moduleName) !== -1) {
      		moduleFolder =  __dirname + "/../modules/default/" + module;
      	}
      
      	var helperPath = moduleFolder + "/node_helper.js";
      
      	var loadModule = true;
      	try {
      		fs.accessSync(helperPath, fs.R_OK);
      	} catch (e) {
      		loadModule = false;
      		console.log("No helper found for module: " + moduleName + ".");
      	}
      
      	if (loadModule) {
      		var Module = require(helperPath);
      		var m = new Module();
      
      		if (m.requiresVersion) {
      			console.log("Check MagicMirror version for node helper '" + moduleName + "' - Minimum version:  " + m.requiresVersion + " - Current version: " + global.version);
      			if (cmpVersions(global.version, m.requiresVersion) >= 0) {
      				console.log("Version is ok!");
      			} else {
      				console.log("Version is incorrect. Skip module: '" + moduleName + "'");
      				return;
      			}
      		}
      
      		m.setName(moduleName);
      		m.setPath(path.resolve(moduleFolder));
      		nodeHelpers.push(m);
      	}
      };
      
      /* loadModules(modules)
       * Loads all modules.
       *
       * argument module string - The name of the module (including subpath).
       */
      var loadModules = function(modules) {
      	console.log("Loading module helpers ...");
      
      	for (var m in modules) {
      		loadModule(modules[m]);
      	}
      
      	console.log("All module helpers loaded.");
      };
      
      /* cmpVersions(a,b)
       * Compare two symantic version numbers and return the difference.
       *
       * argument a string - Version number a.
       * argument a string - Version number b.
       */
      function cmpVersions(a, b) {
      	var i, diff;
      	var regExStrip0 = /(\.0+)+$/;
      	var segmentsA = a.replace(regExStrip0, "").split(".");
      	var segmentsB = b.replace(regExStrip0, "").split(".");
      	var l = Math.min(segmentsA.length, segmentsB.length);
      
      	for (i = 0; i < l; i++) {
      		diff = parseInt(segmentsA[i], 10) - parseInt(segmentsB[i], 10);
      		if (diff) {
      			return diff;
      		}
      	}
      	return segmentsA.length - segmentsB.length;
      }
      
      /* start(callback)
       * This methods starts the core app.
       * It loads the config, then it loads all modules.
       * When it"s done it executs the callback with the config as argument.
       *
       * argument callback function - The callback function.
       */
      this.start = function(callback) {
      
      	loadConfig(function(c) {
      		config = c;
      
      		var modules = [];
      
      		for (var m in config.modules) {
      			var module = config.modules[m];
      			if (modules.indexOf(module.module) === -1 && !module.disabled) {
      				modules.push(module.module);
      			}
      			}
      
      		});
      	});
      };
      

      };

      module.exports = new App();

      i sobstitute this file that is in the js directory, the file is app.js, this is from the older version of magic mirror that casually i have saved but with this it works…
      i don’t know why but with the newer version of this file modules arent recognised…

      R 1 Reply Last reply Apr 12, 2017, 2:54 PM Reply Quote 0
      • R Offline
        robertoOk @robertoOk
        last edited by Apr 12, 2017, 2:54 PM

        i don’t know why but code is divided into blocks , copy all the text i have written minus my last comments at the end

        J 1 Reply Last reply Apr 12, 2017, 3:17 PM Reply Quote 0
        • J Offline
          johnnyboy @robertoOk
          last edited by johnnyboy Jun 10, 2017, 12:26 PM Apr 12, 2017, 3:17 PM

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • G Offline
            gismo2006
            last edited by May 28, 2017, 1:03 PM

            Hey, @robertoOk or anybody other. I got today exact the same problem. After updating to 2.1.1 my mm start whit a black screen. And npm write the same like @robertoOk write in his first post. If I cut this module out at the config.js. mm starts correctly.

            Greets gismo

            1 Reply Last reply Reply Quote 0
            • G Offline
              gismo2006
              last edited by Jun 2, 2017, 7:30 AM

              Ok, now I give up… :-D

              Can maybe someone whit some more coding experince help me to solve this problem??

              Greets gismo

              B 1 Reply Last reply Jun 12, 2017, 9:35 AM Reply Quote 0
              • F Offline
                fabrang
                last edited by Jun 7, 2017, 1:50 PM

                I have the same problem since two days. I tried some stuff but nothing worked.

                B 1 Reply Last reply Jun 12, 2017, 9:32 AM Reply Quote 0
                • B Offline
                  Berto1998 @fabrang
                  last edited by Jun 12, 2017, 9:32 AM

                  @fabrang i sobstitute the app.js file code with the older version and works

                  1 Reply Last reply Reply Quote 1
                  • B Offline
                    Berto1998 @gismo2006
                    last edited by Jun 12, 2017, 9:35 AM

                    @gismo2006 i sobstitute the app.js file code with the older version and works

                    1 Reply Last reply Reply Quote 0
                    • G Offline
                      gismo2006
                      last edited by Jun 14, 2017, 5:29 AM

                      @Berto1998 said in mm-music-player errors:

                      sobstitute

                      Hi @Berto1998 Perfect!!! But where do you find an older version??

                      greets gismo

                      B 1 Reply Last reply Jun 14, 2017, 7:12 AM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy