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.

    Simple Music Player Module

    Scheduled Pinned Locked Moved Entertainment
    musicaudioplayer
    41 Posts 19 Posters 52.4k Views 21 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.
    • brobergB Offline
      broberg Project Sponsor @lucallmon
      last edited by

      @lucallmon either you change the directory in the players .js file or you link the music folder to the thumbdrive

      1 Reply Last reply Reply Quote 0
      • D Offline
        dbaler
        last edited by

        If you have a nas / networked storage and want to use music files from there, how would you do that?

        brobergB 1 Reply Last reply Reply Quote 0
        • brobergB Offline
          broberg Project Sponsor @dbaler
          last edited by

          @dbaler My higly noobish answer is Samba, and mount a network folder.

          D 1 Reply Last reply Reply Quote 0
          • D Offline
            dbaler @broberg
            last edited by

            @broberg Just change the directory in which JS file?

            brobergB 1 Reply Last reply Reply Quote 0
            • brobergB Offline
              broberg Project Sponsor @dbaler
              last edited by

              @dbaler If you are not using the default Music folder you could actually mount your network folder directly in that folder. No need to alter anything in the js files

              Here is a easy to follow tutorial on how you mount a smb share in linux :
              https://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/

              1 Reply Last reply Reply Quote 0
              • P Offline
                Preve @cowboysdude
                last edited by

                @cowboysdude Is that “show list” already available?

                1 Reply Last reply Reply Quote 0
                • aro28A Offline
                  aro28
                  last edited by aro28

                  Hi Eof,
                  Do you know why mm-music-player module is not loading even i added below code to config file? I downloaded and copied mm-music-player folder to MM’s Modules folder. Do i need to do something else?

                  {
                  module: ‘mm-music-player’,
                  position: ‘bottom_left’,
                  config: {
                  startingVolume: 20,
                  fadeDuriation: 2000
                  }
                  }

                  Thank you!

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    DrCastor
                    last edited by DrCastor

                    Hi aro28,

                    I had the same problem, so I decided to take a look at why this module couldn’t be loaded.

                    The issues is in the Node_Helper.js given, which is mistaken. The structure is wrong. It looks like a quick adaptation of a ctrl+C/ctrl+V made from index.js, found in the node_helper folder (MM core folders).

                    I’m actually tweeking it a bit. I’ll give you news when i get it worked nicely.
                    (In fact, it seems i can now load it, but since my speaker are broke, i cant be sure it reads files… I’ll change them tomorrow)

                    aro28A 1 Reply Last reply Reply Quote 0
                    • aro28A Offline
                      aro28 @DrCastor
                      last edited by

                      @DrCastor
                      Great! Thank you for reply. I hope you will succeed.

                      1 Reply Last reply Reply Quote 0
                      • D Offline
                        DrCastor
                        last edited by yawns

                        Ok, found bad speakers, but at least, they allow me to test it. It works :). I’m a real noob, so some useless things may still be there. But at least, it will do the trick

                        Go to the node_helper.js file, and change it this way:

                        var Class = require("../../js/class.js");
                        var express = require("express");
                        var path = require("path");
                        
                        
                        module.exports = NodeHelper.create({
                        
                        	init: function() {
                        		console.log("Initializing mm-music-player module helper ...");
                        	},
                        
                        	start: function() {
                        		this.expressApp.get('/music', function (req, res) {
                        			var fs = require('fs');
                        			var path = require('path');
                        
                        			var files = [];
                        
                        			fs.readdir('modules/mm-music-player/music', (err, data) => {
                        				for(i = 0; i < data.length; i++){
                        					if(path.extname(data[i]) == ".mp3"){
                        						files.push(data[i]);
                        					}
                        				}
                        				
                        				res.send(files);
                        			});
                        		});
                        	},
                        
                        
                        
                        	/* setExpressApp(app)
                        	 * Sets the express app object for this module.
                        	 * This allows you to host files from the created webserver.
                        	 *
                        	 * argument app Express app - The Express app object.
                        	 */
                        	setExpressApp: function(app) {
                        		this.expressApp = app;
                        
                        		var publicPath = this.path + "/public";
                        		app.use("/" + this.name, express.static(publicPath));
                        	},
                        
                        });
                        

                        If luck is by your side, it will work ;)

                        aro28A 1 Reply Last reply Reply Quote 0
                        • aro28A Offline
                          aro28 @DrCastor
                          last edited by yawns

                          @DrCastor said in Simple Music Player Module:

                          Hi,
                          Could you please send a full code of “node_helper.js” file?
                          Thanks in advance,

                          1 Reply Last reply Reply Quote 0
                          • D Offline
                            DrCastor
                            last edited by

                            It seems that I don’t have enough priviledges for uploading a file directly in this reply, and I don’t really want to provide you a link to some uploading site, since I don’t know if it is allowed in the rules of this site. I’ll try to find a way.

                            Since then, just try what I told you. You juste have to cut and paste what I wrote. I’m sure you can do it, be confident in yourself ;)

                            aro28A 1 Reply Last reply Reply Quote 0
                            • aro28A Offline
                              aro28 @DrCastor
                              last edited by

                              @DrCastor
                              Manay thanks!
                              Resolved.

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                DrCastor
                                last edited by

                                Happy to have helped you :). It is sad that just for a problem of syntax, the source file was never edited :$

                                aro28A 1 Reply Last reply Reply Quote 0
                                • aro28A Offline
                                  aro28 @DrCastor
                                  last edited by

                                  @DrCastor

                                  Last question.
                                  Do you know how to write a code for a volume buttons for that player?
                                  I know that “MMM-TouchPlayerBasic” module has that feature.

                                  1 Reply Last reply Reply Quote 0
                                  • D Offline
                                    DrCastor
                                    last edited by

                                    no, I’m a noob in this. You should take a look at the files of MMM-TouchPlayerBasic, and try to enderstand how the volume is managed. Good luck!

                                    1 Reply Last reply Reply Quote 0
                                    • M Offline
                                      Milk
                                      last edited by

                                      would it be possible to make it so I could use a keyboard to control the music?

                                      aro28A 1 Reply Last reply Reply Quote 0
                                      • aro28A Offline
                                        aro28 @Milk
                                        last edited by

                                        @Milk
                                        I use the built-in Monitor’s hard buttons to control the sound.
                                        There’s “alsamixer” command to control volume. But this is not convenient.

                                        1 Reply Last reply Reply Quote 0
                                        • M Offline
                                          Milk
                                          last edited by

                                          			'use strict';
                                          			var playingnow = false;
                                          			document.addEventListener('keypress', (event) => {
                                          				const keyName = event.key;
                                          				
                                          				if(keyName == " " && playingnow == false){
                                          					$(audioElement).trigger('play');
                                          					$(currentlyPlaying).html(songs[current]).fadeIn(fadeDuriation);
                                          					playingnow = true;
                                          				
                                          				}else if(keyName == " " && playingnow == true){
                                          					$(audioElement).trigger('pause');
                                          					$(currentlyPlaying).fadeOut(fadeDuriation);
                                          					playingnow = false;
                                          				
                                          				}
                                          				if(keyName == "."){
                                          					next();
                                          				}
                                          				if(keyName == ","){
                                          					back();
                                          				}
                                          			});
                                          

                                          I have added this code to the mm-music player.js and it now accepts key presses

                                          1 Reply Last reply Reply Quote 0
                                          • R Offline
                                            Rolandb
                                            last edited by

                                            Hi Guys,

                                            I have a problem with the MM-Music_player module.
                                            I just can not get it to work.
                                            No matter what I do. I’ve already tried with the proposed solutions from you, but it does not work.
                                            I do not even know if I have the module installed correctly nor where I need to add it everywhere (config.js, defaultmodules.js)

                                            I am grateful for any help.

                                            aro28A 1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 3
                                            • 2 / 3
                                            • 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