mirror of
https://github.com/wang-bin/QtAV.git
synced 2026-10-18 13:11:13 +08:00
examples: remove vo-gl, add a minimal player example
This commit is contained in:
@@ -3,6 +3,7 @@ TEMPLATE = subdirs
|
||||
SUBDIRS += \
|
||||
common \
|
||||
sharedoutput \
|
||||
simpleplayer \
|
||||
player \
|
||||
filters \
|
||||
videographicsitem \
|
||||
@@ -11,10 +12,6 @@ SUBDIRS += \
|
||||
|
||||
player.depends += common
|
||||
|
||||
config_gl {
|
||||
SUBDIRS += vo-gl
|
||||
}
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4):qtHaveModule(quick) {
|
||||
SUBDIRS += QMLPlayer \
|
||||
qmlvideofx
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/******************************************************************************
|
||||
Simple Player: this file is part of QtAV examples
|
||||
Copyright (C) 2012-2014 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
#include <QApplication>
|
||||
|
||||
#include <QtAV/AVPlayer.h>
|
||||
#include <QtAV/WidgetRenderer.h>
|
||||
#include <QtAV/OSDFilter.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QtAV::WidgetRenderer renderer;
|
||||
renderer.osdFilter()->setShowType(QtAV::OSD::ShowNone); //default show current time and total time
|
||||
renderer.show();
|
||||
renderer.setWindowTitle("minimal player--QtAV " + QtAV_Version_String_Long() + " wbsecg1@gmail.com");
|
||||
QtAV::AVPlayer player;
|
||||
player.setRenderer(&renderer);
|
||||
|
||||
if (argc > 1)
|
||||
player.play(a.arguments().last());
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
@@ -7,6 +7,3 @@ include($$PROJECTROOT/src/libQtAV.pri)
|
||||
preparePaths($$OUT_PWD/../../out)
|
||||
|
||||
SOURCES += main.cpp
|
||||
HEADERS +=
|
||||
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/******************************************************************************
|
||||
Simple Player: this file is part of QtAV examples
|
||||
Copyright (C) 2012-2013 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
******************************************************************************/
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QtCore/QLocale>
|
||||
#include <QtCore/QTranslator>
|
||||
|
||||
#include <QtAV/AVPlayer.h>
|
||||
#include <QtAV/GLWidgetRenderer.h>
|
||||
|
||||
using namespace QtAV;
|
||||
|
||||
static FILE *sLogfile = 0; //'log' is a function in msvc math.h
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
#define qInstallMessageHandler qInstallMsgHandler
|
||||
void Logger(QtMsgType type, const char *msg)
|
||||
{
|
||||
#else
|
||||
void Logger(QtMsgType type, const QMessageLogContext &, const QString& qmsg)
|
||||
{
|
||||
const char* msg = qPrintable(qmsg);
|
||||
#endif
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
fprintf(stdout, "Debug: %s\n", msg);
|
||||
if (sLogfile)
|
||||
fprintf(sLogfile, "Debug: %s\n", msg);
|
||||
break;
|
||||
case QtWarningMsg:
|
||||
fprintf(stdout, "Warning: %s\n", msg);
|
||||
if (sLogfile)
|
||||
fprintf(sLogfile, "Warning: %s\n", msg);
|
||||
break;
|
||||
case QtCriticalMsg:
|
||||
fprintf(stderr, "Critical: %s\n", msg);
|
||||
if (sLogfile)
|
||||
fprintf(sLogfile, "Critical: %s\n", msg);
|
||||
break;
|
||||
case QtFatalMsg:
|
||||
fprintf(stderr, "Fatal: %s\n", msg);
|
||||
if (sLogfile)
|
||||
fprintf(sLogfile, "Fatal: %s\n", msg);
|
||||
abort();
|
||||
}
|
||||
fflush(0);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QTranslator ts;
|
||||
if (ts.load(qApp->applicationDirPath() + "/i18n/QtAV_" + QLocale::system().name()))
|
||||
a.installTranslator(&ts);
|
||||
QTranslator qtts;
|
||||
if (qtts.load("qt_" + QLocale::system().name()))
|
||||
a.installTranslator(&qtts);
|
||||
|
||||
sLogfile = fopen(QString(qApp->applicationDirPath() + "/log.txt").toUtf8().constData(), "w+");
|
||||
if (!sLogfile) {
|
||||
qWarning("Failed to open log file");
|
||||
sLogfile = stdout;
|
||||
}
|
||||
qInstallMessageHandler(Logger);
|
||||
|
||||
GLWidgetRenderer renderer;
|
||||
renderer.show();
|
||||
renderer.setWindowTitle("QtAV " + QtAV_Version_String_Long() + " wbsecg1@gmail.com");
|
||||
//renderer.resize(800, 600);
|
||||
QString fileName;
|
||||
if (argc > 1)
|
||||
fileName = a.arguments().at(1);
|
||||
|
||||
AVPlayer player;
|
||||
player.setRenderer(&renderer);
|
||||
if (!fileName.isEmpty()) {
|
||||
player.play(fileName);
|
||||
}
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user