简体   繁体   中英

How to upload Mp3 files on Qt (QMediaPlayer)?

I have to create a Qt application that executes mp3 files. I use the library QMediaPlayer, how can I let the user choose and upload the mp3 file?

QMediaPlayer has a setMedia method which can accept a path to you local .mp3 file. It can be used like this.

QMediaPlayer *player = new QMediaPlayer;
player->setMedia(QUrl::fromLocalFile("C:\mycoolsong.mp3"));

I guess you want to build something like a file explorer from where the user can select from multiple songs. There is a great tutorial for this here: C++ Qt 49 - QFileSystemModel a simple file explorer example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM