You can also read a translated version of this file in Chinese 简体中文版.
This is an audio player project based on PyQt5 and follows the MVC framework. The project was developed on Ubuntu 20.04 and supports playing songs in a specific folder, sequential playback, single-song loop, random playback, and other basic functions. Additionally, it implements the feature of variable playback speed.
- Project Repository: https://github.com/yuan2001425/yuanMusic
- Demo Video: https://www.bilibili.com/video/BV1aa4y1B7WW
- Blog Address: https://yuan425.blog.csdn.net/article/details/135234255
Use the following commands to create the virtual environment required for the project:
conda env create -f environment.yml
conda activate yuanMusic
1. Prepare Audio Files
You can choose to create an empty music
folder and add audio files yourself:
mkdir music
Alternatively, unzip the provided sample music (popular songs by Eason Chan):
Link: https://pan.baidu.com/s/1EG0QBhtZ_KfbkuHmxejUeA?pwd=i9pz
Extraction Code: i9pz
--Shared from Baidu Cloud Super Member V5
unzip music.zip
2. Configure Audio File Types (Optional)
Open the src/controller/controller.py
file.
Modify the ALLOW_VOICE_TYPE
variable to allow playing other file types. The default is:
ALLOW_VOICE_TYPE = [".mp3", ".wav"]
3. Launch the Audio Player
Run the following command in the terminal to start the audio player:
python main.py
- Specify Folder for Playback: Choose a specific folder to play songs only from that folder.
- Playback Modes: Support sequential playback, single-song loop, and random playback.
- Variable Playback Speed: Provide options for variable playback speed to accelerate or decelerate audio playback.
-
Launch the Application:
- After opening the application, use the controls on the interface to select the playback mode and target folder.
- The system will automatically detect playable audio files in the directory and display them in the list.
- By default, the system will automatically play the first song in the playlist.
-
Audio Playback Control:
- Click the play button to play and pause audio.
- Adjust the audio playback progress easily by dragging the slider.
-
Audio Switching and Adjustment:
- Use the previous and next buttons or double-click on a song in the list to switch audio conveniently.
- Adjust loop mode and playback speed to meet personalized preferences.
-
Exit the Application:
- To exit the application, simply click the close button in the upper right corner of the window.
- doc: Related documents
- music: Sample music directory
- src: Source code
- controller: Control logic
controller.py
- model: Audio model
model.py
- view: Display interface
- UI: UI interface generated by QtDesigner
Widget.py
Widget.ui
view.py
: Personalized frontend
- UI: UI interface generated by QtDesigner
- controller: Control logic
environment.yml
: Dependency installationmain.py
: Function entry pointREADME_CN.md
: Chinese project introductionREADME.md
: English project introduction
- Make sure Python 3.10 or above is installed.
- Before running the application, ensure that the environment is configured and the virtual environment is activated.
- Python Version: 3.10
- PyQt Version: 5.15
Author: YuanGeTingLe
(CSDN/Bilibili/GitHub/WeChat Official Account with the same name)
For any questions or suggestions, please contact the author: yuan2001425@163.com