我正在为 Symbians 开发音乐播放器,需要播放手机内存中的原始音频数据 (PCM)。
我尝试了 QAudioOutput,它工作正常(通过 Qbuffer - iherits QIODevice),但它是太多的低级 API,因此不适合我。所以我找到了 Phonon 和 QMediaPlayer。
我无法让 Phonon 在我的手机和 Windows 上工作。但是,在 Windows 上,我可以播放文件,但不能播放 QBuffers ......奇怪。
但是,现在我想使用 QMediaPlayer 但还没有找到从内存中播放原始数据的方法。 QMediaContent 只有 QUrl 构造函数。
是否有任何选项如何从 QBuffer、QDataStream、QByteArray... 在内存中播放 QMediaPlayer?
任何建议都会很棒,谢谢:)。
最佳答案
在桌面上,我使用普通的 GStreamer(没有声子层)从内存中播放。 Phonon 后端不能很好地处理来自内存 (QIODevice) 的媒体。来自 Qt 文档:
Warning: On Windows, we only support QIODevices containing the avi, mp3, or mpg formats. Use the constructor that takes a file name to open files (the Qt backend does not use a QFile internally).
关于Qt MediaPlayer 从内存中播放音频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6662016/