Random crashes while playing videos through Phonon on Windows
I’m having trouble with some simple video playback code. Let’s say I have 3 video files. I want to play them in a loop, every video for 10 seconds. Videos shorter than 10 seconds should be played multiple times. This is the meat of my code:
- #include "mainwindow.hpp"
- MainWindow::MainWindow(QWidget *parent) :
- timer(new QTimer(this)),
- videoPlayer(new Phonon::VideoPlayer(this))
- connect(timer, SIGNAL(timeout()), this, SLOT(advance()));
- connect(videoPlayer, SIGNAL(finished()), this, SLOT(playbackFinished()));
- void MainWindow::showEvent(QShowEvent *event)
- videoPlayer->setGeometry(10, 10, width()-20, height()-20);
- void MainWindow::advance()
- pos = (pos + 1) % playlist.size();
- void MainWindow::playbackFinished()
A complete project can be found at Bitbucket [bitbucket.org]
Screenshots of the crash and resulting debugger session:
edit: In order to get mov and mp4 files to play I installed the K-lite codec pack. Just remembered that and tried running the app with only avi and wmv files. So far it has not crashed, so the problem might be due to the other codecs.
Apologies for replying to myself. After deinstalling the 3rd party codecs and testing for a while it crashed again, but only once, where before it would crash much more often. This seems to happen when I try to play an MPEG-4 H.264 file.
BTW, I don’t understand why the file doesn’t play without any 3rd party codec on Windows 7. Windows Media Player plays it just fine. Shouldn’t everything that works in WMP also work in Phonon::VideoPlayer?
This is a huge problem for the app I’m writing. The customers expect to be able to play common video files, especially if they work in the default media player. WMV can not be used either, since that doesn’t work with the Mac version (see WMV Playback using Phonon::VideoWidget and Flip4Mac fails in 32-Bit builds [developer.qt.nokia.com]).
Any help would be greatly appreciated…