简体   繁体   English

在Windows系统上使用QMediaPlayer并在Linux上编译代码

[英]using QMediaPlayer on Windows system with code compiled on Linux

A project of mine is written with Qt5/c++, using the QMediaPlayer class to read audio files. 我的一个项目是用Qt5 / c ++编写的,使用QMediaPlayer类读取音频文件。 Everything's ok as long as I run this project on Linux. 只要我在Linux上运行此项目,一切都会好的。 Since I want to run my program on Windows, I use MXE to compile my code and create a binary file for Windows systems. 由于我想在Windows上运行程序,因此我使用MXE编译代码并为Windows系统创建一个二进制文件。

The program seems ok, except this problem with the QMediaPlayer class. 该程序看起来还可以,除了QMediaPlayer类存在此问题。 When the program runs on a Windows system, I read this message : 当程序在Windows系统上运行时,我读到此消息:

defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer".

By googling around, I came to understand that the QMediaPlayer used several plugins , different on each platform. 通过四处搜寻,我了解到QMediaPlayer使用了几个插件 ,每个平台上都有不同。 On Windows, The WMF plugin is Microsoft-only, DirectShow seems useless; 在Windows上,WMF插件仅适用于Microsoft,DirectShow似乎没有用; others suggest to use other external plugins like portaudio, SdlAudio ou OpenAI. 其他人建议使用其他外部插件,例如portaudio,SdlAudio或OpenAI。

How may I solve this problem ? 我该如何解决这个问题?

我发现了问题并知道如何解决它: 根据此线程 ,只需将以下行添加到您的.pro文件中:

QTPLUGIN += dsengine qtmedia_audioengine

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

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