[112] | 1 | /* smplayer, GUI front-end for mplayer.
|
---|
[188] | 2 | Copyright (C) 2006-2017 Ricardo Villalba <rvm@users.sourceforge.net>
|
---|
[112] | 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"
|
---|
[176] | 22 | #include "playerprocess.h"
|
---|
| 23 | #include "playerid.h"
|
---|
[112] | 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);
|
---|
[176] | 30 | if (fi.exists() && fi.isExecutable() && !fi.isDir()) {
|
---|
| 31 | mplayer_bin = fi.absoluteFilePath();
|
---|
[112] | 32 | }
|
---|
| 33 |
|
---|
[176] | 34 | PlayerProcess * proc = PlayerProcess::createPlayerProcess(mplayer_bin, 0);
|
---|
[112] | 35 |
|
---|
[176] | 36 | proc->setExecutable(mplayer_bin);
|
---|
| 37 | proc->setFixedOptions();
|
---|
[181] | 38 | QString nframes = "1";
|
---|
| 39 | if (proc->isMPlayer()) nframes = "0";
|
---|
| 40 | proc->setOption("frames", nframes);
|
---|
[176] | 41 | proc->setOption("vo", "null");
|
---|
| 42 | proc->setOption("ao", "null");
|
---|
| 43 | #ifdef Q_OS_WIN
|
---|
| 44 | proc->setOption("fontconfig", false);
|
---|
| 45 | #endif
|
---|
| 46 | proc->setMedia(filename);
|
---|
| 47 |
|
---|
| 48 | QString commandline = proc->arguments().join(" ");
|
---|
| 49 | qDebug("InfoProvider::getInfo: command: '%s'", commandline.toUtf8().data());
|
---|
| 50 |
|
---|
| 51 | proc->start();
|
---|
| 52 | if (!proc->waitForFinished()) {
|
---|
[112] | 53 | qWarning("InfoProvider::getInfo: process didn't finish. Killing it...");
|
---|
[176] | 54 | proc->kill();
|
---|
[112] | 55 | }
|
---|
| 56 |
|
---|
[176] | 57 | MediaData md = proc->mediaData();
|
---|
| 58 | delete proc;
|
---|
| 59 |
|
---|
| 60 | return md;
|
---|
[112] | 61 | }
|
---|
| 62 |
|
---|
| 63 | MediaData InfoProvider::getInfo(QString filename) {
|
---|
| 64 | return getInfo( Global::pref->mplayer_bin, filename );
|
---|
| 65 | }
|
---|