RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login

    Background Music [Continued from Help/Support]

    Scheduled Pinned Locked Moved General Discussion and Gaming
    musicbgm
    343 Posts 109 Posters 325.6k Views
    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.
    • synackS
      synack @ZingZonZot
      last edited by synack

      @ZingZonZot Yeah, the script was intended to start playing music as soon as the emulationstation screen comes up. If you want to delay that from happening, you can use the following line (replacing the other mpg123 command) in the autostart.sh file

      (sleep 10; mpg123 -Z /home/pi/bgm/*.mp3 >/dev/null 2>&1) &
      

      Here, you would adjust the sleep amount to the desired amount.

      1 Reply Last reply Reply Quote 0
      • Z
        ZingZonZot
        last edited by ZingZonZot

        @synack, Alright, awesome I'll try it out thanks for the help man! I'm trying to get this done before Christmas making my brother a retropie box, and at the same time getting calls from clients to been busy lol.

        Btw I start a game the music stops but in game audio is cut off.. 🤔

        Z 1 Reply Last reply Reply Quote 0
        • S
          smellslikekimchi
          last edited by

          I'm new to the community so I'd first like to say thank you all for sharing your knowledge with us newbies. It definitely helps us a ton and I personally really appreciate it. Introductions aside, I just had a simple question before I go ahead with this process, will the music stop when ES goes to standby/sleep mode? I will have my Retropie on at all times. I read the entire thread and didn't see anything about standby. Thank you!

          Z 1 Reply Last reply Reply Quote 0
          • Z
            ZingZonZot @smellslikekimchi
            last edited by ZingZonZot

            @smellslikekimchi I can confirm that, I just quit EMU station and the music stops as soon as it goes back to the CLI, but upon restarting EMU station it still plays.

            S 1 Reply Last reply Reply Quote 0
            • S
              smellslikekimchi @ZingZonZot
              last edited by

              @ZingZonZot thank you for the instant reply! So to be clear, it stopped when you shut down ES? I was actually referring to when you just let it sit for a while and it goes to sleep.

              synackS Z 2 Replies Last reply Reply Quote 0
              • synackS
                synack @smellslikekimchi
                last edited by synack

                @smellslikekimchi the short answer is no, it will keep playing and since that dimming/sleep mode is not externally indicated.

                S 1 Reply Last reply Reply Quote 0
                • Z
                  ZingZonZot @smellslikekimchi
                  last edited by

                  @smellslikekimchi yes, it stopped when shutdown emulation station but like @synack said it doesn't when it's in sleep mode.

                  1 Reply Last reply Reply Quote 0
                  • S
                    smellslikekimchi @synack
                    last edited by

                    @synack @ZingZonZot aha, thank yall for this. I will hold off until I can figure out a way to have it stop on sleep. I'm new to this so it may take me a while. I'm curious, at cursory glance at Livewire's code do you think it would pause music during sleep?

                    synackS 1 Reply Last reply Reply Quote 0
                    • synackS
                      synack @smellslikekimchi
                      last edited by

                      @smellslikekimchi sorry, but no -- it would not stop.

                      S 1 Reply Last reply Reply Quote 0
                      • S
                        smellslikekimchi @synack
                        last edited by

                        @synack roger that. Thank you for your help

                        1 Reply Last reply Reply Quote 0
                        • Z
                          ZingZonZot @ZingZonZot
                          last edited by

                          nevermind I solved my own game sound issue, @synack Thank you for your help I really appreciate it, man!

                          1 Reply Last reply Reply Quote 1
                          • K
                            karmakode @synack
                            last edited by

                            @synack good stuff man i was able to get this to work but i noticed whenever i try to go to retropie setup in the menu the screen goes black and i cant see anything but can hear the music still.....Did i do something wrong?

                            1 Reply Last reply Reply Quote 0
                            • K
                              karmakode @synack
                              last edited by

                              @synack nevermind i was ssh into the pi at the same time. thats why i was getting a blank screen. it would be awesome if there was a way to get different music when your in each system like recallbox

                              1 Reply Last reply Reply Quote 0
                              • R
                                raspy+
                                last edited by

                                @synack

                                thank you very much for this wonderful method!

                                if I was to type "emulationstation" at the command-line can I get the player to start again or do I have to reboot to autostart the process?

                                Thanks,

                                synackS 1 Reply Last reply Reply Quote 0
                                • synackS
                                  synack @raspy+
                                  last edited by

                                  @raspy+ You can either reboot or execute the autostart.sh script which will invoke the mp3 player as well as emulationstation.

                                  /opt/retropie/configs/all/autostart.sh
                                  
                                  R 1 Reply Last reply Reply Quote 0
                                  • R
                                    raspy+ @synack
                                    last edited by raspy+

                                    @synack

                                    thanks for your quick response! ... I did a little poking around on the internet and even read up on how to make a basic shell script since I am such a noob. I just end up modifying the existing (/usr/bin/emulationstation) script by adding your script before "clear" and after "reset" like so and I can launch "emulationstation" with the same results from command-line:

                                    #!/bin/bash

                                    if [[ $(id -u) -eq 0 ]]; then
                                    echo "emulationstation should not be run as root. If you used 'sudo emulationstation' please run without sudo."
                                    exit 1
                                    fi

                                    if [[ "$(uname --machine)" != 86 ]]; then
                                    if [[ -n "$(pidof X)" ]]; then
                                    echo "X is running. Please shut down X in order to mitigate problems with losing keyboard input. For example, logout from LXDE."
                                    exit 1
                                    fi
                                    fi

                                    while pgrep omxplayer >/dev/null; do sleep 1; done
                                    mpg123 -Z /media/usb0/music/*.mp3 2>/media/usb0/music/playlist &

                                    clear
                                    tput civis
                                    "/opt/retropie/supplementary/emulationstation/emulationstation.sh" "$@"
                                    reset

                                    pkill mpg123

                                    EDIT: I forgot to mention that even though I can execute the "autostart.sh" script to achieve the same thing however I have Kodi booting first and I wanted to just launch emulationstation when I am at the command-line.

                                    Thanks,

                                    S 1 Reply Last reply Reply Quote 1
                                    • M
                                      MoMan_
                                      last edited by

                                      Audio continues playing when running ">ports_" games (Super Mario War, at least).

                                      What would I add to the script to kill audio when playing ported games?

                                      1 Reply Last reply Reply Quote 1
                                      • S
                                        smellslikekimchi @raspy+
                                        last edited by

                                        @raspy+ Thank you for this update. This in conjunction with @synack 's tutorial gave me exactly what I wanted except for one small question:

                                        When I exit a game the menu music comes back on immediately when I exit to the game select screen. How do I add a bit of delay or "sleep" until the music starts back up again?

                                        Thanks!

                                        synackS 1 Reply Last reply Reply Quote 0
                                        • synackS
                                          synack @smellslikekimchi
                                          last edited by

                                          @smellslikekimchi

                                          to force a delay, edit /opt/retropie/configs/all/runcommand-onend.sh and instead of

                                          pkill -CONT mpg123
                                          

                                          use

                                          (sleep 2; pkill -CONT mpg123) &
                                          

                                          Of course, adjust the sleep # to your heart's desire.

                                          S 1 Reply Last reply Reply Quote 0
                                          • S
                                            smellslikekimchi @synack
                                            last edited by

                                            @synack you are a king among peasants. This worked like a charm. Thank you again for your help.

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

                                            Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.