2009-02-08 22:20:41 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2009 Marco Martin <notmart@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, 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 Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PLASMA_VIDEOWIDGET_H
|
|
|
|
#define PLASMA_VIDEOWIDGET_H
|
|
|
|
|
2012-02-02 10:35:53 +01:00
|
|
|
#include <QGraphicsProxyWidget>
|
2009-02-08 22:20:41 +01:00
|
|
|
|
2009-02-08 22:41:08 +01:00
|
|
|
#include <plasma/plasma_export.h>
|
|
|
|
|
2009-02-08 22:20:41 +01:00
|
|
|
namespace Phonon {
|
|
|
|
class VideoWidget;
|
|
|
|
class MediaObject;
|
|
|
|
class AudioOutput;
|
|
|
|
}
|
|
|
|
|
2009-02-11 22:34:07 +01:00
|
|
|
class KUrl;
|
|
|
|
|
2009-02-08 22:20:41 +01:00
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
|
|
|
class VideoWidgetPrivate;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class VideoWidget plasma/widgets/videowidget.h <Plasma/Widgets/VideoWidget>
|
2009-02-09 17:09:34 +01:00
|
|
|
* a Video playing widget via Phonon, it encloses the
|
|
|
|
* Phonon::MediaObject and Phonon::AudioOutput too
|
2009-02-08 22:20:41 +01:00
|
|
|
*
|
|
|
|
* @short Provides a video player widget
|
2009-02-09 17:09:34 +01:00
|
|
|
* @since KDE4.3
|
2009-02-08 22:20:41 +01:00
|
|
|
*/
|
2009-02-08 22:41:08 +01:00
|
|
|
class PLASMA_EXPORT VideoWidget : public QGraphicsProxyWidget
|
2009-02-08 22:20:41 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2009-02-11 22:34:07 +01:00
|
|
|
Q_PROPERTY(QString url READ url WRITE setUrl)
|
2009-06-18 21:46:11 +02:00
|
|
|
Q_PROPERTY(qint64 currentTime READ currentTime)
|
|
|
|
Q_PROPERTY(qint64 totalTime READ totalTime)
|
|
|
|
Q_PROPERTY(qint64 remainingTime READ remainingTime)
|
2009-02-12 21:51:49 +01:00
|
|
|
Q_PROPERTY(Controls usedControls READ usedControls WRITE setUsedControls)
|
|
|
|
Q_PROPERTY(bool controlsVisible READ controlsVisible WRITE setControlsVisible)
|
2011-07-07 15:32:04 +02:00
|
|
|
Q_PROPERTY(qint32 tickInterval READ tickInterval WRITE setTickInterval)
|
2009-02-08 22:20:41 +01:00
|
|
|
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
2009-02-14 14:55:09 +01:00
|
|
|
Q_ENUMS(Control)
|
2009-02-08 22:20:41 +01:00
|
|
|
|
|
|
|
public:
|
2009-02-12 14:58:10 +01:00
|
|
|
enum Control {
|
|
|
|
NoControls = 0,
|
|
|
|
Play = 1,
|
|
|
|
Pause = 2,
|
|
|
|
Stop = 4,
|
|
|
|
PlayPause = 8,
|
2009-04-21 15:35:42 +02:00
|
|
|
Previous = 16,
|
|
|
|
Next = 32,
|
|
|
|
Progress = 64,
|
|
|
|
Volume = 128,
|
2009-02-12 17:47:30 +01:00
|
|
|
OpenFile = 128,
|
2009-02-12 14:58:10 +01:00
|
|
|
DefaultControls = PlayPause|Progress|Volume|OpenFile
|
|
|
|
};
|
2009-02-13 02:08:23 +01:00
|
|
|
Q_DECLARE_FLAGS(Controls, Control)
|
2009-02-12 14:58:10 +01:00
|
|
|
|
2009-02-08 22:20:41 +01:00
|
|
|
explicit VideoWidget(QGraphicsWidget *parent = 0);
|
|
|
|
~VideoWidget();
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
2009-02-11 22:34:07 +01:00
|
|
|
* Load a certain url that can be a local file or a remote one
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param path resource to play
|
2009-02-09 17:09:34 +01:00
|
|
|
*/
|
2009-02-11 22:34:07 +01:00
|
|
|
void setUrl(const QString &url);
|
2009-02-08 22:20:41 +01:00
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
2009-02-11 22:34:07 +01:00
|
|
|
* @return the url (local or remote) we are playing
|
2009-02-09 17:09:34 +01:00
|
|
|
*/
|
2009-02-11 22:34:07 +01:00
|
|
|
QString url() const;
|
2009-02-08 22:20:41 +01:00
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* @return the Phonon::MediaObject being used
|
|
|
|
* @see Phonon::MediaObject
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
Q_INVOKABLE Phonon::MediaObject *mediaObject() const;
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* @return the Phonon::AudioOutput being used
|
|
|
|
* @see Phonon::AudioOutput
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
Q_INVOKABLE Phonon::AudioOutput *audioOutput() const;
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* @return the current time of the current media file
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
qint64 currentTime() const;
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* @return the total playing time of the current media file
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
qint64 totalTime() const;
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* @return the time remaining to the current media file
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
qint64 remainingTime() const;
|
|
|
|
|
2009-02-12 14:58:10 +01:00
|
|
|
/**
|
2009-02-12 21:51:49 +01:00
|
|
|
* Set what control widgets to use
|
2009-02-12 14:58:10 +01:00
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param controls bitwise OR combination of Controls flags
|
2009-02-12 14:58:10 +01:00
|
|
|
* @see Controls
|
|
|
|
*/
|
2009-02-14 14:55:09 +01:00
|
|
|
void setUsedControls(const Controls controls);
|
2009-02-12 14:58:10 +01:00
|
|
|
|
|
|
|
/**
|
2009-02-12 21:51:49 +01:00
|
|
|
* @return the video controls that are used and shown
|
2009-02-12 14:58:10 +01:00
|
|
|
* @see Controls
|
|
|
|
*/
|
2009-02-12 21:51:49 +01:00
|
|
|
Controls usedControls() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show/hide the main controls widget, if any of them is used
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param visible if we want to show or hide the main controls
|
2009-02-12 21:51:49 +01:00
|
|
|
* @see setUsedControls()
|
|
|
|
*/
|
|
|
|
void setControlsVisible(bool visible);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return true if the controls widget is being shown right now
|
|
|
|
*/
|
|
|
|
bool controlsVisible() const;
|
2009-02-12 14:58:10 +01:00
|
|
|
|
2011-07-07 15:32:04 +02:00
|
|
|
/**
|
|
|
|
* @param interval milliseconds the tick signal will be emitted
|
|
|
|
* @since 4.8
|
|
|
|
*/
|
|
|
|
void setTickInterval(qint64 interval);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return milliseconds the tick signal will be emitted
|
|
|
|
* @see tickInterval()
|
|
|
|
* @since 4.8
|
|
|
|
*/
|
|
|
|
qint64 tickInterval() const;
|
|
|
|
|
2009-02-08 22:20:41 +01:00
|
|
|
/**
|
|
|
|
* Sets the stylesheet used to control the visual display of this VideoWidget
|
|
|
|
*
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param stylesheet a CSS string
|
2009-02-08 22:20:41 +01:00
|
|
|
*/
|
|
|
|
void setStyleSheet(const QString &stylesheet);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the stylesheet currently used with this widget
|
|
|
|
*/
|
|
|
|
QString styleSheet();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the native widget wrapped by this VideoWidget
|
|
|
|
*/
|
|
|
|
Phonon::VideoWidget *nativeWidget() const;
|
|
|
|
|
|
|
|
public Q_SLOTS:
|
2009-04-21 15:35:42 +02:00
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* Play the current file
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
void play();
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* Pause the current file
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
void pause();
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* Stop the current file
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
void stop();
|
|
|
|
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* Jump at a given millisecond in the current file
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param time where we want to jump
|
2009-02-09 17:09:34 +01:00
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
void seek(qint64 time);
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
2009-02-09 17:09:34 +01:00
|
|
|
/**
|
|
|
|
* Emitted regularly when the playing is progressing
|
2011-06-13 14:47:29 +02:00
|
|
|
* @param time where we are
|
2009-02-09 17:09:34 +01:00
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
void tick(qint64 time);
|
2009-02-09 17:09:34 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Emitted an instant before the playback is finished
|
|
|
|
*/
|
2009-02-08 22:20:41 +01:00
|
|
|
void aboutToFinish();
|
|
|
|
|
2009-04-21 15:35:42 +02:00
|
|
|
/**
|
|
|
|
* The user pressed the "next" button
|
2009-04-21 19:58:51 +02:00
|
|
|
* @since 4.3
|
2009-04-21 15:35:42 +02:00
|
|
|
*/
|
|
|
|
void nextRequested();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The user pressed the "previous" button
|
2009-04-21 19:58:51 +02:00
|
|
|
* @since 4.3
|
2009-04-21 15:35:42 +02:00
|
|
|
*/
|
|
|
|
void previousRequested();
|
|
|
|
|
2009-02-12 14:58:10 +01:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QGraphicsSceneResizeEvent *event);
|
2009-02-12 19:19:32 +01:00
|
|
|
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|
|
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
2009-02-12 14:58:10 +01:00
|
|
|
|
2009-02-08 22:20:41 +01:00
|
|
|
private:
|
|
|
|
VideoWidgetPrivate * const d;
|
2009-02-12 14:58:10 +01:00
|
|
|
|
|
|
|
Q_PRIVATE_SLOT(d, void playPause())
|
|
|
|
Q_PRIVATE_SLOT(d, void ticked(qint64 progress))
|
|
|
|
Q_PRIVATE_SLOT(d, void totalTimeChanged(qint64 time))
|
|
|
|
Q_PRIVATE_SLOT(d, void setPosition(int progress))
|
|
|
|
Q_PRIVATE_SLOT(d, void setVolume(int value))
|
|
|
|
Q_PRIVATE_SLOT(d, void volumeChanged(qreal value))
|
|
|
|
Q_PRIVATE_SLOT(d, void showOpenFileDialog())
|
|
|
|
Q_PRIVATE_SLOT(d, void stateChanged(Phonon::State newState, Phonon::State oldState))
|
2009-02-12 19:19:32 +01:00
|
|
|
Q_PRIVATE_SLOT(d, void hideControlWidget())
|
2010-02-04 19:33:24 +01:00
|
|
|
Q_PRIVATE_SLOT(d, void slidingCompleted())
|
2009-02-08 22:20:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|