Proposal: antiX Radio Player GUI

Forum Forums antiX-development Development Proposal: antiX Radio Player GUI

  • This topic has 270 replies, 12 voices, and was last updated Jan 16-8:31 pm by Robin.
Viewing 15 posts - 16 through 30 (of 271 total)
  • Author
    Posts
  • #125520
    Member
    Wallon

      Dear ChPol,

      Your message wasn’t displayed on the screen when I posted my text on the forum.
      Would you please add your new radio list to version V032?

      Kind regards,
      Wallon

      #125526
      Member
      Robin

        I like it too, really, but I still have some remarks.

        While just starting it to listen and add some stations from my country, miniradio v031 has ruined a live recording I was just running in the background. How could this happen? Looking into the script code makes clear the problem immediately:

        # Function to kill mpv, the media player that plays the audio streams
        tuer_mpv(){
        	killall mpv 2>/dev/null
        }

        This function kills all running instances of mpv, regardless whether they belong to this miniradio or not. Please never do something like that within a script!
        Simplicity in your code never must cause affecting other programs running.

        And this function obviously is called at startup already, killing all mpv instances, working in background on other tasks, unexpectedly the very moment you start this script.

        Besides this really bad issue it works fine here, on antiX 23 full runit 32 bit and antiX 23 full runit 64 bit.

        Many thanks for creating it.

        Attached a stations list (FTA stations only) for de_DE, still pretty incomplete, only main „öffentlich-rechtliche” stations. Would be interesting whether the streams can be received from outside Germany. Feel free to include it, I have gathered the stations URL addresses from the public official stations websites (added comments to the list for easy maintenance in case addresses will be changed, so maintainer can easily look up the new URLs.) I guess the script needs to be crafted to handle comments lines starting whith a sharp sign (#) in the lists, or just delete the comments I’ve added, but then maintenance will be difficult and time consuming in future.

        ————-
        Edit says: Sorry Wallon, the message containing your 032 version wasn’t present still when I started writing this posting some hours ago, so I only ran 031.

        Attachments:

        Windows is like a submarine. Open a window and serious problems will start.

        #125532
        Member
        Robin

          Proposal for fixing the bug in this script (sketch only)

          1.) Before starting “your” mpv instance, check which mpv are running already, store the pids to a variable.

          $ pidof mpv
          206197 195178

          2.) Then start “your” mpv instance within the script, and immediately recheck (it is most unlikely the user starts another mpv himslelf the very moment he clicked the play button within the script, so I guess this can be neglected.)

          $ pidof mpv
          214733 206197 195178

          3.) Now compare the two lists, and the new pid belongs to “your” mpv. Store it to a variable, so you can safely close “your” mpv later, without affecting any other running mpv instances, notwithstanding that user is running other mpv instances before or after the miniradio was started.

          In my example you can safely kill 214733.

          Another equivalent fix could be to access mpv by it’s API. (option -​-input-ipc-server=…, see how I’ve solved this in aCSTV) but I think accessing mpv this way is more complex than just making sure to catch the proper pid always when starting it from within your script.

          Attached: Updated de_DE stations list file (DLF was missing). Again, script should ignore comments and blank lines while reading stations lists, so one can add some info about where to get updates for the entries from later.

          Attachments:

          Windows is like a submarine. Open a window and serious problems will start.

          #125554
          Member
          blur13

            Here is another way. This is just a general idea for how to kill a particular pid, I havent looked at the actual radio script.

            mpv &
            echo "$!" > /tmp/mpv.pid
            # $! contains the process ID of the most recently executed background pipeline 
            pid=$(cat /tmp/mpv.pid)
            if [ "$(ps -o comm= -p "$pid")" = "mpv" ]; then
               kill $(</tmp/mpv.pid)
               
            fi
            # this checks that the process ID is in fact mpv, ie the pid has not been reassigned
            #125569
            Member
            Robin

              Some more radio lists, URL’s picked from the official public stations websites.

              de_AT
              de_CH
              fr_CH
              it_CH

              Found these Swiss and Austrian stations connecting properly from Germany. So @Wallon the fr_CH might find your special interest, I guess the stations will work also for Belgium.
              Probably somebody from Switzerland and Austria might want to add some more stations to the lists, this is just a beginning.

              @Blur13 You are right, checking whether the pid wasn’t reassigned before killing is essential. Should have already mentioned it. Still there is a (in my opinion neglectable) possibility the pid was reassigned to another mpv instance (not by miniradio) accidentally in the meantime. This could only happen if user killed miniradio’s mpv instance from elsewhere, and started another mpv instance on his own for another task. Even then it is most unlikely (but not impossible) the very pid hits.

              Windows is like a submarine. Open a window and serious problems will start.

              #125581
              Member
              Robin

                And another one, for people speaking Lëtzebuergesch (or do like pop music)

                lb_LU

                Again, Luxembourger using antiX might add some more stations they know.

                Attachments:

                Windows is like a submarine. Open a window and serious problems will start.

                #125596
                Member
                Robin

                  Again some more lists, this time Nederlandse taal from Holland (the Netherlands), det danske sprog from Denmark, and British English from the UK (BBC and BFBS by now)

                  nl_NL
                  da_DK
                  en_GB

                  Btw, is it en_GB or en_UK ? Following ISO-3166-1 it should be GB, but UK is also mentioned in this standard as an alternative (which should not be used). Not sure about what debian and antiX expects here.

                  Be aware of the comments, current miniradio can’t deal with them so you’ll have to remove all blank and comment lines before using. Btw, it’s probably a good idea to add a comment line with a record of date of last update of it’s entries for each section in it.

                  @PPC and @ChPol :
                  Please replace (count as found in ver 032) of this script the line 93

                  93 done <$radios

                  by the following additional simple sed expression to allow comment lines starting with a sharp sign and also blank lines in the stations list files:
                  93 done <<<$(sed '/#.*\|^[[:space:]]*$/d' "$radios")

                  Then all the comments lines in my stations lists don’t need to get removed any longer.

                  And then I just found out: Many stations transfer icy-titles (whatever that might be) as file tags, so if the script would read these from mpv it could actually display what’s just playing. That would be a really nice-to-have feature. Here an example log from command line:

                  $ mpv 'http://live-icy.gss.dr.dk:8000/A/A04H.mp3'
                   (+) Audio --aid=1 (mp3 2ch 48000Hz)
                  File tags:
                   icy-title: DR P2  dr.dk/p2
                  AO: [pipewire] 48000Hz stereo 2ch floatp
                  A: 00:08:46 / 00:08:56 (98%) Cache: 9.7s/587KB
                  File tags:
                   icy-title: Requiem op 48 - In paradisum / Gabriel Fauré, Paris Operaorkester, Laurence Equilbey
                  A: 00:11:19 / 00:11:29 (99%) Cache: 9.8s/592KB
                  File tags:
                   icy-title: DR P2  dr.dk/p2
                  A: 00:12:15 / 00:12:25 (99%) Cache: 9.8s/592KB
                  File tags:
                   icy-title: Jeg har sat mig her ved det bageste bord (Alternativ Version) / Det Glemte Kvarter, Søren Ulrik Thomsen
                  A: 00:12:25 / 00:12:35 (99%) Cache: 9.8s/592KB
                  File tags:
                   icy-title: Jeg har sat mig her ved det bageste bord / Det Glemte Kvarter, Søren Ulrik Thomsen, Trine Dyrholm
                  A: 00:13:58 / 00:14:08 (99%) Cache: 9.8s/591KB
                  File tags:
                   icy-title: DR P2  dr.dk/p2
                  A: 00:16:37 / 00:16:47 (99%) Cache: 9.8s/592KB
                  File tags:
                   icy-title: 6 Klaverstykker op 118 - Intermezzo es-mol / Johannes Brahms, Paul Lewis
                  A: 00:20:45 / 00:20:55 (99%) Cache: 9.8s/592KB
                  File tags:
                   icy-title: DR P2  dr.dk/p2
                  A: 00:22:27 / 00:22:37 (99%) Cache: 9.8s/595KB
                  File tags:
                   icy-title: Symfoni nr 6 - Intermezzo. Larghetto - / Valentin Silvestrov, Stuttgarts Radiosymfoniorkester, Andrey Boreyko
                  A: 00:26:52 / 00:27:02 (99%) Cache: 9.8s/592KB

                  This log is from Denmarks Radio (DR) P2.

                  Windows is like a submarine. Open a window and serious problems will start.

                  #125607
                  Member
                  Robin

                    Spent a bit of time on this script this morning.

                    Ver. 0.33 is now able to record the stream. (Have “stolen” the method from my own aCSTV script and transferred it here)
                    Please feel free to improve the unique file name generation (I have implemented it simply by adding a timecode formatted in seconds to each new recording; furthermore no target directory selection, so if user has no write permission in the directory the script was called from the recording will fail silently.)

                    The file format is .ts which means the stream is simply stored to the file in the format a particular station comes along with. Sometimes this will be mp3 encoded, sometimes aac or whatever. MPV can play them without any conversion or renaming, so I suggest this file format should be set to open with mpv by default in antiX zzzFM to avoid users getting confused how to play.
                    (You could improve this by checking whether we can derive the format of the stream received by its name, and use in these cases the respective file name extension instead of .ts, using the latter only for cases when it is not possible to determine the true streaming format a station uses. MPV isn’t able to do a live conversion to a fixed output format if the stream received is different; if you use something other than .ts the input format (from stream) must match the requested (by filename extension) output format, otherwise the recording fails silently.) But I reckon .ts format is fine for us.

                    If user still want to do a conversion or to package the stream into a container like mp3, mka, m4a or whatever afterwards, you can use ffprobe to check out what format actually is stored in the .ts file and decide then whether you need to re-encode or only let ffmpeg copy the stream into a container of your choice. This is nothing what could be done on the fly while recording, since real time audio processing needs lots of cpu power and is simply not possible in most cases.

                    And now you can click the radiobuttons without having a selection bar pointing to another entry of the list which was pretty confusing. I’ve also added the sed expression to the script mentioned in my posting above.

                    Zip archive includes all the above European stations list files, and also the .pot file @Wallon has created. Now it has two additonal entries to translate.
                    Please feel free to add all your .po and .mo file translations to the locale directory structure I have put into the zip. Once it is ripened to a stable UI, I’ll put the ressource to transifex for further translation, either to antiX-development (I’d prefer this) or to antiX-community-contributions, whatever suits best.

                    Not fixed in 0.33: The issue with killing other mpv instances. This bug needs to get addressed urgently.

                    @ChPol and @PPC I hope you like my additions to your script. If not, feel free to discard them.

                    Windows is like a submarine. Open a window and serious problems will start.

                    #125620
                    Member
                    Robin

                      So, here’s another one, version 0.34

                      Now it has got a “what’s just playing” window as drafted some postings above.
                      You may want to make this feature optional by binding it to an additional button or checkbox in the GUI, since it takes some time to process the transferred pieces of information.

                      @blur13 In this version you can see why I had in mind the solution with grepping for the pids to a list before and after the mpv command was executed. Actually you also can’t use the $! expansion here. It is precisely the same issue as with yad, refusing to close when catching the pid this way. I had written about this issue two years ago, but didn’t get useful answers for a more elegant method. Man yad itself claims to provide an environment variable $YAD_PID, but I was never able to read this variable from within a script. Maybe somebody more skilled in programming than me can solve this. I have implemented my old method for getting the proper yad pids now here again to close the additional window when stopping the player.
                      See 0.34 version of this script to learn how I have my dirty workaround implemented. At least it works, both for yad and mpv. Maybe this is something special with antiX, since nobody seems to know this issue. We’ll have to find out.

                      Finally fixed: The killing other mpv instances issue.
                      Now it reads out its mpv pids when mpv is invoked, and stores it to a private config folder, which is read on next startup. If the very pid is still present, and also belongs still to mpv, let’s assume it was owned by miniradio before already, so we can kill it. (We could even wait until another button is pressed, this behaviour can be fine tuned later). On powering off or pausing the player the temp file is removed, since in this case on next startup there is nothing to be killed.

                      Single thing left: the new “What’s currently playing” window has to be closed manually by now if miniradio was re-opened while playing, it needs to be treated similar to the mpv process by using a temp file for storing its pid, so it can get closed along with mpv. And for sure, you could make this time consuming task optional by adding a checkbox user can check if he wants to see this additional window.

                      Windows is like a submarine. Open a window and serious problems will start.

                      #125632
                      Member
                      ChPol

                        Arriving well after Robin, as is often the case.

                        To fix kill
                        I give a signature to the mpv launched by the radio and then kill the mpv that has that signature.
                        (uses specific log file “rd antiX”)

                        I’ve changed the sequence when you use the window to select a list, so that it doesn’t cut off the radio, and when you cancel without selecting a file, you continue with the general window: you only exit the program via the quit button, which is more logical.

                        I’m out of the flow, I’m putting in an alpha version: it’s up to PPC to decide whether this should be integrated into the latest version or dropped.

                        I have no opinion on the recording function. (Sorry to Robin for destroying his work in progress, I hadn’t thought of that). We shouldn’t add a function to make coffee, it will end up scaring users…

                        Ch’Pol

                        #125636
                        Member
                        Wallon

                          Dear ChPol,

                          I’ve managed to launch “miniradio-alpha.zip” several times with zzzfm. I therefore had 2 radios transmitting sound at the same time.
                          I can’t turn “miniradio” off.
                          I have to restart the session to turn off the radio sound.

                          Kind regards,
                          Wallon

                          #125639
                          Member
                          Robin

                            Hello ChPol,

                            mpv --log-file=/tmp/rd antiX ...
                            This is a really elegant way to overcome the issue MPV not giving us back proper pid from bash expansion “$!”, since you have simply introduced a marker this way which makes unmistakable clear which mpv can get killed safely. I guess this is more reliable than my approach with generating two lists (and even more elegant than asking mpv for it’s pid using it’s ipc server socket providing the get_property method for the property “pid” which would be also possible)

                            Sorry to Robin for destroying his work in progress, I hadn’t thought of that

                            That’s not destroying, that’s improving 🙂 I’m sure we’ll integrate together with @PPC the best snippets from what all of us provide here so it will be a radio tailored perfectly to meet the antiX standards: mean, lean, as simple as possible while still providing as much convenience as possible without going bloated.

                            Concerning the recording function: This is a single additional button labled “Record”. Everybody who knows to use a radio cassette recorder will immediately know what to do with it. Just press the button, wait until recording was done, and press any other button when you want to end the recording. From point of view of the user it is actually that simple, so no reason to be afraid of scaring users from this.

                            I think a recording function is a must-have for an true antiX radio.

                            Btw, the oversimplified sed json parser I had written for the “What’s playing now” window needs to get improved a bit (or replaced by another json parsing solution). While it works fine on many stations (e.g. from the lists from Norway, Germany, etc.) it fails on British stations (BBC in particular) and also partly on Belgian French stations, displaying not the expected content in the window and window title. There are some approaches I’ll have to check out what works best. Either a more complete separate bash parsing function using more complex sed expressions, or some lines of python code integrated in the bash script, using the python json parser module. See https://stackoverflow.com/questions/1955505/parsing-json-with-unix-tools/26655887#answer-1955555 (FAQ section)
                            This window is a “nice-to-have” if we can make it work fast and reliable both.

                            So, let me try to port your recent work to the current 0.34, this will result in a 0.34a version then, comming soon. Then you’ll be back in flow.

                            Best regards
                            Robin

                            Windows is like a submarine. Open a window and serious problems will start.

                            #125640
                            Member
                            Robin

                              I can’t turn “miniradio” off.
                              I have to restart the session to turn off the radio sound.

                              Hello Wallon,
                              Many thanks for sharing your experience.
                              We’ll have to investigate how this can get prevented before heading for the method used in the alpha version.
                              Let me venture a guess: we have simply to ask the window manager at startup of the script whether another instance of antiX radio is running already.

                              Btw, have you tried the fr_CH list meanwhile?
                              We will have to add some more lists still…

                              Any comments on the recording function found in 0.34 ? Please don’t forget to associate the filetype .ts to MPV as default in zzzFM, then the recordings will play by just clicking them.

                              Windows is like a submarine. Open a window and serious problems will start.

                              #125645
                              Member
                              Robin

                                Dear @ChPol,
                                here the merged new 0.34a version, containing all your provisions to keep other instances of mpv from being closed, while I have removed all my lines dealing with the same issue. Moreover all your other changes (like radio_mem) have been transferred, so I guess you are back in the flow now.

                                Turned out your excellent method works way faster than my approach comparing two lists, and what I can see it is functionally absolutely equivalent.

                                Please check whether I have lost something from your new lines (hopefully this didn’t happen, meld shows it should be fine). Just bark up if it has happened nevertheless.

                                If you’d like to work on a solution for the issue found by @Wallon, please don’t hesitate.

                                I therefore had 2 radios transmitting sound at the same time.
                                I can’t turn “miniradio” off.

                                I guess a simple check whether an instance of the very script is running already at startup will do the trick. While you work on this (so we won’t do it duplicate) I’ll ponder about how to deal with parsing the json properly, coming from mpv ipc server socket. Need just to read the icy-title and icy-name fields from it. And I’ll think also about how to speed up this info processing a bit. I guess we won’t have to wait for the info window to come up before the main window can get restored.

                                Kind regards
                                Robin

                                Windows is like a submarine. Open a window and serious problems will start.

                                #125666
                                Member
                                ChPol

                                  Hello Robin,

                                  I added a temporary file at launch “/tmp/rd_runing”; killing the old instance was too complicated (for me). And this way it’s very fast.
                                  I updated two radio lists.

                                  The display of tracks currently playing is really nice.
                                  However, at home, it’s so slow that you wonder if you’ve actually clicked on play (it’s an old machine).
                                  Perhaps there should be a system for disabling the function on older computers?
                                  There are many radios where this doesn’t work, among those I’ve tried.

                                  I hope you’ll succeed in making the display more responsive. Perhaps it’s possible to display the windows by starting the music (or whatever), then do the work of formatting the data and displaying them 5 or 10 seconds later.

                                  It’s a real plus if you can do it.

                                  Ch’Pol

                                  PS: new version 034b

                                  • This reply was modified 2 months, 3 weeks ago by ChPol.
                                  • This reply was modified 2 months, 3 weeks ago by ChPol.
                                Viewing 15 posts - 16 through 30 (of 271 total)
                                • You must be logged in to reply to this topic.