mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
QT5.2 Remove VLC Dependency
.. if you are building with QT5.2.1 or higher we are no longer going to use VLC for video playback. .. the QT Multimedia module seems to finally have made the grade and works as advertised on Linux and Windows .. FOR NOW we will continue to use QTKit on Mac but that may also change soon. This is to enable overlays -- placing the video behind the charts etc.
This commit is contained in:
@@ -28,6 +28,11 @@ VideoWindow::VideoWindow(Context *context, const QDir &home) :
|
||||
QHBoxLayout *layout = new QHBoxLayout();
|
||||
setLayout(layout);
|
||||
|
||||
#if QT_VERSION < 0x50201
|
||||
//
|
||||
// USE VLC VIDEOPLAYER
|
||||
//
|
||||
|
||||
// config paramaters to libvlc
|
||||
const char * const vlc_args[] = {
|
||||
"-I", "dummy", /* Don't use any interface */
|
||||
@@ -63,7 +68,7 @@ VideoWindow::VideoWindow(Context *context, const QDir &home) :
|
||||
/* This is a non working code that show how to hooks into a window,
|
||||
* if we have a window around */
|
||||
#ifdef Q_OS_LINUX
|
||||
#if QT_VERSION > 0x050000
|
||||
#if QT_VERSION > 0x50000
|
||||
x11Container = new QWidget(this); //XXX PORT TO 5.1 BROKEN CODE XXX
|
||||
#else
|
||||
x11Container = new QX11EmbedContainer(this);
|
||||
@@ -78,6 +83,17 @@ VideoWindow::VideoWindow(Context *context, const QDir &home) :
|
||||
libvlc_media_player_set_hwnd (mp, (HWND)(container->winId()));
|
||||
#endif
|
||||
|
||||
#else
|
||||
// USE QT VIDEO PLAYER
|
||||
wd = new QVideoWidget(this);
|
||||
wd->show();
|
||||
|
||||
mp = new QMediaPlayer(this);
|
||||
mp->setVideoOutput(wd);
|
||||
|
||||
layout->addWidget(wd);
|
||||
#endif
|
||||
|
||||
connect(context, SIGNAL(stop()), this, SLOT(stopPlayback()));
|
||||
connect(context, SIGNAL(start()), this, SLOT(startPlayback()));
|
||||
connect(context, SIGNAL(pause()), this, SLOT(pausePlayback()));
|
||||
@@ -96,6 +112,10 @@ VideoWindow::~VideoWindow()
|
||||
|
||||
stopPlayback();
|
||||
|
||||
#if QT_VERSION < 0x50201
|
||||
|
||||
// VLC
|
||||
|
||||
/* No need to keep the media now */
|
||||
if (m) libvlc_media_release (m);
|
||||
|
||||
@@ -104,6 +124,12 @@ VideoWindow::~VideoWindow()
|
||||
|
||||
// unload vlc
|
||||
libvlc_release (inst);
|
||||
#else
|
||||
|
||||
// QT MEDIA
|
||||
delete mp;
|
||||
delete wd;
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoWindow::resizeEvent(QResizeEvent * )
|
||||
@@ -113,6 +139,7 @@ void VideoWindow::resizeEvent(QResizeEvent * )
|
||||
|
||||
void VideoWindow::startPlayback()
|
||||
{
|
||||
#if QT_VERSION < 0x50201
|
||||
if (!m) return; // ignore if no media selected
|
||||
|
||||
// stop playback & wipe player
|
||||
@@ -125,25 +152,38 @@ void VideoWindow::startPlayback()
|
||||
libvlc_media_player_play (mp);
|
||||
|
||||
m_MediaChanged = false;
|
||||
#else
|
||||
// open the media object
|
||||
mp->play();
|
||||
#endif
|
||||
}
|
||||
void VideoWindow::stopPlayback()
|
||||
{
|
||||
#if QT_VERSION < 0x50201
|
||||
if (!m) return; // ignore if no media selected
|
||||
|
||||
// stop playback & wipe player
|
||||
libvlc_media_player_stop (mp);
|
||||
#else
|
||||
mp->stop();
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoWindow::pausePlayback()
|
||||
{
|
||||
#if QT_VERSION < 0x50201
|
||||
if (!m) return; // ignore if no media selected
|
||||
|
||||
// stop playback & wipe player
|
||||
libvlc_media_player_pause (mp);
|
||||
#else
|
||||
mp->pause();
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoWindow::resumePlayback()
|
||||
{
|
||||
#if QT_VERSION < 0x50201
|
||||
if (!m) return; // ignore if no media selected
|
||||
|
||||
// stop playback & wipe player
|
||||
@@ -151,18 +191,29 @@ void VideoWindow::resumePlayback()
|
||||
startPlayback();
|
||||
else
|
||||
libvlc_media_player_pause (mp);
|
||||
#else
|
||||
mp->play();
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoWindow::seekPlayback(long ms)
|
||||
{
|
||||
#if QT_VERSION < 0x50201
|
||||
if (!m) return;
|
||||
|
||||
// seek to ms position in current file
|
||||
libvlc_media_player_set_time(mp, (libvlc_time_t) ms);
|
||||
#else
|
||||
mp->setPosition(ms);
|
||||
#endif
|
||||
}
|
||||
|
||||
void VideoWindow::mediaSelected(QString filename)
|
||||
{
|
||||
#if QT_VERSION < 0x50201
|
||||
|
||||
// VLC
|
||||
|
||||
// stop any current playback
|
||||
stopPlayback();
|
||||
|
||||
@@ -188,6 +239,11 @@ void VideoWindow::mediaSelected(QString filename)
|
||||
|
||||
m_MediaChanged = true;
|
||||
}
|
||||
#else
|
||||
// QT MEDIA
|
||||
mc = QMediaContent(QUrl::fromLocalFile(filename));
|
||||
mp->setMedia(mc);
|
||||
#endif
|
||||
}
|
||||
|
||||
MediaHelper::MediaHelper()
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#define _GC_VideoWindow_h 1
|
||||
#include "GoldenCheetah.h"
|
||||
|
||||
// QT5.2 we adopt the native video player
|
||||
#if QT_VERSION < 0x50201
|
||||
|
||||
// for vlc
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -30,6 +33,14 @@ extern "C" {
|
||||
#include <vlc/libvlc_media.h>
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <QVideoWidget>
|
||||
#include <QMediaPlayer>
|
||||
#include <QMediaContent>
|
||||
|
||||
#endif
|
||||
|
||||
// QT stuff etc
|
||||
#include <QtGui>
|
||||
#include <QTimer>
|
||||
@@ -57,7 +68,9 @@ class MediaHelper
|
||||
|
||||
private:
|
||||
QStringList supported;
|
||||
#if QT_VERSION < 0x50201
|
||||
libvlc_instance_t * inst;
|
||||
#endif
|
||||
};
|
||||
|
||||
class VideoWindow : public GcWindow
|
||||
@@ -90,10 +103,20 @@ class VideoWindow : public GcWindow
|
||||
|
||||
bool m_MediaChanged;
|
||||
|
||||
#if QT_VERSION < 0x50201
|
||||
|
||||
// vlc for older QT
|
||||
libvlc_instance_t * inst;
|
||||
//libvlc_exception_t exceptions;
|
||||
libvlc_media_player_t *mp;
|
||||
libvlc_media_t *m;
|
||||
#else
|
||||
|
||||
// QT native
|
||||
QMediaContent mc;
|
||||
QVideoWidget *wd;
|
||||
QMediaPlayer *mp;
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#if QT_VERSION > 0x050000
|
||||
|
||||
@@ -33,6 +33,8 @@ lessThan(QT_MAJOR_VERSION, 5) {
|
||||
QT += webkitwidgets widgets
|
||||
macx {
|
||||
QT += macextras
|
||||
} else {
|
||||
QT += multimedia multimediawidgets
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user