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-MplayerRadio

    Scheduled Pinned Locked Moved Entertainment
    46 Posts 7 Posters 18.6k Views 8 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.
    • wishmaster270W Offline
      wishmaster270 Module Developer
      last edited by

      It pushed a new development version to the repo.
      You can change to it if you do the following commands:

      cd ~/MagicMirror/modules/MMM-MplayerRadio
      git checkout development
      git pull
      

      In the new version you can add “customCommand” and “customCommandArgs” to either the whole module or to every station.
      You then can use any script you like to play either all stations (by passing the url to it) or a special script for each station.

      Example:

      		{
      			module: "MMM-MplayerRadio",
      			header: "Radio",
      			position: "top_center",
      			config: {
      				customCommand: "/home/pi/doSomething.bash",
      				customCommandArgs: ["one", "two", "###URL###"],
      				stations: [
      					{
      						title: "Antenne.de",
      						url: "http://www.surfmusik.de/m3u/antenne-bayern,922.m3u",
      						logo: "https://upload.wikimedia.org/wikipedia/commons/a/ac/Antenne-bayern-logo.png",
      						customCommand: "/home/pi/doSomethingElse.bash",
      						customCommandArgs: ["one", "###URL###", "three"],
      					},
      				],
      			},
      		},
      

      In this example for all stations the script “/home/pi/doSomething.bash one two http://…” is called.
      But “Antenne.de” uses the script “/home/pi/doSomethingElse.bash” with different args.

      The only condition the customCommand-Script needs to meet is that it stays active as long as the station is running and stops the playback if it gets killed.

      E 1 Reply Last reply Reply Quote 0
      • E Offline
        electros Project Sponsor @wishmaster270
        last edited by electros

        @wishmaster270 Now if I put this in the config file:

        {
        			module: "MMM-MplayerRadio",
        			header: "Radio",
        			position: "top_center",
        			config: {
        				customCommand: "",
        				customCommandArgs: ["", "", ""],
        				stations: [
        					{
        						title: "KissFM",
        						url: "",
        						logo: "https://upload.wikimedia.org/wikipedia/ro/8/86/Logo_Kiss_FM.png",
        						customCommand: "/home/pi/MagicMirror/modules/MMM-MplayerRadio/scripts/KissFM.sh",
        						customCommandArgs: ["", "", ""],
        					},
        				],
        			},
        		},
        

        and this in KissFM.sh

        #!/bin/bash
        
            xmms2 stop
        
           xmms2 clear
          
         
        xmms2 add https://live.kissfm.ro/kissfm.aacp
        
          xmms2 play 
        

        it’s working when i want to start radio but nothing happens when i touch the stop button just a short flickering of your module(I use a 10" touchescreen).
        Thank you.

        1 Reply Last reply Reply Quote 0
        • wishmaster270W Offline
          wishmaster270 Module Developer
          last edited by

          Hi,

          as i wrote in the documentation you need to make sure that your script runs as long as the station is active and needs to stop the playback if it gets a kill signal.
          Maybe i will find a short tutorial about catching the kill signal.

          1 Reply Last reply Reply Quote 0
          • wishmaster270W Offline
            wishmaster270 Module Developer
            last edited by wishmaster270

            If you change your script to (playRadio.bash):

            #!/bin/bash
            URL=$1
            RUN=1
            exit_script() {
                    echo "Stopping playback"
                    xmms2 stop
                    xmms2 clear
                    RUN=0
            }
            
            trap exit_script SIGINT SIGTERM
            
            xmms2 stop
            xmms2 clear
            xmms2 add $URL
            xmms2 play
            
            while [ $RUN -gt 0 ]; do
                    echo "Still running"
                    sleep 1
            done
            

            and the config to

            		{
            			module: "MMM-MplayerRadio",
            			header: "Radio",
            			position: "top_center",
            			config: {
            				stations: [
            					{
            						title: "KissFM",
            						url: "https://live.kissfm.ro/kissfm.aacp",
            						logo: "https://upload.wikimedia.org/wikipedia/ro/8/86/Logo_Kiss_FM.png",
            						customCommand: "/home/pi/MagicMirror/modules/MMM-MplayerRadio/scripts/playRadio.bash",
            						customCommandArgs: ["###URL###"],
            					},
            				],
            			},
            		},
            

            You can then reuse the same script for different stations only by adding the url as first parameter in the config

            Edit: Added url back to the config

            E B 2 Replies Last reply Reply Quote 0
            • E Offline
              electros Project Sponsor @wishmaster270
              last edited by

              @wishmaster270 it’s working now thanks.

              wishmaster270W 1 Reply Last reply Reply Quote 0
              • wishmaster270W Offline
                wishmaster270 Module Developer @electros
                last edited by

                @electros Perfect.
                I think I will check in the script into the repository so you can easy update to upcoming versions

                E 1 Reply Last reply Reply Quote 0
                • E Offline
                  electros Project Sponsor @wishmaster270
                  last edited by

                  @wishmaster270 Thank you

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    bryan_1 @wishmaster270
                    last edited by

                    @wishmaster270 Hi, I’m newbie and know almost nothing about coding. I have installed your module successfully, but what should I do to start it (without touchscreen)? It is shown on my mirror but not played. I put only one Station.
                    I want to start it automatically if I start my mirror.
                    Thanks.

                    wishmaster270W 1 Reply Last reply Reply Quote 0
                    • wishmaster270W Offline
                      wishmaster270 Module Developer @bryan_1
                      last edited by

                      @bryan_1 Hi, currently there is no autoplay feature implemented. But I will check it the next days. Maybe it is not a big deal

                      1 Reply Last reply Reply Quote 0
                      • wishmaster270W Offline
                        wishmaster270 Module Developer
                        last edited by

                        Hi,

                        just published an new version (0.0.3) which provides an autoplay feature. Simply add the station index you want to play to the config option “autoplay”. If you only configured one station it is 0. The station will start to play after about 1 second after the mirror started.

                        B 1 Reply Last reply Reply Quote 0
                        • ? Offline
                          A Former User
                          last edited by

                          hi @wishmaster270 ,

                          if you want me to create a vocal control with MMM-GoogleAssistant, just tell me.
                          I can create a special sub-code for your module

                          can do:

                          • volume control (no api found)
                          • change stations (next/previous/play/toogle,etc) from your api
                          wishmaster270W 1 Reply Last reply Reply Quote 0
                          • wishmaster270W Offline
                            wishmaster270 Module Developer @Guest
                            last edited by

                            @Bugsounet Hi, great idea. At the moment my mirror is only controlled by sensors and touch.
                            The volume control buttons of my module only send an notification to MMM-Volume that’s way there isn’t any api in this module.
                            Everything else can be controlled by notifications. There is a small section about the notifications in the readme.

                            1 Reply Last reply Reply Quote 0
                            • B Offline
                              bryan_1 @wishmaster270
                              last edited by

                              @wishmaster270 wow, vielen Dank :folded_hands:

                              1 Reply Last reply Reply Quote 0
                              • ? Offline
                                A Former User
                                last edited by A Former User

                                @wishmaster270 said in MMM-MplayerRadio:

                                The volume control buttons of my module only send an notification to MMM-Volume that’s way there isn’t any api in this module

                                ok so not needed because GA/A2D have native this function (volume control in vocal)
                                I can create quiclky an sample by I don’t know if you use my module

                                Edit:

                                the problem is I can’t send real name of the radio (it’s different with the google Server response)
                                so i will code :

                                SAY To GoogleAssistant NOTIFICATION Sended to MMM-MplayerRadio Function
                                Radio play RADIO_PLAY Playing first station
                                Radio stop RADIO_STOP Stop radio
                                Radio Next RADIO_NEXT Next Station
                                Radio Previous RADIO_PREVIOUS Previous Station

                                Of course all user can change you prefered ‘sentence’ for activate each wanted control

                                Edit 2:

                                [ASSISTANT] Command RADIO_PLAY is executed (notificationExec).
                                MMM-NotificationReceived.js:20 [Notification Sended From][MMM-GoogleAssistant] RADIO_PLAY {}
                                
                                [ASSISTANT] Command RADIO_STOP is executed (notificationExec).
                                MMM-NotificationReceived.js:20 [Notification Sended From][MMM-GoogleAssistant] RADIO_STOP {}
                                
                                [ASSISTANT] Command RADIO_PREVIOUS is executed (notificationExec).
                                MMM-NotificationReceived.js:20 [Notification Sended From][MMM-GoogleAssistant] RADIO_PREVIOUS {}
                                
                                [ASSISTANT] Command RADIO_NEXT is executed (notificationExec).
                                MMM-NotificationReceived.js:20 [Notification Sended From][MMM-GoogleAssistant] RADIO_NEXT {}
                                

                                Tell me if ok, in all case notification are sended.
                                sample of syntax used for send : this.sendNotification("RADIO_STOP")

                                For volume:
                                Vocal Control already coded with GA/A2D : volume 100% for exemple
                                make RPI volume to 100%
                                So don’t worry about this :)

                                Notes:
                                GA: MMM-GoogleAssistant
                                A2D: MMM-Assistant2Display
                                too long to write lol !

                                Sub-Code (recipe) is coded and commit in my dev branch

                                if some users want to test it

                                @bugsounet

                                wishmaster270W 1 Reply Last reply Reply Quote 0
                                • wishmaster270W Offline
                                  wishmaster270 Module Developer @Guest
                                  last edited by

                                  @Bugsounet Hi, thank you for your work. I checked the code, your notifications should work as planned. Play will start with the last station played or with the first one initially.

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

                                    Hi!

                                    my second post :)
                                    I’ve lost my first one somewhere , sorry if you read twice :) :)

                                    I’ve raspberry with AIY voice module , magic mirror software and a little touchscreen

                                    the touchscreen works good ( in the lego cabinet) with touch software like MMM-ModuleBar
                                    but I can’t use the buttons below the MMM-MplayerRadio , they seems dosn’t work or send notification

                                    the MplayerRadio module is working , and I really like hear the music from the module but i want to use the touch buttons too 😃

                                    i’ve used the “/etc/asound.conf” of your hints and the radio plays ok (with the “Pulse” configuration) but only if the trick below:

                                    I put the option DisplayStatioOnStartup: true and I click on the suggested radio

                                    (with this option = false, the radio dosn’t start or I cannot go in the menu with the radio display list)

                                    I’ve also installed MMM-Volume module too, but the volume button I suppose have the same problem of previous , play and next buttons

                                    Do you have any advice or hints or config example ?

                                    thanks for reading
                                    Roberto

                                    wishmaster270W 1 Reply Last reply Reply Quote 0
                                    • wishmaster270W Offline
                                      wishmaster270 Module Developer @robfer
                                      last edited by

                                      @robfer Hi, normally there is some other module covering the buttons in such cases.
                                      You can solve this by setting z-index in your custom.css.
                                      The higher the index the more in the foreground the module will be.

                                      The following config is part of my custom.css file:

                                      .MMM-ImagesPhotos, .MMM-ImageSlideshow, .MMM-COVID19, .MMM-Spotify, .MMM-Temperature, .MMM-LEDStripControl {
                                          z-index: -1;
                                      }
                                      
                                      .MMM-MplayerRadio {
                                          z-index: 999;
                                      }
                                      
                                      R 1 Reply Last reply Reply Quote 0
                                      • R Offline
                                        robfer @wishmaster270
                                        last edited by

                                        @wishmaster270
                                        thanks,
                                        you was right, the module newsfeed cover the buttons on my little screen

                                        hiding and showing it solve my problem, now i can use the radio and the volume buttons too :)

                                        maybe without use the custom.css
                                        but in this case a little extra question, if you know: can I put standard module newsfeed in the custom.css file? (I tryed but seems not work)

                                        wishmaster270W 1 Reply Last reply Reply Quote 0
                                        • wishmaster270W Offline
                                          wishmaster270 Module Developer @robfer
                                          last edited by

                                          @robfer Hi, sure you can. The right class will be “.module.newsfeed”

                                          1 Reply Last reply Reply Quote 0
                                          • T Offline
                                            totofar
                                            last edited by

                                            Hi,

                                            @bugsounet created notifications/patterns in his module MMM-GoogleAssistant to drive this module MMM-MplayerRadio.
                                            Did anyone manage to implement these commands in GoogleAssistant ? How does it work ?

                                            Thanks in advance

                                            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