SD card audio player using TMRpcm.h library (char* error)

(Sorry if my English isn’t the best.)
Hello im trying to make a simple button that when pressed played a sound and then stops again. This appears to be more difficult then I originally imaged. Mainly because the code doesn’t seem to upload. Im using the Arduino nano but I also tried to upload it to the Arduino due and uno but that didn’t work either. I found the library in the library management and on a website (I don’t know If the library on the website is an older version) library:(TMRpcm-master.zip - Google Drive)

(my code)

#include <SD.h>                       
//#define SD_ChipSelectPin 53         
#define SD_ChipSelectPin 10            
#include <TMRpcm.h>                  
#include <SPI.h>

TMRpcm tmrpcm;
const int buttonPin = 2;
int buttonState = 0; 
void setup()
{
  pinMode(buttonPin, INPUT);
tmrpcm.speakerPin=9;            
                                
                                
Serial.begin(9600);
if(!SD.begin(SD_ChipSelectPin))
{
  Serial.println("SD fail");
  return;
}
}
void loop() {
  // put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
    tmrpcm.setVolume(6);
tmrpcm.play("sound1.wav");
  }
}


]

(the error)

[
C:\Users\nebur\OneDrive\Documenten\Arduino\button\button.ino: In function 'void loop()':

C:\Users\nebur\OneDrive\Documenten\Arduino\button\button.ino:29:25: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

 tmrpcm.play("sound1.wav");

                         ^

Sketch uses 11550 bytes (37%) of program storage space. Maximum is 30720 bytes.
Global variables use 1066 bytes (52%) of dynamic memory, leaving 982 bytes for local variables. Maximum is 2048 bytes.

thank you in advance

it's a warning, not an error

that's because the developer of the library declared his method with a char *

 void TMRpcm::play(char* filename){
	play(filename,0);
}

instead of a const char *. When doing so the compiler assumes the function might modify the data and since you can't modify a hardcoded (constant) string tmrpcm.play("sound1.wav"); the compiler barks at you.

this should upload though as it's "just" a warning. (you can fix this by changing the signature in the library)

I have been trying to fix the new error that the changes gave me and tried googling it but I cant seem to solve the next problem that has been created this time it is an error. Im not
certain if I didn't understand you correctly or if it just doesn't work. now it give this error code: [

C:\Users\nebur\OneDrive\Documenten\Arduino\button\button.ino: In function 'void loop()':

button:27:18: error: qualified-id in declaration before '(' token

void TMRpcm::play(char* sound1.wav){

^

exit status 1
qualified-id in declaration before '(' token

]

I don't know what you did... post your program

#include <SD.h>                                
#define SD_ChipSelectPin 10            
#include <TMRpcm.h>                  
#include <SPI.h>

TMRpcm tmrpcm;
const int buttonPin = 2;
int buttonState = 0; 
void setup()
{
  pinMode(buttonPin, INPUT);
tmrpcm.speakerPin=9;            
                                
                                
Serial.begin(9600);
if(!SD.begin(SD_ChipSelectPin))
{
  Serial.println("SD fail");
  return;
}
}
void loop() {
  // put your main code here, to run repeatedly:
buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {
void TMRpcm::play(char* sound1.wav){
  tmrpcm.setVolume(6);
  play(sound1.wav,0);
  
}
  }
}

:o :o
You did not modify the library… you added weird code in the loop()…

OK - I guess what I said was over your head.

The simpler way… declare a char array initialized with your file name and use that…

// at beginning of the program
char fileName[] = "sound1.wav";
....

// later in code
if (buttonState == HIGH) {
  tmrpcm.setVolume(6);
  tmrpcm.play(fileName);
}

————

Please correct your post above and add code tags around your code (use the </> button) in tool bar or
[code]`` [color=blue]// your code is here[/color] ``[/code].

It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)