Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Media Player played once but then after first time no longer outputs video [SOLVED]

Media Player played once but then after first time no longer outputs video [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ion_knight
    wrote on last edited by
    #1

    Below is my code which is quite frankly making me want to pull my hair out. First time I ran this it started straight away, then decided to run again (after trying a RTSP url instead), and now the video won't play no matter what I do. If anyone has an idea why this is happening please let me know. Cheers

    @#include "mainwindow.h"
    #include <QApplication>
    #include <QMediaPlayer>
    #include <QFileInfo>
    #include <QDebug>
    #include <QVideoWidget>
    #include <QGraphicsView>
    #include <QGraphicsVideoItem>
    #include <QGraphicsScene>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;

    QMediaPlayer *player = new QMediaPlayer;
    player->setMedia(QUrl::fromLocalFile&#40;"big_buck_bunny_480p_surround-fix.avi"&#41;&#41;;
    

    // player->setMedia(QUrl("rtsp://192.168.100.58:8554/stream/"));
    // player->setMedia(QUrl("http://www.youtube.com/watch?v=5OC0rZCal24"));
    // player->setMedia(QUrl("http://localhost:8080/stream"));
    QVideoWidget *videoWidget = new QVideoWidget;
    w.setCentralWidget(videoWidget); // if w is a QMainWindow
    player->setVideoOutput(videoWidget);
    player->play();

    /* QGraphicsView *graphicsView = new QGraphicsView;
    // w.setCentralWidget(graphicsView); // w = QMainWindow
    QGraphicsScene *scene = new QGraphicsScene;
    QMediaPlayer *player = new QMediaPlayer;
    QGraphicsVideoItem *item = new QGraphicsVideoItem;

    graphicsView->setScene(scene);
    player->setVideoOutput(item);
    
    graphicsView->scene()->addItem(item);
    //player->setMedia(QUrl::fromLocalFile&#40;"C:/Users/nick.herniman/Downloads/big_buck_bunny_1080p_h264.mov"&#41;&#41;;
    player->setMedia(QUrl("rtsp://localhost:8554/stream"));
    player->play();
    

    */
    w.show();

    return a.exec&#40;&#41;;
    

    }@

    .pro file
    @#-------------------------------------------------

    Project created by QtCreator 2013-09-03T14:51:23

    #-------------------------------------------------

    QT += core gui multimedia widgets multimediawidgets

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = Media_player_v2
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui
    @

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Where is big_buck_bunny_480p_surround-fix.avi located ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ion_knight
        wrote on last edited by
        #3

        Slightly confused now, ran the same program again today (only thing that has changed is that I have restarted the machine), and it's working.

        Don't suppose you have any idea why this might happen as completely miffed how this could of happened (could the file be blocked for some reason ?)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Gremlins in your computer ? :D

          Seriously, can't tell

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • I Offline
            I Offline
            ion_knight
            wrote on last edited by
            #5

            Ah ok well those gremlins are bloody annoying :P. Ah well ghost in the shell i guess :P.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved