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

use esp32c3 After the sound stops, wait 4-5 minutes. #667

Open
kangz543g opened this issue Mar 2, 2024 · 0 comments
Open

use esp32c3 After the sound stops, wait 4-5 minutes. #667

kangz543g opened this issue Mar 2, 2024 · 0 comments

Comments

@kangz543g
Copy link

int outputUrlToSpeaker(String url) {
static int lastms = 0;
unsigned long startTime = millis(); // 현재 시간 기록

file = new AudioFileSourceHTTPStream(url.c_str());
buff = new AudioFileSourceBuffer(file, preallocateBuffer, preallocateBufferSize);
mp3 = new AudioGeneratorMP3();
mp3->begin(buff, out);

digitalWrite(LED_audio, HIGH);

while (mp3->isRunning() && millis() - startTime < 10000) { // 현재 시간이 시작 시간으로부터 10초 이내일 때까지 루프 실행
    if (!mp3->loop()) {
        mp3->stop();    <---- After the sound stops, wait 4-5 minutes.   problem????
        if (file != nullptr) {
          delete file;
          file = nullptr;
        }
        digitalWrite(LED_audio, LOW);
        delete out;
        delete mp3;
        return -1; // MP3가 중간에 중단되었음을 나타냄
    }
  
    // 1초마다 시간 출력
    if (millis() - lastms > 1000) {
        lastms = millis();
        Serial.printf("Running for %d ms...\n", lastms);
        Serial.flush();
    }
}

return 0; // 성공적으로 MP3가 종료됨을 나타냄

}

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

1 participant