How can i watch internetstreams with phonon?
-
Hi all,
Im sorry for the many questions i have this evening, but again i have a problem.I want to know if it is possible to watch streams from the internet trough phonon.
I have the following code that works perfect to play a local file.
The function that plays the file:
@
int Widget::playVideo(QString filename)
{
obj_MediaObject->clearQueue ();
obj_MediaObject->enqueue(Phonon::MediaSource(filename));
//var_MediaObject->setCurrentSource(filename); //is also possible
Phonon::createPath(obj_MediaObject, wid_videoWidget);
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory,this);
Phonon::createPath(obj_MediaObject, audioOutput);
obj_MediaObject->play();
return 0;
}
@
The code to set the phonon widgets
@
void Widget::setupAppearance()
{
//Widgets on window
obj_MediaObject = new Phonon::MediaObject(this);
wid_videoWidget = new Phonon::VideoWidget(this);
wid_videoWidget->resize(this->size());
}
@And the call:
@
playVideo("pathtofile.mp4"); //works perfect!playVideo("pathtofile.avi"); // works perfect!
playVideo("http://streaming.azpm.org/kuaz128.mp3.m3u"); //works i can here the stream!
playVideo("http://www.youtube.com/watch?v=GEf6d4FqNn4"); //Doesnt work. :(
// Gives the following application output:
demux_wavpack: (open_wv_file:127) open_wv_file: non-seekable inputs aren't supported yet.
demux_wavpack: (open_wv_file:127) open_wv_file: non-seekable inputs aren't supported yet.
MyPhonon(19393)/kio (KIOJob) KIO::SimpleJob::doKill: KIO::TransferJob(0xa56fb58) This is overkill.playVideo("http://cgi.omroep.nl/legacy/player?/ceres/1/avro/rest/2011/AVRO_1409254/bb.20110106.asf");//crash: The program has unexpectedly finished.
playVideo("mms://tempo14.omroep.nl/thema_journaal24-bb-public?/nos/journaal24-bb&md5=ed9b76efd49d780959b1f94563e980d8&t=4da653d6");//crash
playVideo("http://livestreams.omroep.nl/nos/journaal24-bb");//crash
playVideo("http://nos.nl/journaal24.html"); //doesnt work
//gives the following application output:
demux_wavpack: (open_wv_file:127) open_wv_file: non-seekable inputs aren't supported yet.
MyPhonon(19393)/kio (KIOJob) KIO::SimpleJob::doKill: KIO::TransferJob(0xa56fb58) This is overkill.
@Is it possible to use phonon to watch this streams or do i have to use QtMultimediaKit ?
-
Not sure about youtube or asf, but I've tried year or couple ago to stream remote video (it was standard video file, don't remember format, mov I think) and it worked fine.
-
Hi Denis Kormalev,
Thanks for your reply,
So you dont know, how it is possible to watch the other formats?There is something strange about for example this stream:
http://livestreams.omroep.nl/nos/journaal24-bb
It works perfect in xine, but not in my app, although i have also the xine-plugin installed.
-
Soory, but I can say only about standard video formats, not internet ones. I've played with phonon not much and only as experimental future for one of projects.
-
Hi vinb,
I write a sample application with the code you attached. The video can't be played. Why? How to fix this problem? Thanks a lot.
- Frank
-
Hi Frank,
Wich video do you mean? if it is a local one, you can play almost everything. My only problem was the streaming media and youtube. I know that it has to work i only didnt figured out yet how to do it.
Did you add += phonon in your pro file?Edit:
under construction but the player code works:
The .pro file:
http://pastebin.com/7WrPrvtBThe player widget = just a plain widget.
The videoplayer.h file:
http://pastebin.com/50DhtX11The videoplayer.cpp file:
http://pastebin.com/9xmDviRSYou see its still uder conctruction, but it will play a local file without problems.
i put my call to the the file to play in the constructor, only for testing purpose. :) -
Hi vinb, I have installed DirectX and Windows SDK. Thanks.
-
Hi vinb,
In fact, my sample is just a local application. It included Phonon. It can run, but failed to play all videos(such as, mp4, avi, and etc.). This sample is important for me.
-
i editted my last post, so you can play with the files. :)
Im working on a linuxbox, so i dont know if its ok in windows.
But i didnt use platform independed code, so i quess there will be no problem.Why it is so important for you, if i may ask?
edit:
Im working on the playlist now.
After that i will look again to the internet issues. -
Hi vinb,
Here are my code.
@
QStringList types = Phonon::BackendCapabilities::availableMimeTypes();
int number = types.size(); // types is not empty.
foreach(const QString& type, types)
{
std::string theType = type.toStdString();
std::cout << theType << std::endl;
}QWidget* pane = new QWidget; QVBoxLayout* layout = new QVBoxLayout; Phonon::MediaObject* media = new Phonon::MediaObject(pane); media->setCurrentSource(QString("HelloTest.mp4")); Phonon::VideoWidget* video = new Phonon::VideoWidget(pane); Phonon::createPath(media, video); Phonon::AudioOutput* audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, pane); Phonon::createPath(media, audioOutput); layout->addWidget(video); pane->setLayout(layout); pane->setFixedSize(QSize(600, 400)); media->play(); pane->show();
@
-
It is important because playing video is a part of my work. :-|
-
i cant see what is wrong with your code :(
What kind of mime types is the output from theType?
If avi and mp4 is in it, then it should work.(same as my inet issues :( )Look "here":http://doc.trolltech.com/4.7-snapshot/phonon-overview.html#installing-phonon if you might miss something.
edit: i saw that you also need directshow. -
yes. it include "video/mp4, video/avi". So, I feel strange also why it can't play mp4 and avi.
-
what is your application output when you try?
-
Thanks vinb.
I fixed this problem. On windows, need to install a Direct Show splitter. After installed it, my video player works perfect. Anyway, thank you so much.
- Frank
-
Nice to hear Frank!
If you let me know, when you know the solution to my inet issue, let me know please. :)
Bye the way, can you try:
http://livestreams.omroep.nl/nos/journaal24-bb
and a youtube for me please? -
Hi!
I have been redirected here from the other post :)
The problem for youtube from this code
bq. playVideo("http://www.youtube.com/watch?v=GEf6d4FqNn4"); //Doesnt work. :(
is not the direct link to the stream: in few words you must query youtube with something like:
bq. http://www.youtube.com/get_video_info?&video_id=GEf6d4FqNn4&el=embedded&ps=default&eurl=&gl=US&hl=en
"reference here":http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Retrieving_and_searching_for_videos
you will get an xml or a json data to parse and within that you can parse related streams with different formats to gather which video stream you want to play (reference almost on the link above).In other words, you can't play an html (or xml or wathever) page with phonon :) you must retrieve a direct stream media link and have relative codec to play it. For example that http://livestreams.omroep.nl/nos/journaal24-bb is an ASF video format. I tried it in linux with my app but can't play.
To check which codec are supported on your platform you can do this:
@QStringList sl=Phonon::BackendCapabilities::availableMimeTypes();
qDebug() << sl;
@
My app is "here":http://mediadownloader.cz.cc, its free and you can see sources in youtube.cpp to understand how it works. And if you use linux, there is a feature that can monitor firefox and if you are browsing a web page with a compatible streaming video, it will be displayed in the app :)
I have the problem that new html5 youtube videos, needs cookies to be played, and I don't know how to tell phonon to use cookies I got when I query to retrieve video infos.regards
Marco -
Hi Marco,
thanks for the advice!
I will take a look at your app as well as the other link you gave me.
But what i dont understand is the stream in asf format. Xine is the backend of my app and xine can play the stream without a problem. Why then it is not possible in my app?
When i run the capability app provided by Qt in the examples i can see that "x-ms-asf" is indeed supported. So it has to be possible.
Thanks,
vinb -
Hi vinb,
I think that with this post I'll become an Ant :)
btw, if you download that http://livestreams.omroep.nl/nos/journaal24-bb you will see that it is an xml containing the references of mms kind of live streams. If you play one of those, it will play correctly with phonon (I tried). Evidently xine has a parser for that kind of types.
Marco
-
Hi Marco,
So you mean i have to download it and play the downloaded content?
Thanks for helping!
vinb.btw, i looked at your app. WOW, very impressive!
But i have a problem building it. i seem to miss XTest.h, but i have x11-xext-dev installed.:(