Important: Please read the Qt Code of Conduct -

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

  • 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("rtsp://"));
    // player->setMedia(QUrl(""));
    // player->setMedia(QUrl("http://localhost:8080/stream"));
    QVideoWidget *videoWidget = new QVideoWidget;
    w.setCentralWidget(videoWidget); // if w is a QMainWindow

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



    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

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

  • Lifetime Qt Champion


    Where is big_buck_bunny_480p_surround-fix.avi located ?

  • 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 ?)

  • Lifetime Qt Champion

    Gremlins in your computer ? :D

    Seriously, can't tell

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

Log in to reply