1

Please help me to play video from URL LAN network in Qt. I have an IP camera with URL = 192.168.1.101:8080/video, and here is my qt code

#include "dialog.h"
#include <QApplication>
#include <QMediaPlayer>
#include <QVideoWidget>
#include <QNetworkRequest>
#include <QDebug>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QMediaPlayer *_player = new QMediaPlayer;
    QVideoWidget *_vw = new QVideoWidget;
    _player->setVideoOutput(_vw);
    const QUrl url = QUrl("http://192.168.1.101:8080/video");
    const QNetworkRequest requete(url);
    _player->setMedia(requete);
    _vw->setGeometry(100,100,300,400);
    _vw->show();
    _player->play();

    return a.exec();
}

But it not work. I have tested with video from local host and it ok. Thank you and sorry for my English.

Shymaxtic
  • 37
  • 1
  • 9
  • Possible duplicate of [How do i play a stream with QMediaPlayer](https://stackoverflow.com/questions/30507317/how-do-i-play-a-stream-with-qmediaplayer) – 0xbaadf00d Oct 11 '19 at 06:02

1 Answers1

0

You can put directly URL to setMedia(...) function: _player->setMedia(url);. I've checked it by playing the stream in QML VideoOutput with C++ QMediaPlayer using the setMedia(QUrl("http://127.0.0.1:8080"));
The stream was created by VLC media player using the HTTP to the 8080 port.

Alkin
  • 1