schreibfaul1 / ESP32-MiniWebRadio

Internetradio with ESP32, I2S DAC and SPI TFT Display with Touchpad
https://www.youtube.com/watch?v=6QbPee2583o
290 stars 76 forks source link

MP3 Directory and Playlist #391

Closed ve2cfb closed 2 months ago

ve2cfb commented 2 months ago

Hello Wolle, I have about 300 mp3 files in audiofile/musique directory and when you display the musique dir, it takes a lot of time to display them. My idea is to move those mp3 files to the root dir and make M3U playlist in audiofile/musique dir.

Here is my directory structure for what i am trying to do.

Directory

Many thanks... Pierre

schreibfaul1 commented 2 months ago

It takes time to display all files in the menu tree. It therefore makes sense to use additional folders. If you need an m3u playlist, you can proceed as follows: Create a folder structure on your PC and add the audio files. Then create a playlist with the VLC Player. And then copy everything to the SD card. The files in a playlist do not have to be in the same folder.

ve2cfb commented 2 months ago

Hello Wolle,

here is the serial output and the M3U file

Serial Output

created on my PC: test-5.m3u

EXTM3U

EXTINF:216,Chris Rea - Josephine

file:///C:/allmusiq/Josephine.mp3

Modified: test-5.m3u

EXTM3U

EXTINF:216,Chris Rea - Josephine

/allmusiq/Josephine.mp3

i always get: /audiofiles/musique/allmusiq/Josephine.mp3 it seems that i cant point to the root.

how would you go back to the root directory...

ve2cfb commented 2 months ago

Hello Wolle, I did a test by changing the code in main.cpp to see if by moving all my music to the root directory would help and so far so good.

Why this change...? If my 1700 mp3 files where in audiofiles/musique/allmusic, when in displaylist mode, if by mistake you hit display allmusic, this would take a lot of time. When in the root directory, you never access those files, only M3U will be able to. Also, its a lot easier to manage all the mp3 in one place.

All my music (1700 mp3 files for testing purpose) are in the root with directory for artist, by type and so on. In the audiofiles/musique, i only have my M3U files . The M3U are able to select the root directory. This method, is very fast.

main.md

Do a search on "_test_chbuf" for the modifications.

Mind you this is a dirty code and there are other issues in the code but i am sure you will see where there are some improvment like the shuffle and loop part.

I wish there could be an easier way of doing things.

Thanks for your time...

schreibfaul1 commented 2 months ago

Hi Pierre, I have looked at the changes in your main.cpp and now know what you mean. The m3u is always relative to the content. You can see this when you create a playlist with the VLC player. For example: The paths change with the location of the playlist. The symbol "file:///" is used for root, I would use that.

image

Then it would look like this in your case:

EXTM3U

EXTINF:216,Chris Rea - Josephine

file:///allmusiq/Josephine.mp3

What do you think?

ve2cfb commented 2 months ago

Hello Wolle, Great, it works... One problem... The Shuffle option. The mp3 files are played in sequence, no problem there, but once it start playing the first song and i press the red X button and press the Shuffle button, it shows the following "Chris Rae.m3u" and it hang in that situation.

While where at it... it would be nice to activate the shuffle function at the start of "Audio Player menu" and change the button color to show when its active or not.

Again, many thanks.

schreibfaul1 commented 2 months ago

Hello Pierre, I have changed something else. I discovered another serious error. If another FLAC file is played later after a FLAC file, a crash can sometimes occur. This has been fixed. In addition, the entire playlist was cancelled when playing a faulty file. I will think about the arrangement of the buttons.

Best regards Wolle

ve2cfb commented 2 months ago

Hi Wolle, Many thanks... I am moving all my files in the root and in AUDIOFILES, i create M3U groups like Artist, Type, Best listen and so on. Am i able to use the shuffle option at this stage...?

TubaFonse commented 2 months ago

Hello Wolle, hello Pierre,

I just tried to play some mp3's and playlists by using the Web-Interface. I use the actual Firmware and also the actual files on SD-card.

  1. On the touch-screen I can play the songs / playlists,
  2. but it doesn't work with Web-Interface - what do I wrong? Can you play the files with your Web-Interface? Do we need additional buttons there to play the songs or playlists? I only see the Buttons grafik for "Upload to SD-Folder", "Pause", "Resume", nothing else. I'm using Firefox on Win10/11-PC: grafik

Best regards, Alfons

ve2cfb commented 2 months ago

Hello TubaFonse, Have you try using the mouse right click button when pointing to an mp3 or m3u file...?

TubaFonse commented 2 months ago

Hello Pierre, ... mouse right click, oh yes - that's the solution of my problem!!! Many thanks - best regards, Alfons.

TubaFonse commented 2 months ago

... but how can I play that files or playlists using my tablet / smartphone (no mouse)? The additional buttons like touch screen will be useful for realizing it also in Web-interface: grafik

schreibfaul1 commented 2 months ago

When an m3u playlist is played, skipping forwards and backwards does not work. I will add this soon.

TubaFonse commented 2 months ago

Please re-test: 1.) Issue, when using Web-Interface (Win10 PC with Firefox), "Play All" from folder /audiofiles: only the last song is playing (because all previous files recognized as AudioCurrentTime 0:00s, AudioFileDuration 0:00s! grafik

2.) Issue, when using Web-Interface (Win10 PC with Firefox), "Play All" from folder /audiofiles/myPlaylist: similar effect like 1.), followed by Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled. grafik

serial monitor Issue 1.) 18:05:38 webSrv: ... Play Folder"/audiofiles" 18:05:38 AUDIO_FILE: Collide.ogg 18:05:38 AUDIO_info: buffers freed, free Heap: 165704 bytes 18:05:38 AUDIO_info: Reading file: "/audiofiles/Collide.ogg" 18:05:38 AUDIO_info: VORBISDecoder has been initialized, free Heap: 161300 bytes, free stack 4484 DWORDs 18:05:38 AUDIO_FILE: AudioCurrentTime 0:00s, AudioFileDuration 0:00s 18:05:38 Audiocodec: VORBIS 18:05:39 webSrv: ... Play Folder"/audiofiles" 18:05:39 AUDIO_info: skip playlist /audiofiles/myPlaylist.m3u 435 18:05:39 webSrv: ... Play Folder"/audiofiles" 18:05:39 AUDIO_info: stream ready 18:05:39 AUDIO_info: syncword found at pos 0 18:05:39 AUDIO_info: Eddie Grey - Collide 18:05:39 StreamTitle: Eddie Grey - Collide 18:05:39 AUDIO_info: Channels: 2 18:05:39 AUDIO_info: SampleRate: 44100 18:05:39 AUDIO_info: BitsPerSample: 16 18:05:39 AUDIO_info: BitRate: 128000 18:05:39 AUDIO_FILE: sample.aac 18:05:39 AUDIO_info: Closing audio file 18:05:39 AUDIO_info: buffers freed, free Heap: 165692 bytes 18:05:39 AUDIO_info: Reading file: "/audiofiles/sample.aac" 18:05:39 AUDIO_info: AACDecoder has been initialized, free Heap: 161288 bytes , free stack 4484 DWORDs 18:05:39 AUDIO_FILE: AudioCurrentTime 0:00s, AudioFileDuration 0:00s 18:05:39 Audiocodec: AAC 18:05:39 webSrv: ... Play Folder"/audiofiles" 18:05:39 AUDIO_FILE: sample.flac 18:05:39 AUDIO_info: Closing audio file 18:05:39 AUDIO_info: buffers freed, free Heap: 165692 bytes 18:05:39 AUDIO_info: Reading file: "/audiofiles/sample.flac" 18:05:39 AUDIO_info: FLACDecoder has been initialized, free Heap: 161288 bytes , free stack 4484 DWORDs 18:05:39 AUDIO_info: Content-Length: 836530 18:05:39 webSrv: ... Play Folder"/audiofiles" 18:05:39 AUDIO_info: FLAC maxBlockSize: 4096 18:05:39 AUDIO_info: FLAC maxFrameSize: 12239 18:05:39 AUDIO_info: FLAC sampleRate: 44100 18:05:39 AUDIO_info: FLAC numChannels: 2 18:05:39 AUDIO_info: FLAC bitsPerSample: 16 18:05:39 AUDIO_info: total samples in stream: 413817 18:05:39 AUDIO_info: audio file duration: 9 seconds 18:05:39 id3data: .. VENDOR_STRING: reference libFLAC 1.3.3 20190804 18:05:39 id3data: .. COMMENTS=flac 18:05:39 id3data: .. DATE=2022 18:05:39 id3data: .. ARTIST=sample 18:05:39 AUDIO_FILE: sample.m4a 18:05:39 AUDIO_info: Closing audio file 18:05:39 AUDIO_info: buffers freed, free Heap: 165692 bytes 18:05:39 AUDIO_info: Reading file: "/audiofiles/sample.m4a" 18:05:39 AUDIO_info: AACDecoder has been initialized, free Heap: 161288 bytes , free stack 4484 DWORDs 18:05:39 AUDIO_info: ch; 2, bps: 16, sr: 44100 18:05:39 id3data: .. Album: sample 18:05:39 id3data: .. Encoder: Lavf58.29.100 18:05:39 id3data: .. Comment: 18:05:39 webSrv: ... Play Folder"/audiofiles" 18:05:39 AUDIO_info: Audio-Length: 520091 18:05:39 AUDIO_info: Content-Length: 0 18:05:39 AUDIO_FILE: sample.mp3 18:05:39 AUDIO_info: Closing audio file 18:05:39 AUDIO_info: buffers freed, free Heap: 165692 bytes 18:05:39 AUDIO_info: Reading file: "/audiofiles/sample.mp3" 18:05:39 AUDIO_info: MP3Decoder has been initialized, free Heap: 161288 bytes , free stack 4484 DWORDs 18:05:39 AUDIO_info: Content-Length: 1954212 18:05:39 AUDIO_info: ID3 framesSize: 45 18:05:39 AUDIO_info: ID3 version: 2.4 18:05:39 AUDIO_info: ID3 normal frames 18:05:39 webSrv: ... Play Folder"/audiofiles" 18:05:39 id3data: .. SettingsForEncoding: Lavf57.83.100 18:05:39 AUDIO_info: Audio-Length: 1954167 18:05:40 AUDIO_FILE: sample.wav 18:05:40 AUDIO_info: Closing audio file 18:05:40 AUDIO_info: buffers freed, free Heap: 165692 bytes 18:05:40 AUDIO_info: Reading file: "/audiofiles/sample.wav" 18:05:40 webSrv: ... Play Folder"/audiofiles" 18:05:40 AUDIO_info: skip playlist /audiofiles/simplePlaylist.m3u 263 18:05:40 AUDIO_info: FormatCode: 1 18:05:40 AUDIO_info: DataRate: 176400 18:05:40 AUDIO_info: DataBlockSize: 4 18:05:40 AUDIO_info: BitsPerSample: 16 18:05:40 AUDIO_info: Audio-Length: 1616220 18:05:40 AUDIO_FILE: AudioCurrentTime 0:00s, AudioFileDuration 0:00s 18:05:40 Audiocodec: WAV 18:05:40 AUDIO_info: stream ready 18:05:40 AUDIO_info: syncword found at pos 0 18:05:40 AUDIO_info: Channels: 2 18:05:40 AUDIO_info: SampleRate: 44100 18:05:40 AUDIO_info: BitsPerSample: 16 18:05:40 AUDIO_info: BitRate: 1411200 18:05:41 AUDIO_FILE: AudioCurrentTime 0:01s, AudioFileDuration 0:09s 18:05:42 AUDIO_FILE: AudioCurrentTime 0:02s, AudioFileDuration 0:09s 18:05:43 AUDIO_FILE: AudioCurrentTime 0:03s, AudioFileDuration 0:09s 18:05:44 AUDIO_FILE: AudioCurrentTime 0:04s, AudioFileDuration 0:09s 18:05:45 AUDIO_FILE: AudioCurrentTime 0:05s, AudioFileDuration 0:09s 18:05:46 AUDIO_FILE: AudioCurrentTime 0:06s, AudioFileDuration 0:09s 18:05:47 AUDIO_FILE: AudioCurrentTime 0:07s, AudioFileDuration 0:09s 18:05:48 AUDIO_FILE: AudioCurrentTime 0:08s, AudioFileDuration 0:09s 18:05:49 AUDIO_FILE: AudioCurrentTime 0:09s, AudioFileDuration 0:09s 18:05:49 AUDIO_info: Closing audio file 18:05:49 end of file: sample.wav 18:05:49 AUDIO_info: End of file "sample.wav" 18:05:49 AUDIO_info: next audio file 18:05:49 AUDIO_info: No other audio files found

serial monitor Issue 2.) 18:13:50 webSrv: ... GetFolder "/audiofiles" 18:14:07 webSrv: ... GetFolder "/audiofiles/myPlaylist" 18:14:13 webSrv: ... Play Folder"/audiofiles/myPlaylist" 18:14:14 AUDIO_FILE: logo-1.mp3 18:14:14 AUDIO_info: buffers freed, free Heap: 165604 bytes 18:14:14 AUDIO_info: Reading file: "/audiofiles/myPlaylist/logo-1.mp3" 18:14:14 AUDIO_info: MP3Decoder has been initialized, free Heap: 161188 bytes , free stack 4484 DWORDs 18:14:14 AUDIO_info: Content-Length: 353230 18:14:14 AUDIO_info: ID3 framesSize: 56 18:14:14 AUDIO_info: ID3 version: 2.4 18:14:14 AUDIO_info: ID3 extended header 18:14:14 AUDIO_FILE: AudioCurrentTime 0:00s, AudioFileDuration 0:00s 18:14:14 id3data: .. Album: Logo 1 18:14:14 Audiocodec: MP3 18:14:14 id3data: .. Artist: Logo 1 18:14:14 AUDIO_info: Audio-Length: 353174 18:14:14 webSrv: ... Play Folder"/audiofiles/myPlaylist" 18:14:14 AUDIO_info: stream ready 18:14:14 AUDIO_info: syncword found at pos 0 18:14:14 AUDIO_info: Channels: 2 18:14:14 AUDIO_info: SampleRate: 44100 18:14:14 AUDIO_info: BitsPerSample: 16 18:14:14 AUDIO_info: BitRate: 320000 18:14:14 AUDIO_FILE: ανακοίνωση-3.mp3 18:14:14 AUDIO_info: Closing audio file 18:14:14 AUDIO_info: buffers freed, free Heap: 165584 bytes 18:14:14 AUDIO_info: Reading file: "/audiofiles/myPlaylist/ανακοίνωση-3.mp3" 18:14:14 AUDIO_info: MP3Decoder has been initialized, free Heap: 161152 bytes , free stack 4484 DWORDs 18:14:14 AUDIO_info: Content-Length: 156849 18:14:14 AUDIO_info: ID3 framesSize: 116 18:14:14 AUDIO_info: ID3 version: 2.4 18:14:14 AUDIO_info: ID3 extended header 18:14:14 webSrv: ... Play Folder"/audiofiles/myPlaylist" 18:14:14 id3data: .. Album: τόνος ανακοίνωσης 18:14:14 id3data: .. Artist: τόνος ανακοίνωσης 18:14:14 AUDIO_info: Audio-Length: 156733 18:14:14 AUDIO_info: stream ready 18:14:14 AUDIO_info: syncword found at pos 0 18:14:14 AUDIO_info: Channels: 2 18:14:14 AUDIO_info: SampleRate: 44100 18:14:14 AUDIO_info: BitsPerSample: 16 18:14:14 AUDIO_info: BitRate: 320000 18:14:15 AUDIO_FILE: Лого-2.mp3 18:14:15 AUDIO_info: Closing audio file 18:14:15 AUDIO_info: buffers freed, free Heap: 165584 bytes 18:14:15 AUDIO_info: Reading file: "/audiofiles/myPlaylist/Лого-2.mp3" 18:14:15 AUDIO_info: MP3Decoder has been initialized, free Heap: 161164 bytes , free stack 4484 DWORDs 18:14:15 AUDIO_info: Content-Length: 163159 18:14:15 AUDIO_info: ID3 framesSize: 156 18:14:15 AUDIO_info: ID3 version: 2.4 18:14:15 AUDIO_info: ID3 extended header 18:14:15 webSrv: ... Play Folder"/audiofiles/myPlaylist" 18:14:15 AUDIO_info: No other audio files found 18:14:15 id3data: .. Album: фирменный или товарный знак 18:14:15 id3data: .. Artist: фирменный или товарный знак 18:14:15 AUDIO_info: Audio-Length: 163003 18:14:15 AUDIO_info: stream ready 18:14:15 AUDIO_info: syncword found at pos 0 18:14:15 AUDIO_info: Channels: 2 18:14:15 AUDIO_info: SampleRate: 44100 18:14:15 AUDIO_info: BitsPerSample: 16 18:14:15 AUDIO_info: BitRate: 320000 Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

Core 1 register dump: PC : 0x42108b87 PS : 0x00060d30 A0 : 0x82005d46 A1 : 0x3fcebdb0
=> 0x42108b87: strlenUTF8(char const) at src/main.cpp:2076 (inlined by) strlenUTF8(char const) at src/main.cpp:2072 A2 : 0x0000000d A3 : 0x00000000 A4 : 0x3fceca50 A5 : 0x00000000
A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000000 A10 : 0x3fcebdac A11 : 0x00000000 A12 : 0x0000000d A13 : 0x0000009f A14 : 0x000000e2 A15 : 0xb33fffff SAR : 0x00000007 EXCCAUSE: 0x0000001c EXCVADDR: 0x0000000d LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff

schreibfaul1 commented 2 months ago

I know what you mean. I have a list that processes "playAll", but at the same time also saves the contents of the folders (this is the vector _SD_content). That can't work well. I will separate this so that the described defect no longer occurs.

schreibfaul1 commented 2 months ago

Hello @TubaFonse, the content of a folder is saved in a vector and played in sequence by "playAll". If you clicked on another folder in the file tree, the vector changed and sometimes caused a crash. This no longer happens.

TubaFonse commented 2 months ago

Dear Wolle @schreibfaul1 - it works fine now, without crash!!! I tested the actual Fw with my configurations:

schreibfaul1 commented 2 months ago

great, thanks, now I have "playAll" and "m3u" in one list. This will make it possible to jump forwards and backwards. That will be coming soon.

Best regards

ve2cfb commented 2 months ago

Hello Wolle, A quick question...
Is the shuffle option suppose to work...? i have Version 3.01d Apr 17/2024
Thanks for your time.

schreibfaul1 commented 2 months ago

Yes, this should work, the shuffle symbol is only shown on the display at the moment. This "virtually" shuffles the contents of the currently open folder.

ve2cfb commented 2 months ago

Hello Wolle, Mine does not shuffle at all either mp3 or m3u. Where did i go wrong... Thanks.

schreibfaul1 commented 2 months ago

currently only folder m3u files not yet, that will come later