From 0f60badc82e628619f98407e9d0d3fb9dfd601d3 Mon Sep 17 00:00:00 2001 From: Mark Liversedge Date: Mon, 31 Oct 2011 20:56:48 +0000 Subject: [PATCH] Fixup QTKit Video Playback Deallocate errors when scrolling through large numbers of videos, but otherwise functional. The redraw of the layouts needs to be looked at, since there are some nasty artefacts when resizing the video window that need to be fixed separately. --- src/QtMacVideoWindow.h | 1 + src/QtMacVideoWindow.mm | 58 ++++++++++++++++------------------------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/src/QtMacVideoWindow.h b/src/QtMacVideoWindow.h index 471ac5ee4..643fa480b 100644 --- a/src/QtMacVideoWindow.h +++ b/src/QtMacVideoWindow.h @@ -103,6 +103,7 @@ class VideoWindow : public GcWindow // passed from MainWindow QDir home; MainWindow *main; + bool hasMovie; // the active movie NativeQTMovieRef movie; diff --git a/src/QtMacVideoWindow.mm b/src/QtMacVideoWindow.mm index 7eb485d59..9a301c0b2 100644 --- a/src/QtMacVideoWindow.mm +++ b/src/QtMacVideoWindow.mm @@ -25,7 +25,7 @@ #include VideoWindow::VideoWindow(MainWindow *parent, const QDir &home) : -GcWindow(parent), home(home), main(parent) +GcWindow(parent), home(home), main(parent), hasMovie(false) { setControls(NULL); @@ -60,22 +60,32 @@ void VideoWindow::resizeEvent(QResizeEvent * ) void VideoWindow::startPlayback() { - if (!movie) return; // no movie selected + if (!hasMovie) return; // no movie selected + + [movie gotoBeginning]; + [movie play]; } void VideoWindow::stopPlayback() { - if (!movie) return; // no movie selected + if (!hasMovie) return; // no movie selected + + [movie stop]; + [movie gotoBeginning]; } void VideoWindow::pausePlayback() { - if (!movie) return; // no movie selected + if (!hasMovie) return; // no movie selected + + [movie stop]; } void VideoWindow::resumePlayback() { - if (!movie) return; // no movie selected + if (!hasMovie) return; // no movie selected + + [movie play]; } static inline NSString *darwinQStringToNSString (const QString &aString) @@ -86,21 +96,10 @@ static inline NSString *darwinQStringToNSString (const QString &aString) void VideoWindow::mediaSelected(QString filename) { -qDebug()<<"media selected:"<setMovie(movie); + + hasMovie = true; } } -MediaHelper::MediaHelper() -{ -} +MediaHelper::MediaHelper() { } -MediaHelper::~MediaHelper() -{ -} +MediaHelper::~MediaHelper() { } // convert an NSString to a QString static QString qt_mac_NSStringToQString(const NSString *nsstr) @@ -184,12 +180,7 @@ QtMacMovieView::QtMacMovieView (QWidget *parent) : QMacCocoaViewContainer (0, pa // allocate the player player = [[QTMovieView alloc] initWithFrame:frame]; [player setPreservesAspectRatio:YES]; - -#if 0 - NSSegmentedButtonTarget *bt = [[NSSegmentedButtonTarget alloc] initWithObject1:this]; - [mNativeRef setTarget:bt]; - [mNativeRef setAction:@selector(segControlClicked:)]; -#endif + [player setControllerVisible:NO]; setCocoaView (player); } @@ -197,8 +188,5 @@ QtMacMovieView::QtMacMovieView (QWidget *parent) : QMacCocoaViewContainer (0, pa void QtMacMovieView::setMovie(NativeQTMovieRef movie) { -qDebug()<<"setting the movie to qtmovieview..."; [player setMovie:movie]; -qDebug()<<"playing the movie?"; - [[player movie] play]; }