QMediaPlayer-播放YouTube音乐 [英] QMediaPlayer - playing youtube music
问题描述
Qt5引入了QMediaPlayer
,但是它不能播放youtube链接(我只想要音乐).我发现的是,在Qt 4.8(声子)中可以,但是在Qt5中我得到了错误:
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:
缺少"text/html"的解码器. GStreamer没有插件
Missing decoder for 'text/html'. GStreamer has no plugin for it
这是Qt Creator中波兰语输出的纯译本.是GStreamer插件的问题还是我应该下载HTML内容,找到与媒体的直接链接并进行播放?有什么主意吗?
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?
代码:
mMediaPlayer.setMedia(QUrl("http://youtu.be/wVvoQIdD80U"));
mMediaPlayer.play();
推荐答案
与youtube视频的链接是指向网页的链接,其中包含指向媒体的链接.首先,您需要从网页提取此URL,然后再处理此URL.
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.
您可能会在 Qt-YouTube项目中查看如何做GitHub .
这篇关于QMediaPlayer-播放YouTube音乐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!