1
/* This file is part of the KDE project
2
Copyright (C) 2004-2007 Matthias Kretz <kretz@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) version 3, or any
8
later version accepted by the membership of KDE e.V. (or its
9
successor approved by the membership of KDE e.V.), Nokia Corporation
10
(or its successors, if any) and the KDE Free Qt Foundation, which shall
11
act as a proxy defined in Section 6 of version 3 of the license.
13
This library is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
Lesser General Public License for more details.
18
You should have received a copy of the GNU Lesser General Public
19
License along with this library. If not, see <http://www.gnu.org/licenses/>.
23
#include "videoplayer.h"
24
#include "mediaobject.h"
25
#include "audiooutput.h"
26
#include "videowidget.h"
29
#include <QtCore/QEvent>
31
#ifndef QT_NO_PHONON_VIDEOPLAYER
36
class VideoPlayerPrivate
43
, category(Phonon::NoCategory)
44
, initialized(false) {}
46
void ensureCreated() const;
48
mutable MediaObject *player;
49
mutable AudioOutput *aoutput;
50
mutable VideoWidget *voutput;
52
mutable MediaSource src;
53
mutable Phonon::Category category;
54
mutable bool initialized;
58
void VideoPlayerPrivate::ensureCreated() const
62
QVBoxLayout *layout = new QVBoxLayout(q_ptr);
65
aoutput = new AudioOutput(category, q_ptr);
66
voutput = new VideoWidget(q_ptr);
67
layout->addWidget(voutput);
69
player = new MediaObject(q_ptr);
70
Phonon::createPath(player, aoutput);
71
Phonon::createPath(player, voutput);
73
q_ptr->connect(player, SIGNAL(finished()), SIGNAL(finished()));
77
VideoPlayer::VideoPlayer(Phonon::Category category, QWidget *parent)
79
, d(new VideoPlayerPrivate)
82
d->category = category;
85
VideoPlayer::VideoPlayer(QWidget *parent)
87
, d(new VideoPlayerPrivate)
90
d->category = Phonon::VideoCategory;
93
VideoPlayer::~VideoPlayer()
98
MediaObject *VideoPlayer::mediaObject() const
104
AudioOutput *VideoPlayer::audioOutput() const
110
VideoWidget *VideoPlayer::videoWidget() const
116
void VideoPlayer::load(const MediaSource &source)
119
d->player->setCurrentSource(source);
122
void VideoPlayer::play(const MediaSource &source)
125
if (source == d->player->currentSource()) {
131
d->player->setCurrentSource(source);
133
if (ErrorState == d->player->state())
139
void VideoPlayer::play()
145
void VideoPlayer::pause()
151
void VideoPlayer::stop()
157
qint64 VideoPlayer::totalTime() const
160
return d->player->totalTime();
163
qint64 VideoPlayer::currentTime() const
166
return d->player->currentTime();
169
void VideoPlayer::seek(qint64 ms)
175
float VideoPlayer::volume() const
178
return d->aoutput->volume();
181
void VideoPlayer::setVolume(float v)
184
d->aoutput->setVolume(v);
187
bool VideoPlayer::isPlaying() const
190
return (d->player->state() == PlayingState);
193
bool VideoPlayer::isPaused() const
196
return (d->player->state() == PausedState);
199
bool VideoPlayer::event(QEvent *e) {
200
if (e->type() == QEvent::Show)
202
return QWidget::event(e);
207
#endif //QT_NO_PHONON_VIDEOPLAYER
209
#include "moc_videoplayer.cpp"