[ English | 简体中文 ]
This article describes how to run the music player demo on openvela Emulator.
-
Set up the development environment. Refer to Environment Setup.
-
Download the source code. Refer to Download openvela source code.
-
Switch to the root directory of openvela repository and execute the following command to configure the music player.
The emulator configuration file (defconfig) is in the “vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap/” directory, and the development board code is configured and compiled using “build.sh”.
./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap menuconfig
- build.sh: A script for compilation used to configure and compile openvela code.
- vendor/openvela/boards/vela/configs/*:configuration path
- menuconfig: Open the menuconfig page to modify the configuration of the project code.
-
Press the “/” key to search and modify the following configurations:
LVX_USE_DEMO_MUSIC_PLAYER=y LVX_MUSIC_PLAYER_DATA_ROOT="/data"
Take LVX_USE_DEMO_MUSIC_PLAYER as an example for illustration. The other configurations are modified is the same way.
-
Enter the configuration “LVX_USE_DEMO_MUSIC_PLAYER” to be searched. Fuzzy search is supported; for example, “music_player” will get the corresponding configuration. Press the Enter key to enter that configuration.
-
Press the spacebar, and a * that appears in [ ] indicates that the configuration is turned on.
-
Set “LVX_MUSIC_PLAYER_DATA_ROOT” to “/data”, and press Enter to save the current configuration.
-
Press the letter Q to bring up the exit Save screen as follows.
-
Press the letter Y to save the configuration and exit the Modify Configuration page.
-
-
Switch to the root directory of openvela repository and execute the following commands one by one in a terminal:
# Clean up build artifacts ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap distclean -j$(nproc) # Start to build ./build.sh vendor/openvela/boards/vela/configs/goldfish-armeabi-v7a-ap -j$(nproc)
-
After successful execution, you will get the following files:
./nuttx ├── vela_ap.elf ├── vela_ap.bin
The font and image resources used by the music player are located in “apps/packages/demos/music_player/res”.To push these resources to the corresponding file paths mounted by the emulator, follow the steps below.
-
Switch to the root directory of openvela repository and start the emulator:
./emulator.sh vela
-
Push resources to the device by using emulator-supported ADB. Open a new terminal in the root directory of openvela repository, type “adb push” followed by the file path to transfer the resources to the appropriate location.
#Install adb sudo apt install android-tools-adb #Push resources adb push apps/packages/demos/music_player/res /data/
Enter the following command in the emulator's terminal environment “openvela-ap”:
music_player &
Shut down the emulator to exit Demo, as shown below:
-
Modify the configuration under “apps/packages/demos/music_player/res” to add new music media files in the “res/musics” directory. Only the “_.wav” format is currently supported. You can convert file formats “_.mp3/aac/m4a” to “*.wav”.Then, modify the “res/musics/manifest.json” file in that directory:
{ "musics": [ { "path": "UnamedRhythm.wav", "name": "UnamedRhythm", "artist": "Benign X", "cover": "UnamedRhythm.png", "total_time": 12000, "color": "#114514" } ] }
Parameters Description of parameters path File path of the media item to be played name Name of the media item artist Name of the artist cover Cover path. If no cover is provided, the cover will be displayed. total_time The total playing duration of the media item in “milliseconds”. color Theme color, not currently used. Refer to the format. Add the media item you want to play to that configuration file.
For example, to add music “Happiness.wav” with a playing time of 186,507 ms, you can modify it as follows.
{ "musics": [ { "path": "UnamedRhythm.wav", "name": "UnamedRhythm", "artist": "Benign X", "cover": "UnamedRhythm.png", "total_time": 12000, "color": "#114514" }, { "path": "Happiness.wav", "name": "Xin", "artist": "Tang", "cover": "Good.png", "total_time": 186507, "color": "#252525" }, ] }
After modifying the configuration, you need to push resources again by executing the following command:
# Push resources adb push apps/packages/demos/music_player/res /data/
-
Exit the emulator.