Read the statement by Michael Teeuw here.
MMM-MP3Player (remade asimhsidd's player)
-
Hi, community!
I present a MagicMirror module for playing music from folder.
This is the version of the asimhsidd’s MMM-MP3Player module remade to my needs.
@asimhsidd, thank you very much for so beautiful player!Differences:
- my version play music from
path
, not USB; - besides .mp3, supports .wav and .flac;
- has
autoplay
,random
andloop
options; - can be controlled with notifications;
- only supports rock music.
It was a first time I have ever worked with JavaScript. I know nothing! I just wanted working mp3 player for my mirror. After unsuccessful installations of several modules, I decided to remade asimhsidd’s player.
P.S.: thank you, MichMich, for so cool project and community. Thank you, @sdetweil, for your numerous responses and hints and for helping module developers. I just want you to know you helped a lot of people (not only in this forum).
- my version play music from
-
Hi, How can I enable mp3 player only between 3 hours in a day ?
05.00 AM - 08.00 AM
-
@emrah_asl, Hi. This module does not provide such opportunity. I think you should search module that can turn on/off or hide other modules on time.
-
UPD:
Version 1.2.0 - 2020.09.14
- Now player displays album cover. It tries to retrieve the image from ID3-Tags, if nothing found, it searches file
cover.jpg
in the playing music file directory. - add: turn random on/off over notifications.
more inREADME.md
- Now player displays album cover. It tries to retrieve the image from ID3-Tags, if nothing found, it searches file
-
i cant get notifications to start the player. Can you add an example? Thanks. How to use it with
MMM-Remote-Control. -
@jonae looks like from the code, it can play music that is defined in the config.
case "PLAY_MUSIC": if (audioElement.paused){ audioElement.play(); } else { self.sendSocketNotification("LOADFILE", self.songs[self.current]); } break; case "STOP_MUSIC": audioElement.pause(); break; case "NEXT_TRACK": if(!self.musicFound){ self.album_art.classList.toggle('active'); return; } if (self.config.random){ if (!arrPlayed.includes(false)){ arrPlayed.fill(false); } do { ind = Math.floor(Math.random() * self.songs.length); // (self.current + 1) % self.songs.length; } while (arrPlayed[ind] || ind == self.current); // ind == self.current: not to play one song twice - in the end of list and in the beginning of newly created list) arrPlayed[ind] = true; self.current = ind; } else { if(self.current==(self.songs.length-1)){ // this assures the loop self.current = -1; } self.current++; } self.sendSocketNotification("LOADFILE", self.songs[self.current]); break; case "PREVIOUS_TRACK": if(self.current==0){ // this assures the loop self.current = (self.songs.length); } self.current--; self.sendSocketNotification("LOADFILE", self.songs[self.current]); break; case "RANDOM_ON": self.config.random = true; break; case "RANDOM_OFF": self.config.random = false; break;
-
@sdetweil i saw that, i send the notification and nothing happens…
-
@jonae do you have the music defined in config?
u can use the developers window, sources tab to walk thru the modules code
ctrl-shift-i, select the sources tab, find the module and its js file, will show to the right
click the line number in the left edge where the notificationReceived is
then send your notification and it shoudl stop there, then the circle arrow, is step instruction
and u can hover over the variables to see what they containblue arrow to run to next stop (if any)
-
@sdetweil thanks for the tipp, but nothing happens. like it is ignoring the notification, maybe remote control is not sending the right notification…
-
@jonae notification is a text string
notification is just a text string, here its ‘PLAY_MUSIC’
u have to configure that as remote doesn’t have it built in.