QMPwidget is a small class which allows Qt developers to embed an MPlayer instance into their application for convenient video playback. Starting with version 4.4, Qt can be build with Phonon, the KDE multimedia framework (see http://doc.trolltech.com/phonon-overview.html for an overview). However, the Phonon API provides only a limited amount of functionality, which may be too limited for some purposes.
In contrast, this class provides a way of embedding a full-fledged movie player within an application. This means you can use all of MPlayer's features, but also that you will need to ship a MPlayer binary with your application if you can't make sure that it is already installed on a user system.
For more information about MPlayer, please visit http://www.mplayerhq.hu/ .
Please note that in the following, it is assumed you are already using QMake to manage your build system.
In order to include QMPwidget as a library, your build system needs to be set up using the
src directory of the source distribution to your project tree. You might want to rename it, e.g. to
qmpwidget. Afterwards, rename
src.pro to match your directory name, e.g.
qmpwidget.pro, and adjust it to your needs. Finally, add the directory to your existing
SUBDIRS defintion of the parent directory's project file.
By default, QMPwidget will be built as a single static library located in the parent directory. Therefore, the parts of the program using the widget need to link against it. Furthermore, the directory containing the QMPwidget source should be included in the respective
You can also simply add the following files to your project:
|QMPwidget class definition|
|QMPwidget class implementation and related helper classes|
|Optional: Needs to be included for pipe mode|
You can use QMPwidget just like any other QWidget. First, you should make sure that the MPlayer path used is correct (QMPwidget::mplayerPath()). Next, you can start the MPlayer process using QMPwidget::start(). Finally, load and play a media file or url with QMPwidget::load().
Please refer to the QMPwidget class documentation for detailed usage information.
Normally, embedding MPlayer into a GUI application is done by attaching the process to an existing window. Unfortunately, this doesn't work on Mac OS X at all, so QMPwidget provides an additional "pipe mode" for running MPlayer on this operating system. Although this mode works on all operating systems, the standard mode should perform significantly better in terms of CPU usage and audio / video synchronization.
The pipe mode is included if the QMake configuration variable
pipemode is set.
The following keyboard shortcuts are implemented. However, you can reimplement QMPwidget::keyPressEvent() and extend this list, of course.
|Close the widget|
|Adjust audio delay by +/- 0.1 seconds|
|Seek backward/forward 10 seconds|
|Seek backward/forward 1 minute|
|Seek backward/forward 10 minutes|
|Increase or decrease PCM volume|
|Adjust subtitle delay by +/- 0.1 seconds|
A table listing the corresponding key codes can be found at the Qt documentation.
qmpwidget - A Qt widget for embedding MPlayer Copyright (C) 2010 by Jonas Gehring 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/>.
QMPwidget uses the YCbCr to RGB conversion routines from mjpegtools (http://mjpeg.sourceforge.net/).