madplay mp3

Hello everybody,
Just need a little help for something that drive me crazy.
I successfully managed to play a mp3 with my arduino yun following this tutorial http://dev.mikamai.com/post/69775973742/arduino-yun-with-sound-the-supereasy-way

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>
#include <FileIO.h>

const int buttonPin = 2;
const int ledPin =  13;

int buttonState = 0;
Process p;

void setup() {
  Bridge.begin();
  pinMode(ledPin, OUTPUT);      
  pinMode(buttonPin, INPUT);     
  Console.begin();
}

void loop(){
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {    
    digitalWrite(ledPin, HIGH);  
    p.runShellCommandAsynchronously("madplay /mnt/sd/Testsong.mp3");
    Console.println(buttonState);
  } 
  else {
    digitalWrite(ledPin, LOW);
    Console.println(buttonState);
}
}

Hope you can help me,
thanks

opkg update
opkg install kmod-usb-audio
opkg install madplay
cd /mnt/sda1
wget --no-check-certificate  https://www.dropbox.com/s/zzowqtew6cmspsf/track39.mp3
#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;
    }
  }
}

p: Play
s: Stop
r: Repeat Play

How can i change the volume of madplay while a process is running?

magum12:
How can i change the volume of madplay while a process is running?

Google: madplay mp3 manpage

http://manpages.ubuntu.com/manpages/utopic/man1/madplay.1.html

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.

Jesse

Take a look here Exiting a runShellCommandAsynchronously() process - Arduion Yun - #4 by Angelo9999 - Arduino Yún - Arduino Forum