- If I combine decaf and regular coffee, how is the caffeine distributed in the cup?
- Electron drift velocity
- How to derive that $pV^k$ is constant in a polytropic process?
- Determine total turns $N_g$ before the coin slips from the rotating horisontal disk
- can you destroy the sun if you throw enough iron into it?
- How to find the Normal force imparted?
- If M=2.0kg, what is the tension in string 1 on the picture below?
- What is $z$ in the Bose gas?
- What's do critical about the critical density of the Universe
- Can you tap artifacts to an improvise cost to help pay for kicker costs?
- How do I play Z.O.D.?
- “Install overnight” option does not apply update over night
- How can I use a bluetooth controller to skip back/forward a video 5/10 seconds?
- Physical Device does not show up in Android Device Chooser
- Honor 7 Boot-loop after changing display+frame
- Inside of 2.4 GHz Dipole Antenna
- Decoding waveform from RFID 125 khz reader
- Output impedance function generator, limiting the current
- 3.7V battery charger analyse
- PCB layer stack up practices
Need a GPIO button to stop the currently playing mp3 file
I am using a RPi3 in a museum to connect to 2 buttons via GPIO. Each button plays an mp3 file.
I used the Adafruit guide here: https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/overview
and everything works as advertised. However, the files are around 30 minutes long, and if the person starts playing one track, gets a few minutes then realizes they want to play the other track, they can't. The first file has to play to the end, and only then can the second button be pushed.
So what I want to do if possible is to add a 'stop' button, a third button which, when pressed stops whichever track is playing, and allows the other track to be chosen.
Or better still, when either of the 2 buttons is pushed to select a track, it stops whatever track is already playing.
Below is the python script I'm using.
from time import sleep
import RPi.GPIO as GPIO