Magnetic switch loop

MarkT:
Look at and study the example 02.Digital > StateChangeDetection

Thank you very much Paul and Mark
I think i got meaning of BECOMES and IS LOW

For the part of playing music, when I open the box, I want the box just play the code in between once(the sound), and therefore I int theboxstatus =1 at the end to try to stop the loop. but seems I cannot stop the loop, so my box keep playing sound when it is open, why?

void loop(){
if(digitalRead(button) == LOW){
if(theboxstatus==0){

{digitalWrite(SLAVESELECT,LOW);
spi_transfer(SET_PLAY); // clear interupt and eom bit
SPI.transfer(0x00);
SPI.transfer(30);
SPI.transfer(0x00);
SPI.transfer(46);
SPI.transfer(0x00);
SPI.transfer(0x00);
digitalWrite(SLAVESELECT,HIGH);}

theboxstatus =1;
delay(10000);}
}else{
theboxstatus = 0;
}