DFRobot / DFRobot_DF1201S

Here comes the DFPlayer Pro-a mini simple but powerful MP3 Player! This MP3 player module supports four controlling modes: Arduino, AT command, on-board buttons, and ADKEY. You can directly press the on-board button to play or switch music without using a controller. By using a USB cable, you can easily copy your favorite songs into this module to play them any where you want, or use it as a sound card for your PC or Raspberry Pi after connecting them together.
MIT License
6 stars 5 forks source link

AT+PLAYFILE #5

Open smdjeff opened 2 years ago

smdjeff commented 2 years ago

Does AT+PLAYFILE work?

  1. It seems to just play track 1, I assume because it can't find the file on the disk correctly.
  2. Noticing that playSpecFile() is commented out in the example, is that a tell?
  3. There's a lot of weird utf8/unicode translation code in the file name DFRobot_DF1201S::getFileName() that's doesn't have a reciprocal in the playSpecFile().
pleasetakeup commented 2 years ago

According to our recent test, AT+PLAYFILE and playSpecFile() can work properly.

  1. If other functions can work normally except playSpecFile() during use, please check whether you sent the command in the correct format or whether you filled in the correct parameters. You can refer to the sample in the product wiki: https://wiki.dfrobot.com/DFPlayer_PRO_SKU_DFR0768
  2. If other functions can’t work normally, either, please check whether there is something wrong with the hardware.
  3. The utf8/unicode translation code is used to support Chinese display in the serial port. The data read from mp3 module using unicode encoding should be changed to use utf8 encoding when displayed in the serial port of Arduino, so the translation code is required. Thanks for your question. Hope this helps.
Beanow commented 1 year ago

Same issue, even following the same file path. Using DFR0768's onboard storage, test/test.mp3

DF1201S.playSpecFile("/test/test.mp3");

In serial

AT+PLAYFILE=/test/test.mp3

OK

Is there supposed to be a path to the internal storage? Like /storage/test/test.mp3?

smdjeff commented 1 year ago

Still broken. The advice above was not useful. playSpecFile() doesn't work likely because of the aforementioned causes.

Ended up discarding these boards and switching to a more expensive Adafruit board that has a working filesystem and serial command set.

ChrisBall commented 1 year ago

According to our recent test, AT+PLAYFILE and playSpecFile() can work properly.

1. If other functions can work normally except playSpecFile() during use, please check whether you sent the command in the correct format or whether you filled in the correct parameters. You can refer to the sample in the product wiki: https://wiki.dfrobot.com/DFPlayer_PRO_SKU_DFR0768

2. If other functions can’t work normally, either, please check whether there is something wrong with the hardware.

3. The utf8/unicode translation code is used to support Chinese display in the serial port. The data read from mp3 module using unicode encoding should be changed to use utf8 encoding when displayed in the serial port of Arduino, so the translation code is required.
   Thanks for your question. Hope this helps.

Can you supply example code that works?

ChrisBall commented 1 year ago

I've got this working to some extent, but not as the example given (DF1201S.playSpecFile("/test/test.mp3");).

What works is DF1201S.playSpecFile("/filename.mp3"));, with conditions given below.

-Files are relative to the root, e.g. "/yourfile.mp3" will attempt to play ROOT/yourfile.mp3. -Leading forward slash is required in string, but ignored when counting filename char length. -File naming must be in 8.3 format. e.g. "/test.mp3" is OK. "/testlong.mp3" is OK. "/testlonger.mp3" is not (testlonger is 10 chars). -Subfolders only work if the total length of the path (including slashes) is less than 8 chars e.g. "/test/test.mp3" WILL NOT WORK as "test/test" is 9 chars. "/test/tes.mp3" seems OK. More investigation required.

If any of these conditions are not met, the chip always falls back to playing file 1 (the first file copied to the disk, regardless of location/naming).

Hope this helps someone.

smdjeff commented 1 year ago

Thanks for digging in! That path length limitation is nuts. Worse than DOS 1 :)

nelsonii commented 1 year ago

I should have searched for "DF1201S.playSpecFile" about two hours ago! Augh! Thanks @ChrisBall and @smdjeff for posting this. It's all in the filename length.

/en_num_20.mp3 fails (but in a frustrating way -- playing the first file in memory) -- one character too long /20.mp3 is happy days (num_20.mp3 okay too)

I ended up dropping an "error.mp3" file as the first file on the disk, so I can tell if "file not found".

qsjhyy commented 9 months ago

我已经在某种程度上工作了,但不是作为给出的示例(DF1201S.playSpecFile(“/test/test.mp3”);)。

有效的是DF1201S.playSpecFile(“/filename.mp3”));,条件如下。

-文件是相对于根目录的,例如“/yourfile.mp3”将尝试播放ROOT/yourfile.mp3。 -字符串中需要前导正斜杠,但在计算文件名字符长度时被忽略。 - 文件命名必须采用 8.3 格式。例如,“/test.mp3”是可以的。 “/testlong.mp3”是可以的。 “/testlonger.mp3”不是(testlonger是10个字符)。 -子文件夹仅在路径的总长度(包括斜杠)小于 8 个字符时才有效,例如“/test/test.mp3”将不起作用,因为“test/test”是 9 个字符.mp3。需要进行更多调查。

如果不满足这些条件中的任何一个,芯片将始终回退到播放文件 1(复制到磁盘的第一个文件,无论位置/命名如何)。

希望这对某人有所帮助。

Thank you very much for testing this. '/123456789.mp3' is not allowed, but '/12345678.mp3' is. I also found that '/test/test.mp3' and '/12345678/12345678.mp3' both work. In fact, it seems that the individual filename length needs to be less than 8 bytes.