However I can't manage to stop the mp3 before it's completly finished to play.
I'm putting bellow my current code, the goal of this exercice would be that the mp3 play when I'm pushing the button and stop when I'm not.
#include <Process.h>
Process p;
void setup() {
Bridge.begin();
Serial.begin(9600); // Initialize the Serial
while (!Serial); // Wait until a Serial Monitor is connected.
}
void loop() {
if (Serial.available() > 0) {
int inByte = Serial.read();
//Serial.write(inByte);
switch (inByte) {
case 'p':
Serial.println("Play:");
p.runShellCommandAsynchronously("/usr/bin/madplay /mnt/sda1/track39.mp3");
break;
case 's':
Serial.println("Stop:");
p.runShellCommandAsynchronously("/usr/bin/killall -9 madplay");
break;
case 'r':
Serial.println("Repeat Play:");
p.runShellCommandAsynchronously("/usr/bin/madplay /mnt/sda1/track39.mp3 -r");
break;
}
}
}
For each file, madplay will also attempt to read and display ID3 tag
information. The supported tag versions are ID3v1, ID3v1.1, ID3v2.2,
ID3v2.3, and ID3v2.4. If a tag contains relative volume adjustment
information (RVA2), madplay will use the information to adjust the
master volume for output. This behavior can be changed with the -A
(--adjust-volume) and -G (--replay-gain) options.
::::SNIP::::
-A or --adjust-volume=decibels
Adjust the relative volume for all files. This option overrides
any per-file volume adjustment settings. For example, -A0 may be
used to ignore relative volume adjustments given by ID3 tags.
Relative volume adjustments specified by this option or by ID3
tags are used as the base volume against which the signal is
further attenuated or amplified using the -a (--attenuate,
--amplify) option or keyboard controls. This option cannot be
used together with -G (--replay-gain).
-G or --replay-gain[=profile]
Enable Replay Gain volume adjustments. Replay Gain information
contained in the decoded files (if any) is used to make volume
adjustments for output. The profile may be one of radio (the
default) or audiophile. See the NOTES section below for further
details. When Replay Gain is enabled, a default pre-amp gain of
+6 dB is also applied; this can be changed with the -a
(--attenuate, --amplify) option.
There is no information if you can adjust volume while it is playing. I assume that you cannot adjust it while it is playing.