~john.vrbanac/ubuntu-app-reviews/minicast

« back to all changes in this revision

Viewing changes to qmpwidget.h

  • Committer: Aaron Lewis
  • Date: 2012-07-09 08:00:58 UTC
  • Revision ID: the.warl0ck.1989@gmail.com-20120709080058-h0x8cbtuqrza88k4
Fix duplicate file contents

Show diffs side-by-side

added added

removed removed

Lines of Context:
186
186
 
187
187
 
188
188
#endif // QMPWIDGET_H_
189
 
/* BEGIN_COMMON_COPYRIGHT_HEADER
190
 
 * (c)LGPL2+
191
 
 *
192
 
 * Copyright: 2012 Labo A.L
193
 
 * Authors:
194
 
 *   Aaron Lewis <the.warl0ck.1989@gmail.com>
195
 
 *
196
 
 * This program or library is free software; you can redistribute it
197
 
 * and/or modify it under the terms of the GNU Lesser General Public
198
 
 * License as published by the Free Software Foundation; either
199
 
 * version 2.1 of the License, or (at your option) any later version.
200
 
 *
201
 
 * This library is distributed in the hope that it will be useful,
202
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
203
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
204
 
 * Lesser General Public License for more details.
205
 
 
206
 
 * You should have received a copy of the GNU Lesser General
207
 
 * Public License along with this library; if not, write to the
208
 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
209
 
 * Boston, MA 02110-1301 USA
210
 
 *
211
 
 * END_COMMON_COPYRIGHT_HEADER */
212
 
/*
213
 
 *  qmpwidget - A Qt widget for embedding MPlayer
214
 
 *  Copyright (C) 2010 by Jonas Gehring
215
 
 *
216
 
 *  This program is free software: you can redistribute it and/or modify
217
 
 *  it under the terms of the GNU General Public License as published by
218
 
 *  the Free Software Foundation, either version 3 of the License, or
219
 
 *  (at your option) any later version.
220
 
 *
221
 
 *  This program is distributed in the hope that it will be useful,
222
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
223
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
224
 
 *  GNU General Public License for more details.
225
 
 *
226
 
 *  You should have received a copy of the GNU General Public License
227
 
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
228
 
 */
229
 
 
230
 
 
231
 
#ifndef QMPWIDGET_H_
232
 
#define QMPWIDGET_H_
233
 
 
234
 
 
235
 
#include <QHash>
236
 
#include <QPointer>
237
 
#include <QTimer>
238
 
#include <QWidget>
239
 
 
240
 
class QAbstractSlider;
241
 
class QImage;
242
 
class QProcess;
243
 
class QStringList;
244
 
 
245
 
class QMPProcess;
246
 
 
247
 
 
248
 
class QMPwidget : public QWidget
249
 
{
250
 
        Q_OBJECT
251
 
    Q_PROPERTY(State state READ state)
252
 
    Q_PROPERTY(double streamPosition READ tell)
253
 
    Q_PROPERTY(QString videoOutput READ videoOutput WRITE setVideoOutput)
254
 
    Q_PROPERTY(QString mplayerPath READ mplayerPath WRITE setMPlayerPath)
255
 
    Q_PROPERTY(QString mplayerVersion READ mplayerVersion)
256
 
    Q_ENUMS(state)
257
 
 
258
 
        public:
259
 
                enum State {
260
 
                        NotStartedState = -1,
261
 
                        IdleState,
262
 
                        LoadingState,
263
 
                        StoppedState,
264
 
                        PlayingState,
265
 
                        BufferingState,
266
 
                        PausedState,
267
 
                        ErrorState
268
 
                };
269
 
 
270
 
                struct MediaInfo {
271
 
                        QString videoFormat;
272
 
                        int videoBitrate;
273
 
                        QSize size;
274
 
                        double framesPerSecond;
275
 
 
276
 
                        QString audioFormat;
277
 
                        double audioBitrate;
278
 
                        int sampleRate;
279
 
                        int numChannels;
280
 
 
281
 
                        QHash<QString, QString> tags;
282
 
 
283
 
                        bool ok;
284
 
                        double length;
285
 
                        bool seekable;
286
 
 
287
 
                        MediaInfo();
288
 
                };
289
 
 
290
 
                enum Mode {
291
 
                        EmbeddedMode = 0,
292
 
                        PipeMode
293
 
                };
294
 
 
295
 
                enum SeekMode {
296
 
                        RelativeSeek = 0,
297
 
                        PercentageSeek,
298
 
                        AbsoluteSeek
299
 
                };
300
 
 
301
 
        public:
302
 
                QMPwidget(QWidget *parent = 0);
303
 
                virtual ~QMPwidget();
304
 
 
305
 
                State state() const;
306
 
                MediaInfo mediaInfo() const;
307
 
                double tell() const;
308
 
                QProcess *process() const;
309
 
 
310
 
                void setMode(Mode mode);
311
 
                Mode mode() const;
312
 
 
313
 
                void setVideoOutput(const QString &output);
314
 
                QString videoOutput() const;
315
 
 
316
 
                void setMPlayerPath(const QString &path);
317
 
                QString mplayerPath() const;
318
 
                QString mplayerVersion();
319
 
 
320
 
                void setSeekSlider(QAbstractSlider *slider);
321
 
                void setVolumeSlider(QAbstractSlider *slider);
322
 
 
323
 
                void showImage(const QImage &image);
324
 
 
325
 
                virtual QSize sizeHint() const;
326
 
 
327
 
        public slots:
328
 
                void start(const QStringList &args = QStringList());
329
 
                void load(const QString &url);
330
 
                void play();
331
 
                void pause();
332
 
                void stop();
333
 
                bool seek(int offset, int whence = AbsoluteSeek);
334
 
                bool seek(double offset, int whence = AbsoluteSeek);
335
 
 
336
 
                void toggleFullScreen();
337
 
 
338
 
                void writeCommand(const QString &command);
339
 
 
340
 
        protected:
341
 
                virtual void mouseDoubleClickEvent(QMouseEvent *event);
342
 
                virtual void keyPressEvent(QKeyEvent *event);
343
 
                virtual void resizeEvent(QResizeEvent *event);
344
 
 
345
 
        private:
346
 
                void updateWidgetSize();
347
 
 
348
 
        private slots:
349
 
                void setVolume(int volume);
350
 
 
351
 
                void mpStateChanged(int state);
352
 
                void mpStreamPositionChanged(double position);
353
 
                void mpVolumeChanged(int volume);
354
 
                void delayedSeek();
355
 
 
356
 
        signals:
357
 
                void stateChanged(int state);
358
 
                void error(const QString &reason);
359
 
 
360
 
                void readStandardOutput(const QString &line);
361
 
                void readStandardError(const QString &line);
362
 
 
363
 
        private:
364
 
                QMPProcess *m_process;
365
 
                QWidget *m_widget;
366
 
                QPointer<QAbstractSlider> m_seekSlider;
367
 
                QPointer<QAbstractSlider> m_volumeSlider;
368
 
                Qt::WindowFlags m_windowFlags;
369
 
                QRect m_geometry;
370
 
 
371
 
                QTimer m_seekTimer;
372
 
                QString m_seekCommand;
373
 
};
374
 
 
375
 
 
376
 
#endif // QMPWIDGET_H_