import the video widget, will add later to the build

svn path=/trunk/KDE/kdelibs/; revision=923508
This commit is contained in:
Marco Martin 2009-02-08 21:20:41 +00:00
parent 8a28c219b3
commit b0ad8d6535
2 changed files with 251 additions and 0 deletions

144
widgets/videowidget.cpp Normal file
View File

@ -0,0 +1,144 @@
/*
* Copyright 2008 Aaron Seigo <aseigo@kde.org>
*
* 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.
*/
#include "videowidget.h"
#include <phonon/videowidget.h>
#include <phonon/mediaobject.h>
#include <phonon/mediasource.h>
#include <phonon/audiooutput.h>
namespace Plasma
{
class VideoWidgetPrivate
{
public:
VideoWidgetPrivate()
{
}
~VideoWidgetPrivate()
{
}
Phonon::VideoWidget *videoWidget;
Phonon::AudioOutput *audioOutput;
Phonon::MediaObject *media;
};
VideoWidget::VideoWidget(QGraphicsWidget *parent)
: QGraphicsProxyWidget(parent),
d(new VideoWidgetPrivate)
{
d->videoWidget = new Phonon::VideoWidget;
d->audioOutput = new Phonon::AudioOutput(this);
d->media = new Phonon::MediaObject(this);
//it appears that the path has to be created BEFORE setting the proxy
Phonon::createPath(d->media, d->videoWidget);
Phonon::createPath(d->media, d->audioOutput);
setWidget(d->videoWidget);
connect(d->media, SIGNAL(tick(qint64)), this, SIGNAL(tick(qint64)));
connect(d->media, SIGNAL(aboutToFinish()), this, SIGNAL(aboutToFinish()));
}
VideoWidget::~VideoWidget()
{
delete d;
}
Phonon::MediaObject *VideoWidget::mediaObject() const
{
return d->media;
}
Phonon::AudioOutput *VideoWidget::audioOutput() const
{
return d->audioOutput;
}
void VideoWidget::setFile(const QString &path)
{
d->media->setCurrentSource(Phonon::MediaSource(path));
}
QString VideoWidget::file() const
{
return d->media->currentSource().fileName();
}
void VideoWidget::play()
{
d->media->play();
}
void VideoWidget::pause()
{
d->media->pause();
}
void VideoWidget::stop()
{
d->media->stop();
}
void VideoWidget::seek(qint64 time)
{
d->media->seek(time);
}
qint64 VideoWidget::currentTime() const
{
return d->media->currentTime();
}
qint64 VideoWidget::totalTime() const
{
return d->media->totalTime();
}
qint64 VideoWidget::remainingTime() const
{
return d->media->remainingTime();
}
void VideoWidget::setStyleSheet(const QString &stylesheet)
{
d->videoWidget->setStyleSheet(stylesheet);
}
QString VideoWidget::styleSheet()
{
return d->videoWidget->styleSheet();
}
Phonon::VideoWidget *VideoWidget::nativeWidget() const
{
return d->videoWidget;
}
} // namespace Plasma
#include <videowidget.moc>

107
widgets/videowidget.h Normal file
View File

@ -0,0 +1,107 @@
/*
* 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
#include <QtGui/QGraphicsProxyWidget>
namespace Phonon {
class VideoWidget;
class MediaObject;
class AudioOutput;
}
namespace Plasma
{
class VideoWidgetPrivate;
/**
* @class VideoWidget plasma/widgets/videowidget.h <Plasma/Widgets/VideoWidget>
*
* @short Provides a video player widget
*/
class VideoWidget : public QGraphicsProxyWidget
{
Q_OBJECT
Q_PROPERTY(QString file READ file WRITE setFile)
Q_PROPERTY(QString currentTime READ currentTime)
Q_PROPERTY(QString totalTime READ totalTime)
Q_PROPERTY(QString remainingTime READ remainingTime)
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
public:
explicit VideoWidget(QGraphicsWidget *parent = 0);
~VideoWidget();
void setFile(const QString &path);
//TODO: decide ifsupporting just file from the api or even just make use just MediaObject wtith no api here
QString file() const;
Q_INVOKABLE Phonon::MediaObject *mediaObject() const;
Q_INVOKABLE Phonon::AudioOutput *audioOutput() const;
//FIXME: bunch of stuff wrapped from MediaObject: makes sense for scripting or just use MediaObject also for scripts?
qint64 currentTime() const;
qint64 totalTime() const;
qint64 remainingTime() const;
/**
* Sets the stylesheet used to control the visual display of this VideoWidget
*
* @arg stylesheet a CSS string
*/
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:
void play();
void pause();
void stop();
void seek(qint64 time);
Q_SIGNALS:
void tick(qint64 time);
void aboutToFinish();
private:
VideoWidgetPrivate * const d;
};
} // namespace Plasma
#endif // multiple inclusion guard