| 1 | /* smplayer, GUI front-end for mplayer.
|
|---|
| 2 | Copyright (C) 2006-2016 Ricardo Villalba <rvm@users.sourceforge.net>
|
|---|
| 3 |
|
|---|
| 4 | This program is free software; you can redistribute it and/or modify
|
|---|
| 5 | it under the terms of the GNU General Public License as published by
|
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 7 | (at your option) any later version.
|
|---|
| 8 |
|
|---|
| 9 | This program is distributed in the hope that it will be useful,
|
|---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 12 | GNU General Public License for more details.
|
|---|
| 13 |
|
|---|
| 14 | You should have received a copy of the GNU General Public License
|
|---|
| 15 | along with this program; if not, write to the Free Software
|
|---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include "infoprovider.h"
|
|---|
| 20 | #include "global.h"
|
|---|
| 21 | #include "preferences.h"
|
|---|
| 22 | #include "playerprocess.h"
|
|---|
| 23 | #include "playerid.h"
|
|---|
| 24 | #include <QFileInfo>
|
|---|
| 25 |
|
|---|
| 26 | MediaData InfoProvider::getInfo(QString mplayer_bin, QString filename) {
|
|---|
| 27 | qDebug("InfoProvider::getInfo: %s", filename.toUtf8().data());
|
|---|
| 28 |
|
|---|
| 29 | QFileInfo fi(mplayer_bin);
|
|---|
| 30 | if (fi.exists() && fi.isExecutable() && !fi.isDir()) {
|
|---|
| 31 | mplayer_bin = fi.absoluteFilePath();
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | PlayerProcess * proc = PlayerProcess::createPlayerProcess(mplayer_bin, 0);
|
|---|
| 35 |
|
|---|
| 36 | proc->setExecutable(mplayer_bin);
|
|---|
| 37 | proc->setFixedOptions();
|
|---|
| 38 | proc->setOption("frames", "1");
|
|---|
| 39 | proc->setOption("vo", "null");
|
|---|
| 40 | proc->setOption("ao", "null");
|
|---|
| 41 | #ifdef Q_OS_WIN
|
|---|
| 42 | proc->setOption("fontconfig", false);
|
|---|
| 43 | #endif
|
|---|
| 44 | proc->setMedia(filename);
|
|---|
| 45 |
|
|---|
| 46 | QString commandline = proc->arguments().join(" ");
|
|---|
| 47 | qDebug("InfoProvider::getInfo: command: '%s'", commandline.toUtf8().data());
|
|---|
| 48 |
|
|---|
| 49 | proc->start();
|
|---|
| 50 | if (!proc->waitForFinished()) {
|
|---|
| 51 | qWarning("InfoProvider::getInfo: process didn't finish. Killing it...");
|
|---|
| 52 | proc->kill();
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | MediaData md = proc->mediaData();
|
|---|
| 56 | delete proc;
|
|---|
| 57 |
|
|---|
| 58 | return md;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | MediaData InfoProvider::getInfo(QString filename) {
|
|---|
| 62 | return getInfo( Global::pref->mplayer_bin, filename );
|
|---|
| 63 | }
|
|---|