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

MMM-MplayerRadio

Scheduled Pinned Locked Moved Entertainment
46 Posts 7 Posters 11.7k 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.
  • E Offline
    electros Project Sponsor @wishmaster270
    last edited by May 4, 2020, 7:20 PM

    @wishmaster270 Ok, I find a easy way to play a web radio with xmms2 player from a executable .sh file for that I ask you to tell me how I can run that file from your module. Now is not working my radios with mplayer.

    1 Reply Last reply Reply Quote 0
    • W Offline
      wishmaster270 Module Developer
      last edited by May 4, 2020, 8:37 PM

      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 May 5, 2020, 7:55 AM Reply Quote 0
      • E Offline
        electros Project Sponsor @wishmaster270
        last edited by electros May 5, 2020, 7:57 AM May 5, 2020, 7:55 AM

        @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
        • W Offline
          wishmaster270 Module Developer
          last edited by May 5, 2020, 2:35 PM

          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
          • W Offline
            wishmaster270 Module Developer
            last edited by wishmaster270 May 5, 2020, 3:41 PM May 5, 2020, 2:58 PM

            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 May 6, 2020, 6:13 PM Reply Quote 0
            • E Offline
              electros Project Sponsor @wishmaster270
              last edited by May 6, 2020, 6:13 PM

              @wishmaster270 it’s working now thanks.

              W 1 Reply Last reply May 6, 2020, 6:16 PM Reply Quote 0
              • W Offline
                wishmaster270 Module Developer @electros
                last edited by May 6, 2020, 6:16 PM

                @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 May 6, 2020, 6:32 PM Reply Quote 0
                • E Offline
                  electros Project Sponsor @wishmaster270
                  last edited by May 6, 2020, 6:32 PM

                  @wishmaster270 Thank you

                  1 Reply Last reply Reply Quote 0
                  • B Offline
                    bryan_1 @wishmaster270
                    last edited by Sep 2, 2020, 7:50 PM

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

                    W 1 Reply Last reply Sep 4, 2020, 6:54 PM Reply Quote 0
                    • W Offline
                      wishmaster270 Module Developer @bryan_1
                      last edited by Sep 4, 2020, 6:54 PM

                      @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
                      • 1
                      • 2
                      • 3
                      • 4
                      • 5
                      • 3 / 5
                      • 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