PDA

View Full Version : Playing ogg files without QMediaPlayer



frucot
16th December 2013, 09:25
Using Qt 5, i want to play ogg files, but i want the user can choose the outputdevice (i.e. HeadSet, speakers)
While QMediaplayer is not able to set a outputdevice, i want to play ogg files in an other way.

I was thinking to use QAudioOutput but it only play uncompressed files :(
QAudioDecoder decompresses the files in a QAudioBuffer but i don't know how to play them :(

Help needed :)

anda_skoa
16th December 2013, 10:57
Can't the use choose the output device through the system's audio tools?

At least on Linux that works independent of the application creating the audio, it is simply controlled by PulseAudio.

Cheers,
_

frucot
16th December 2013, 12:42
Thanks for your reply :)
But no, children may change the outputdevice in the software. This was possible with phonon without pain :confused: And this may be portable on other plateform Desktop, laptop, tablet linux windows Android.
QAudioRecorder can change simply his inputdevice why QMediaPlayer not ?

wysota
16th December 2013, 13:20
I think you can couple QAudioDecoder with QAudioOutput. Decoded frames can be written to a device returned from QAudioOutput::start().

frucot
16th December 2013, 13:45
I think you can couple QAudioDecoder with QAudioOutput. Decoded frames can be written to a device returned from QAudioOutput::start().

I think you're right. Unfortunatly, i don't know how to do this.

jlf

anda_skoa
16th December 2013, 19:37
This was possible with phonon without pain :confused:

That may be a stupid question, but it it works with Phonon, why not use Phonon?

Cheers,
_

frucot
16th December 2013, 19:46
Because of Qt 5 phonon isn't available.

wysota
17th December 2013, 07:24
Unfortunatly, i don't know how to do this.
What have you tried so far?

frucot
17th December 2013, 08:34
I can decode an ogg file with QAudioDecoder *m_decoder and i get a QAudioBuffer by doing m_decoder->read() in a slot called on signal bufferready.
But i can't pass this QAudioBuffer to QAudioOuput who need a QIODevice*
I think i may subclass QIODevice to give QAudioOutput the ability to read this QAudioBuffer. right ?
At this point, i don't know what to do :(

sorry for my poor english :(

anda_skoa
17th December 2013, 09:26
Because of Qt 5 phonon isn't available.

There was no release yet, true. Might still be easier to use it from source than switching multimedia APIs.

Cheers,
_

wysota
17th December 2013, 12:12
I can decode an ogg file with QAudioDecoder *m_decoder and i get a QAudioBuffer by doing m_decoder->read() in a slot called on signal bufferready.
But i can't pass this QAudioBuffer to QAudioOuput who need a QIODevice*
I think i may subclass QIODevice to give QAudioOutput the ability to read this QAudioBuffer. right ?
At this point, i don't know what to do :(

sorry for my poor english :(

If you call QAudioOutput::start() it will return an QIODevice instance you should write your audio frames to. So whenerver you have data in the buffer, just write it to the device returned by QAudioOutput.