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::fromLocalFile("big_buck_bunny_480p_surround-fix.avi"));
// 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("C:/Users/nick.herniman/Downloads/big_buck_bunny_1080p_h264.mov")); player->setMedia(QUrl("rtsp://localhost:8554/stream")); player->play();
*/
w.show();return a.exec();
}@
.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 = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
@ -
Hi,
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 ?)
-
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.