Playing ogg files without QMediaPlayer
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 :)
Re: Playing ogg files without QMediaPlayer
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,
_
Re: Playing ogg files without QMediaPlayer
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 ?
Re: Playing ogg files without QMediaPlayer
I think you can couple QAudioDecoder with QAudioOutput. Decoded frames can be written to a device returned from QAudioOutput::start().
Re: Playing ogg files without QMediaPlayer
Quote:
Originally Posted by
wysota
I think you're right. Unfortunatly, i don't know how to do this.
jlf
Re: Playing ogg files without QMediaPlayer
Quote:
Originally Posted by
frucot
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,
_
Re: Playing ogg files without QMediaPlayer
Because of Qt 5 phonon isn't available.
Re: Playing ogg files without QMediaPlayer
Quote:
Originally Posted by
frucot
Unfortunatly, i don't know how to do this.
What have you tried so far?
Re: Playing ogg files without QMediaPlayer
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 :(
Re: Playing ogg files without QMediaPlayer
Quote:
Originally Posted by
frucot
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,
_
Re: Playing ogg files without QMediaPlayer
Quote:
Originally Posted by
frucot
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.