QMediaPlayer - playing youtube music

 ̄綄美尐妖づ 提交于 2019-11-30 21:05:45

问题


Qt5 introduced QMediaPlayer but it can't play youtube link (I want only music). What I found is that in Qt 4.8 (phonon) it could but in Qt5 I get error:

Missing decoder for 'text/html'. GStreamer has no plugin for it

It is pure translation from Polish output in Qt creator. Is it a matter of GStreamer plugin or should I download HTML content, find direct link to media and play it? Any idea?

Code:

mMediaPlayer.setMedia(QUrl("http://youtu.be/wVvoQIdD80U"));
mMediaPlayer.play();

回答1:


Link to youtube video is link to web page, that contain link to media. First off all you need to extract this URL from web page than handle this URL.

You may look, how to do this in Qt-YouTube project on GitHub.



来源:https://stackoverflow.com/questions/30178577/qmediaplayer-playing-youtube-music

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!