title: Play a Live video Stream using Qt
body: <p>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 <a href="https://github.com/ntadej/vlc-qt" rel="nofollow">here</a>. The problem is <strong>I do not know how to include the player in Qt.</strong> So how do I proceed? </p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QtMultimediaWidgets/QVideoWidget&gt;
  #include &lt;QtMultimedia/QMediaPlayer&gt;
  #include &lt;QtMultimedia/QMediaPlaylist&gt;
  #include &lt;QFile&gt;
  #include &lt;QHBoxLayout&gt;
  #include "DemoPlayer.h"
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
  
      QWidget *widget=new QWidget;
      widget-&gt;resize(400,300);
  
      QMediaPlayer *player=new QMediaPlayer;
      QVideoWidget *vw= new QVideoWidget;
      QHBoxLayout *layout=new QHBoxLayout;
  
      layout-&gt;addWidget(vw);
      widget-&gt;setLayout(layout);
      player-&gt;setVideoOutput(vw);
      player-&gt;setMedia(QUrl::fromLocalFile("C:/Users/Administrator/Desktop/1minute.mp4"));
      player-&gt;play();
      widget-&gt;show();
      qDebug()&lt;&lt;player-&gt;availableMetaData()&lt;&lt;player-&gt;currentMedia().canonicalUrl();
  
      return a.exec();
  }
  </code></pre>