tmrpcm code problem

I am trying to make a project on Home Security.
When laser beam is off arduino will play an audio file from sd card with tmrpcm library. And when a button is pressed the audio will be stopped. But the audio file is not playing. I don't know why. Please help me.Here is the code:

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

TMRpcm tmrpcm;

const int sensivity = 400;

#define ldr A0
#define buttonPin A2

int buttonState;
int state = 0;

void setup() {

Serial.begin(9600);
if (!SD.begin(SD_ChipSelectPin)) {
Serial.println("SD fail");
return;
}

tmrpcm.speakerPin = 9;

}

void alarmOFF() {

tmrpcm.disable();

}

void alarmON() {
tmrpcm.stopPlayback();
tmrpcm.setVolume(2);
tmrpcm.play("1.wav");
}

void loop() {

int light = analogRead(ldr);
int button = analogRead(buttonPin);

if (button >= 1020) {
state = 0;
}

if (light > sensivity) {
state = 1;
}

if ((light <= sensivity) && (state == 0)) {

alarmOFF();

}

if (state == 1) {
alarmON();

}
}

Have you tried some basic code which just plays your file? Does that work o.k.?

How is the button wired and why do you need to use analogRead() with a button?

Put some Serial.prints in to show exactly what values you are getting from the LDR and button.

Steve

The Alarming system is Ok. There is no problem in it. But the problem is in playing the audio file.
When the alarm turns on I can hear some buzzing sound which disappears after the alarm is off. It doesn't play any kind of audio file..

All the alarm does is play an audio file so it seems a bit odd to claim you know its working when it doesn't play an audio file.

I'll guess that there's something wrong with whatever you have connected to pin 9 or your audio file is bad e.g. in an invalid format.

Steve