Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Given below is the code for playing a video file using Qt. Instead of playing the video I want to play a live video stream from an IP Camera. Another approach is to embed the VLC Player in Qt and a link for the project is provided here. The problem is I do not know how to include the player in Qt. So how do I proceed?

#include <QApplication>
#include <QtMultimediaWidgets/QVideoWidget>
#include <QtMultimedia/QMediaPlayer>
#include <QtMultimedia/QMediaPlaylist>
#include <QFile>
#include <QHBoxLayout>
#include "DemoPlayer.h"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QWidget *widget=new QWidget;
    widget->resize(400,300);

    QMediaPlayer *player=new QMediaPlayer;
    QVideoWidget *vw= new QVideoWidget;
    QHBoxLayout *layout=new QHBoxLayout;

    layout->addWidget(vw);
    widget->setLayout(layout);
    player->setVideoOutput(vw);
    player->setMedia(QUrl::fromLocalFile("C:/Users/Administrator/Desktop/1minute.mp4"));
    player->play();
    widget->show();
    qDebug()<<player->availableMetaData()<<player->currentMedia().canonicalUrl();

    return a.exec();
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
556 views
Welcome To Ask or Share your Answers For Others

1 Answer

follow this code . you can embed a widget inside another widget using a valid window id . How to show output video of other application in Qt? you can use the qx11embedwidget and qx11embedwidgetcontainer QX11EmbedWidget and QX11EmbedContainer


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...