.
Fork of VS1053 by
Revision 2:787946147566, committed 2016-12-05
- Comitter:
- PloyLL
- Date:
- Mon Dec 05 21:01:02 2016 +0000
- Parent:
- 1:ab6777568920
- Commit message:
- v
Changed in this revision
player.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/player.cpp Mon Dec 05 10:36:24 2016 +0000 +++ b/player.cpp Mon Dec 05 21:01:02 2016 +0000 @@ -7,9 +7,43 @@ Serial pc(USBTX, USBRX); playerStatetype playerState; ctrlStatetype ctrlState; +char list[20][14]; //song list static unsigned char fileBuf[1024]; unsigned char *bufptr; + + +void Player::begin(void) +{ + DirHandle *dir; + struct dirent *ptr; + FileHandle *fp; + + vs1053.reset(); + dir = opendir("/sd"); + printf("\r\n**********playing list**********\r\n"); + unsigned char i = 0,j=0; + while(((ptr = dir->readdir()) != NULL)&&(i <20)) { + if(strstr(ptr->d_name,".mp3")||strstr(ptr->d_name,".MP3")) { + fp =sd.open(ptr->d_name, O_RDONLY); + if(fp != NULL) { + char *byte = ptr->d_name; + j=0; + while(*byte) { + list[i][j++] = *byte++; + } + printf("%2d . %s\r\n", i+1,list[i++]); + fp->close(); + } + } + } + //index_MAX = i-1; + dir->closedir(); + printf("\r\n"); +} + + + /* This function plays back an audio file. */ void Player::playFile(char *file){ int bytes; // How many bytes in buffer left