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.

    MMM-MP3Player (remade asimhsidd's player)

    Scheduled Pinned Locked Moved Entertainment
    mp3 playermusic player
    14 Posts 5 Posters 4.4k 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.
    • X Offline
      x3mEr
      last edited by x3mEr

      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 and loop 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).

      Download

      1 Reply Last reply Reply Quote 0
      • E Offline
        emrah_asl
        last edited by

        Hi, How can I enable mp3 player only between 3 hours in a day ?

        05.00 AM - 08.00 AM

        X 1 Reply Last reply Reply Quote 0
        • X Offline
          x3mEr @emrah_asl
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • X Offline
            x3mEr
            last edited by

            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 in README.md
            1 Reply Last reply Reply Quote 0
            • J Offline
              Jonae
              last edited by Jonae

              i cant get notifications to start the player. Can you add an example? Thanks. How to use it with
              MMM-Remote-Control.

              S 1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @Jonae
                last edited by

                @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;
                

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                J 1 Reply Last reply Reply Quote 0
                • J Offline
                  Jonae @sdetweil
                  last edited by

                  @sdetweil i saw that, i send the notification and nothing happens…

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @Jonae
                    last edited by

                    @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 contain

                    blue arrow to run to next stop (if any)

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    J 1 Reply Last reply Reply Quote 0
                    • J Offline
                      Jonae @sdetweil
                      last edited by

                      @sdetweil thanks for the tipp, but nothing happens. like it is ignoring the notification, maybe remote control is not sending the right notification…

                      S 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @Jonae
                        last edited by

                        @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.

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        J 1 Reply Last reply 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