Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling audio.getAudioFileDuration() after calling audio.connecttoFS(); multiple times causes it to hang #906

Open
ra0943-VK3ACH opened this issue Nov 13, 2024 · 1 comment

Comments

@ra0943-VK3ACH
Copy link
Contributor

This is gonna sound dumb but whenever I call my PlayItem function for a 2nd time the loop hangs. If I remove the line CurrentSongFileDuration = 0; it runs fine. I took a quick look at the library and I couldnt see anything wrong

void Player::PlayItem(int queueIndex){
    Serial.println("Chagne index");
    CurrentlyPlayingIndex = queueIndex;
    audio.connecttoFS(SD_MMC, Queue[queueIndex].c_str());
    CurrentSongFileDuration = 0;
}

void Player::AudioLoop(){
    audio.loop();
    vTaskDelay(1);
    if(audio.isRunning()){
        int currentTime = audio.getAudioCurrentTime();
        if(CurrentSongFileDuration == 0){
            CurrentSongFileDuration = audio.getAudioFileDuration();
        }
        if(currentTime != previousCurrentTime){
            DrawNowPlayingTime(CurrentSongFileDuration, currentTime);
            previousCurrentTime = currentTime;
        }
    }
    
}
@schreibfaul1
Copy link
Owner

It is not possible to analyse the audio file in advance with the ESP32. The ESP32 is too slow for this. After several audio frames have been played, the average value can be calculated with a variable bit rate. This allows the total playing time of the audio file to be calculated. The longer the file plays, the more accurate the values are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants