简体   繁体   English

如何在Qt(QMediaPlayer)上上传Mp3文件?

[英]How to upload Mp3 files on Qt (QMediaPlayer)?

I have to create a Qt application that executes mp3 files. 我必须创建一个执行mp3文件的Qt应用程序。 I use the library QMediaPlayer, how can I let the user choose and upload the mp3 file? 我使用库QMediaPlayer,如何让用户选择并上传mp3文件?

QMediaPlayer has a setMedia method which can accept a path to you local .mp3 file. QMediaPlayer具有setMedia方法,该方法可以接受本地.mp3文件的路径。 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 这里有一个很棒的教程: C ++ Qt 49-QFileSystemModel一个简单的文件浏览器示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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