1. Introduction
In the previous article, we talked about playing music with Bluetooth speakers. However, before that, the audio files were transferred to the development board through the PC, and then the development board used multimedia tools to play the music. This was very inconvenient, so we wanted the development board to download the audio files by itself and then play them.
2. Python environment preparation
This tool requires Python 3 support. The system comes with Python 3. The version is shown in Figure 1 below:
Figure 1
First, you need to install Python's third-party library [pymusic-dl]. When installing this, I encountered many problems. The first problem is that after entering the [pip3 install pymusic-dl] command, I was supposed to install the [pymusic-dl] tool, but an error message as shown in Figure 2 appeared.
【ERROR: Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443)】
Figure 2
Then I tried it online and added a "--user" attribute, which became [pip3 install --user pymusic-dl] command. It still didn't work. I continued to look for the problem and saw a solution on a foreign website. It should be caused by the mismatch between the current system time and the server time. So I started to modify the time, looked for the development board manual, and found the setting of system time, as shown in Figure 3 below.
Figure 3
Through the above data analysis, I set the system time to the current time, as shown in Figure 4 below.
Figure 4
The board can also set the power-off time. It uses an RTC peripheral, but the RTC peripheral needs to be powered. The power supply management is shown in Figure 5.
Figure 5
The system time has been set, but it is not over yet. The third-party library can be downloaded normally, but there is still an error during installation, as shown in Figure 6 below.
【ERROR: Command errored out with exit status 1】
Figure 6
After some testing, I felt that the version of pip was not new enough, so I used the command [pip3 install --upgrade pip] to upgrade pip, and there were no problems during the upgrade process.
Figure 7
Finally, enter the [pip3 install pymusic-dl] command to successfully download and install the third-party library. The "--user" attribute is not used here. If there are still problems with the installation, you can try adding the "--user" attribute.
Figure 8
3. Audio Download Tool
First, download the tool from GitHub, [https://github.com/0xHJK/music-dl], then move it to the development board and install it directly. In the tool root directory, enter the [python3 setup.py install] command to install it. The installation is shown in Figure 9.
Fig. 9
After successful installation, enter the [music-dl --help] command to view the tool's help information.
Fig.10
Let's search for songs by a certain author. The search results are shown in Figure 11 below.
Fig.11
Then enter 0 and press Enter to download the song with serial number 0. The download speed is quite fast.
Fig.12
Check the root directory of the tool to see if there is this song. As shown in Figure 13 below, there is this song. Finally, use the [gst-play-1.0] tool to play the music.
Fig.13
4. Summary
The system environment of MYS-8MMX is quite good, and no problems caused by the system environment were encountered during use. With the above tools, plus some graphical interfaces, you can actually design a networked music player. Customizing software is so easy~