Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions audio_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,24 @@ static esp_err_t aplay_file(audio_instance_t *i, FILE *fp) {
if(is_mp3(fp)) {
file_type = FILE_TYPE_MP3;
LOGI_1("file is mp3");

// Skip ID3v2 tag body (is_mp3 already rewound, so we read from offset 0)
uint8_t head[10];
if (fread(head, 1, 10, fp) == 10 && memcmp(head, "ID3", 3) == 0) {
uint32_t tag_size = ((uint32_t)head[6] << 21) |
((uint32_t)head[7] << 14) |
((uint32_t)head[8] << 7) |
(uint32_t)head[9];
fseek(fp, tag_size, SEEK_CUR);
} else {
rewind(fp);
}

// Reset decoder: clear bit reservoir state from previous file
Comment thread
Lee-Stone marked this conversation as resolved.
if (i->mp3_decoder) {
Comment thread
Lee-Stone marked this conversation as resolved.
MP3FreeDecoder(i->mp3_decoder);
}
i->mp3_decoder = MP3InitDecoder();

// initialize mp3_instance
i->mp3_data.bytes_in_data_buf = 0;
Expand Down