diff --git a/phonon/videoplayer.cpp b/phonon/videoplayer.cpp index 2feea3c278..5e3c40d43c 100644 --- a/phonon/videoplayer.cpp +++ b/phonon/videoplayer.cpp @@ -1,170 +1,160 @@ /* This file is part of the KDE project Copyright (C) 2004-2007 Matthias Kretz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "videoplayer.h" #include "mediaobject.h" #include "audiooutput.h" #include "videowidget.h" #include "path.h" #include namespace Phonon { class VideoPlayerPrivate { public: VideoPlayerPrivate() : player(0) { } MediaObject *player; AudioOutput *aoutput; VideoWidget *voutput; MediaSource src; - - void _k_stateChanged(Phonon::State, Phonon::State); }; VideoPlayer::VideoPlayer(Phonon::Category category, QWidget *parent) : QWidget(parent) , d(new VideoPlayerPrivate) { QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); d->aoutput = new AudioOutput(category, this); d->voutput = new VideoWidget(this); layout->addWidget(d->voutput); d->player = new MediaObject(this); Phonon::createPath(d->player, d->aoutput); Phonon::createPath(d->player, d->voutput); - connect(d->player, SIGNAL(stateChanged(Phonon::State, Phonon::State)), - SLOT(_k_stateChanged(Phonon::State, Phonon::State))); connect(d->player, SIGNAL(finished()), SIGNAL(finished())); } VideoPlayer::~VideoPlayer() { } MediaObject *VideoPlayer::mediaObject() const { return d->player; } AudioOutput *VideoPlayer::audioOutput() const { return d->aoutput; } VideoWidget *VideoPlayer::videoWidget() const { return d->voutput; } void VideoPlayer::load(const MediaSource &source) { d->player->setCurrentSource(source); } void VideoPlayer::play(const MediaSource &source) { if (source == d->player->currentSource()) { if (!isPlaying()) d->player->play(); return; } // new URL d->player->setCurrentSource(source); if (ErrorState == d->player->state()) return; if (StoppedState == d->player->state()) d->player->play(); } void VideoPlayer::play() { d->player->play(); } void VideoPlayer::pause() { d->player->pause(); } void VideoPlayer::stop() { d->player->stop(); } qint64 VideoPlayer::totalTime() const { return d->player->totalTime(); } qint64 VideoPlayer::currentTime() const { return d->player->currentTime(); } void VideoPlayer::seek(qint64 ms) { d->player->seek(ms); } float VideoPlayer::volume() const { return d->aoutput->volume(); } void VideoPlayer::setVolume(float v) { d->aoutput->setVolume(v); } bool VideoPlayer::isPlaying() const { return (d->player->state() == PlayingState); } bool VideoPlayer::isPaused() const { return (d->player->state() == PausedState); } -void VideoPlayerPrivate::_k_stateChanged(State ns, State os) -{ - if (os == LoadingState && ns == StoppedState) - player->play(); -} - } // namespaces #include "moc_videoplayer.cpp" // vim: sw=4 ts=4 diff --git a/phonon/videoplayer.h b/phonon/videoplayer.h index 47603aa421..75c0eae2d8 100644 --- a/phonon/videoplayer.h +++ b/phonon/videoplayer.h @@ -1,196 +1,193 @@ /* This file is part of the KDE project Copyright (C) 2004-2007 Matthias Kretz This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef Phonon_VIDEOPLAYER_H #define Phonon_VIDEOPLAYER_H #include "phonon/phonon_export.h" #include "phonon/phononnamespace.h" #include "phonon/mediasource.h" #include QT_BEGIN_HEADER QT_BEGIN_NAMESPACE namespace Phonon { class VideoPlayerPrivate; class MediaObject; class AudioOutput; class VideoWidget; /** \class VideoPlayer videoplayer.h Phonon/VideoPlayer * \short Playback class for simple tasks. * * With %VideoPlayer you can get results quickly and easily. You can do the standard * playback tasks like play, pause and stop, but also set a playback volume and * seek (there's no guarantee that the seek will work, though). * * Keep in mind that when the %VideoPlayer instance is deleted the playback will * stop. * * A play and forget code example: * \code * VideoPlayer *player = new VideoPlayer(Phonon::VideoCategory, parentWidget); * connect(player, SIGNAL(finished()), player, SLOT(deleteLater())); * player->play(url); * \endcode * * \ingroup Playback * \ingroup PhononVideo * \author Matthias Kretz */ class PHONON_EXPORT VideoPlayer : public QWidget { Q_OBJECT public: /** * Constructs a new %VideoPlayer instance. * * \param category The category used for the audio output device. * \param parent The QObject parent. */ explicit VideoPlayer(Phonon::Category category, QWidget *parent = 0); /** * On destruction the playback is stopped, also the audio output is * removed so that the desktop mixer will not show the application * anymore. If you need a persistent audio output don't use * %VideoPlayer but MediaObject, VideoPath and VideoOutput. */ ~VideoPlayer(); /** * Get the total time (in milliseconds) of the file currently being played. */ qint64 totalTime() const; /** * Get the current time (in milliseconds) of the file currently being played. */ qint64 currentTime() const; /** * This is the current volume of the output as voltage factor. * * 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% */ float volume() const; /** * \returns \c true if it is currently playing * \returns \c false if it is currently stopped or paused */ bool isPlaying() const; /** * \returns \c true if it is currently paused * \returns \c false if it is currently playing or stopped */ bool isPaused() const; public Q_SLOTS: /** * Starts preloading the media data and fill audiobuffers in the * backend. * * When there's already a media playing (or paused) it will be stopped * (the finished signal will not be emitted). */ void load(const MediaSource &source); /** * Play the media at the given URL. Starts playback as fast as possible. * This can take a considerable time depending on the URL and the * backend. * * If you need low latency between calling play() and the sound actually * starting to play on your output device you need to use MediaObject * and be able to set the URL before calling play(). Note that * \code * audioPlayer->load(url); * audioPlayer->play(); * \endcode * doesn't make a difference: the application should be idle between the * load and play calls so that the backend can start preloading the * media and fill audio buffers. */ void play(const MediaSource &source); /** * Continues playback of a paused media. Restarts playback of a stopped * media. */ void play(); /** * Pauses the playback. */ void pause(); /** * Stops the playback. */ void stop(); /** * Seeks to the requested time. Note that the backend is free to ignore * the seek request if the media source isn't seekable. * * \param ms Time in milliseconds from the start of the media. */ void seek(qint64 ms); /** * Sets the volume of the output as voltage factor. * * 1.0 means 100%, 0.5 means 50% voltage/25% power, 0.0 means 0% */ void setVolume(float volume); /** * getter for the MediaObject. */ MediaObject *mediaObject() const; /** * getter for the AudioOutput. */ AudioOutput *audioOutput() const; /** * getter for the VideoWidget. */ VideoWidget *videoWidget() const; Q_SIGNALS: /** * This signal is emitted when the playback finished. */ void finished(); protected: VideoPlayerPrivate *const d; - - private: - Q_PRIVATE_SLOT(d, void _k_stateChanged(Phonon::State, Phonon::State)) }; } //namespace Phonon QT_END_NAMESPACE QT_END_HEADER #endif // Phonon_VIDEOPLAYER_H // vim: sw=4 ts=4 tw=80