I have a problem with phonon: I need to stream audio from a password protected site, and there doesn't seem to be any way to set authentication information in Phonon::MediaSource, so it displays the default Windows authentication dialog for every file I play. I figured that maybe I could use QNetworkAccessManager to stream and phonon to play, which would solve the authentication problem, but so far I wasn't able to get the two to work together.
I tried a lot of different variations, all with the basic idea that QNetworkReply inherits from QIODevice, so I should be able to set it as setCurrentSource of MediaObject. But it just refuses to play while streaming. It does work if I call play() after the entire download finishes. But it won't play while it downloads. Here's a simplified example to give you the idea:
QNetworkRequest request;
request.
setUrl(QUrl("http://localhost/mm132.mp3"));
networkReply = networkAccessManager.get(request);
mediaObject = Phonon::createPlayer(Phonon::MusicCategory);
mediaObject->setCurrentSource(networkReply);
mediaObject->play()
QNetworkRequest request;
request.setUrl(QUrl("http://localhost/mm132.mp3"));
networkReply = networkAccessManager.get(request);
mediaObject = Phonon::createPlayer(Phonon::MusicCategory);
mediaObject->setCurrentSource(networkReply);
mediaObject->play()
To copy to clipboard, switch view to plain text mode
I also tried creating a separate QByteArray and write to it in readReady() and then use it with QBuffer in read-only mode, assigning it to MediaSource, but it won't work either. Maybe my thinking is too simplistic and it needs some more complex buffering system...
Anyone has any suggestions on how this can be done? (Can it be done?) Or is there a way to overwrite that default authentication dialog in phonon and supply the user name and password some other way?
I would appreciate any ideas or snippets of code you might have. Thank you.
Bookmarks