Error Message using SFEMP3Shield.h Library trying to implement play/pause code

Hi All, I'm curring getting an error message while I'm tryin to edit some code. I'm trying to input a pause/resume piece into the code, so that when the electrode is touched - if playing it wil be paused and the consequently be able to be resumed by touching it again.

the main error I'm getting is

 could not convert 'MP3player.SFEMP3Shield::pauseMusic()' from 'void' to 'bool'
                  if (MP3player.pauseMusic()){'

I'm learning as I go along so apologies, if it is any glaringly obvious fix. Any help will be greatly appreciated!

Link to library using is here: [

See the code below!

// compiler error handling
#include "Compiler_Errors.h"

// touch includes
#include <MPR121.h>
#include <Wire.h>
#define MPR121_ADDR 0x5C
#define MPR121_INT 4

// mp3 includes
#include <SPI.h>
#include <SdFat.h>
#include <FreeStack.h> 
#include <SFEMP3Shield.h>

// mp3 variables
SFEMP3Shield MP3player;
byte result;
int lastPlayed = 0;

// mp3 behaviour defines
#define REPLAY_MODE FALSE  // By default, touching an electrode repeatedly will 
                          // play the track again from the start each time.
                          //
                          // If you set this to FALSE, repeatedly touching an 
                          // electrode will stop the track if it is already 
                          // playing, or play it from the start if it is not.

// touch behaviour definitions
#define firstPin 0
#define lastPin 11

// sd card instantiation
SdFat sd;

void setup(){  
  Serial.begin(57600);
  
  pinMode(LED_BUILTIN, OUTPUT);
   
  //while (!Serial) ; {} //uncomment when using the serial monitor 
  Serial.println("Bare Conductive Touch MP3 player");

  if(!sd.begin(SD_SEL, SPI_HALF_SPEED)) sd.initErrorHalt();

  if(!MPR121.begin(MPR121_ADDR)) Serial.println("error setting up MPR121");
  MPR121.setInterruptPin(MPR121_INT);

  MPR121.setTouchThreshold(10);
  MPR121.setReleaseThreshold(5);

  result = MP3player.begin();
  MP3player.setVolume(10,10);
 
  if(result != 0) {
    Serial.print("Error code: ");
    Serial.print(result);
    Serial.println(" when trying to start MP3 player");
   }
   
}

void loop(){
  readTouchInputs();
}


void readTouchInputs(){
  if(MPR121.touchStatusChanged()){
    
    MPR121.updateTouchData();
    // only make an action if we have one or fewer pins touched
    // ignore multiple touches
    
    if(MPR121.getNumTouches()<=1){
      for (int i=0; i < 12; i++){  // Check which electrodes were pressed
        if(MPR121.isNewTouch(i)){
        
            //pin i was just touched
            Serial.print("pin ");
            Serial.print(i);
            Serial.println(" was just touched");
            digitalWrite(LED_BUILTIN, HIGH);
            
            if(i<=lastPin && i>=firstPin){
              if(MP3player.isPlaying()){
                if(lastPlayed==i && !REPLAY_MODE){
                  // if we're already playing the requested track, stop it
                  // (but only if we're not in REPLAY_MODE)
                  MP3player.pauseMusic();
                  Serial.print("pausing track ");
                  Serial.println(i-firstPin);
                  
                } else {
                 // if the track is already paused, resume the paused track
                 if (MP3player.pauseMusic()){
                  if (lastPlayed == i){
                 MP3player.resumeMusic();
                 Serial.print("resuming track ");
                 Serial.println(i-firstPin);
                  
                   } else { 
                  // if we're already playing a different track (or we're in
                  // REPLAY_MODE), stop and play the newly requested one
                  MP3player.stopTrack();
                  MP3player.playTrack(i-firstPin);
                  Serial.print("playing track ");
                  Serial.println(i-firstPin);
                  
                  // don't forget to update lastPlayed - without it we don't
                  // have a history
                  lastPlayed = i;
                }
              } else {
                // if we're playing nothing, play the requested track 
                // and update lastplayed
                MP3player.playTrack(i-firstPin);
                Serial.print("playing track ");
                Serial.println(i-firstPin);
                lastPlayed = i;
              }
            }     
        } else {
          if(MPR121.isNewRelease(i)){
            Serial.print("pin ");
            Serial.print(i);
            Serial.println(" is no longer being touched");
            digitalWrite(LED_BUILTIN, LOW);
         } 
        }
      }
    }
  }
}

](GitHub - mpflaga/Sparkfun-MP3-Player-Shield-Arduino-Library: REPLACED by)

the main error I'm getting is

Please post the full text of the error message(s)

The expression in the parens after the 'if' has to be converted to a boolean (true or false) value. You are trying to use the value returned by MP3player.pauseMusic() but that function doesn't return a value so it can't be converted to boolean. Why did you try to use MP3player.pauseMusic() as a true/false value?

UKHeliBob:
Please post the full text of the error message(s)

find the full erroe message below

'Arduino: 1.8.5 (Mac OS X), Board: "Bare Conductive Touch Board"

In function 'void readTouchInputs()':
Our_Silhouette:154: error: could not convert 'MP3player.SFEMP3Shield::pauseMusic()' from 'void' to 'bool'
if (MP3player.pauseMusic()){
^
Our_Silhouette:192: error: expected '}' at end of input
}
^
Our_Silhouette:192: error: expected '}' at end of input
exit status 1
could not convert 'MP3player.SFEMP3Shield::pauseMusic()' from 'void' to 'bool'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

johnwasser:
The expression in the parens after the 'if' has to be converted to a boolean (true or false) value. You are trying to use the value returned by MP3player.pauseMusic() but that function doesn't return a value so it can't be converted to boolean. Why did you try to use MP3player.pauseMusic() as a true/false value?

I was trying to write that if the music is paused then resume - so I thought MP3player.pauseMusic() would be the right thing to use.

So instead I tried

   } else {
                 // if the track is already paused, resume the paused track
                 boolean MP3player.pauseMusic
                 if(lastPlayed==i){
                 MP3player.pauseMusic = true; }
                 if (MP3player.pauseMusic (== true)) {                 
                 MP3player.resumeMusic();
                 Serial.print("resuming track ");
                 Serial.println(i-firstPin);

and I received the error message :

Arduino: 1.8.5 (Mac OS X), Board: "Bare Conductive Touch Board"

In function 'void readTouchInputs()':
Our_Silhouette:154: error: expected initializer before '.' token
boolean MP3player.pauseMusic
^
Our_Silhouette:157: error: expected primary-expression before '==' token
if (MP3player.pauseMusic (== true)) {
^
Our_Silhouette:174: error: expected '}' before 'else'
} else {
^

exit status 1
expected initializer before '.' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Thanks for your help!

Please take some time to work through some of the example sketches in the IDE.

johnwasser:
The expression in the parens after the 'if' has to be converted to a boolean (true or false) value. You are trying to use the value returned by MP3player.pauseMusic() but that function doesn't return a value so it can't be converted to boolean. Why did you try to use MP3player.pauseMusic() as a true/false value?

update, I used

 } else {
                 // if the track is already paused, resume the paused track

                 if(lastPlayed==i && !REPLAY_MODE){                
                 MP3player.resumeMusic();
                 Serial.print("resuming track ");
                 Serial.println(i-firstPin);
                  
                   } else {

The track pauses but doesn't resume, any ideas?

Shizzla:
update, I used

 } else {

// if the track is already paused, resume the paused track

if(lastPlayed==i && !REPLAY_MODE){                
                MP3player.resumeMusic();
                Serial.print("resuming track ");
                Serial.println(i-firstPin);
                 
                  } else {




The track pauses but doesn't resume, any ideas?

Does your sketch show "resuming track " on Serial Monitor when you want the track to resume? If not, your logic is bad. If the message shows up and the track does not resume then you may be using the library incorrectly.