QMediaPlayer - playing youtube music

2020-03-08 07:13发布

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条回答
地球回转人心会变
2楼-- · 2020-03-08 08:18

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.

查看更多
登录 后发表回答