Reputation: 23
I am working on a special application in Qt that stores its .mp3 audio files in a QSQLITE database as BLOB data.
With the following code I create a QByteArray:
QByteArray array = query->value(0).toByteArray();
Then I try to play the sound with a QMediaPlayer:
mediaPlayer.setMedia( QMediaContent( QUrl::fromEncoded(array) ) );
mediaPlayer.play();
But I unfortunately get this error:
DirectShowPlayerService::doSetUrlSource: Unresolved error code 800c000d
The main thing that I would like to achieve is to be able to play these .mp3 files that are stored in the QByteArray.
Note: Storing the pathway only in the database is not possible in that special circumstance.
I would really-very appreciate your help. Thank you very much!
Upvotes: 1
Views: 3106
Reputation: 1006
You need to provide the QByteArray
as a QIODevice
to the stream
parameter of QMediaPlayer::setMedia(const QMediaContent & media, QIODevice * stream = 0)
.
Try the following:
QBuffer mediaStream(&array);
mediaPlayer.setMedia(QMediaContent(), &buffer);
mediaPlayer.play();
Upvotes: 4