ProgressStream only returning 0 #913
-
I'm trying to use progressStream by passing the I2SStream to it but in my serial monitor it's straight 0%'s. Here is my code: #include "AudioTools.h" #define PIN_AUDIO_KIT_SD_CARD_CS 22 const char *startFilePath = "/"; void printMetaData(MetaDataType type, const char *str, int len) { void setup() { auto cfg = i2s.defaultConfig(TX_MODE); player.setMetadataCallback(printMetaData); void loop() { Serial.print("Progress: "); delay(1000); Any ideas on where I'm messing up? Thanks in advance :) |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 2 replies
-
You forgot to provide the file size! You can't calculate a percentage if the total is unknown! |
Beta Was this translation helpful? Give feedback.
-
This has nothing to do with my framework: Google is your friend and I am sure it should not bee to difficult to find out how to determine the size of a file |
Beta Was this translation helpful? Give feedback.
-
Ok, so I switched from AudioSourceSDFAT to AudioSourceSD as the SD library has a method to get file size, forked your library, then implemented all of this in my program:
However, the serial monitor still outputs the percentage as being zero, but the method I implemented is working because it successfully returns a value:
|
Beta Was this translation helpful? Give feedback.
-
That's because you still send the output to the I2SStream instead of the ProgressStream! Please note that your logic works only for the first file! you will need to repeat this when the file is changed. |
Beta Was this translation helpful? Give feedback.
-
I'm not quite sure what you mean. How would I correct this? |
Beta Was this translation helpful? Give feedback.
-
In the constructor of the AudioPlayer you need to define the correct output: |
Beta Was this translation helpful? Give feedback.
You forgot to provide the file size! You can't calculate a percentage if the total is unknown!