mp3
Diff: player.cpp
- Revision:
- 2:a59255e80c0d
- Parent:
- 1:17913cff05a2
- Child:
- 3:94b538ace77a
--- a/player.cpp Sat Dec 09 14:21:59 2017 +0000 +++ b/player.cpp Sat Dec 09 15:07:27 2017 +0000 @@ -8,10 +8,10 @@ ctrlStatetype ctrlState; static unsigned char fileBuf[32768]; unsigned char *bufptr; +char green; -char list[20][14]; //song list -char index; //song play index -char index_MAX; //how many song in all +char list[20][50]; //song list + char data ; DigitalIn sw_in(USER_BUTTON); @@ -36,28 +36,22 @@ j=0; while(*byte){ list[i][j++] = *byte++; + green=i; } pc.printf("%2d . %s\r\n", i,list[i++]); //fp->close(); } } } - index_MAX = i-1; dir->closedir(); - printf("\r\n"); } void Player::stop(void){ playerState =PS_STOP; } -void Player::playfile(char n){ - playerState =PS_STOP; - index = n; - } + -void Player::getsong(void){ - playfile(2); - } + /* This function plays back an audio file. */ void Player::playFile(char *file) { @@ -68,7 +62,7 @@ vs1053.setFreq(24000000); //hight speed - FileHandle *fp =sd.open(file, index); + FileHandle *fp =sd.open(file, O_RDONLY); if(fp == NULL) { printf("Could not open %s\r\n",file); @@ -94,6 +88,7 @@ } uint8_t vol = 0x00;//set vlume vs1053.setVolume(vol); //set vlume + if(playerState != PS_PLAY) //stop { fp->close();