Git commit beba299b4354209d74f7d95f84a3ad763cd8ecfe by Casian Andrei. Committed on 02/07/2014 at 11:11. Pushed by casianandrei into branch 'five'. Quickly port the simpleplayer demo to Phonon5 M +1 -1 demos/simpleplayer/CMakeLists.txt M +19 -30 demos/simpleplayer/player.cpp M +4 -3 demos/simpleplayer/player.h http://commits.kde.org/phonon/beba299b4354209d74f7d95f84a3ad763cd8ecfe diff --git a/demos/simpleplayer/CMakeLists.txt b/demos/simpleplayer/CMakeLi= sts.txt index 4a7cf54..ff54708 100644 --- a/demos/simpleplayer/CMakeLists.txt +++ b/demos/simpleplayer/CMakeLists.txt @@ -17,4 +17,4 @@ set(simpleplayer_SRCS add_executable(simpleplayer ${simpleplayer_SRCS}) = qt5_use_modules(simpleplayer Core Widgets) -target_link_libraries(simpleplayer ${PHONON_LIBRARY}) +target_link_libraries(simpleplayer ${PHONON_LIBRARIES}) diff --git a/demos/simpleplayer/player.cpp b/demos/simpleplayer/player.cpp index 5e51241..8547a58 100644 --- a/demos/simpleplayer/player.cpp +++ b/demos/simpleplayer/player.cpp @@ -26,20 +26,15 @@ #include #include = -#include -#include -#include -#include +#include +#include +#include +#include = Player::Player(QWidget* parent, Qt::WindowFlags flags) : QWidget(parent, flags) { - m_media =3D new Phonon::MediaObject(this); - - //Some platforms (i.e. Linux) provide a mechanism for a user to view a= system-wide - //history of content interactions. This is opt-in, and done via settin= g the - //PlaybackTracking property to true. - m_media->setProperty("PlaybackTracking", true); + m_player =3D new Phonon::Player(this); = Phonon::AudioOutput* audioOut =3D new Phonon::AudioOutput(Phonon::Vide= oCategory, this); Phonon::VideoWidget* videoOut =3D new Phonon::VideoWidget(this); @@ -53,7 +48,7 @@ Player::Player(QWidget* parent, Qt::WindowFlags flags) = //After a MediaSource is loaded, this signal will be emitted to let us= know //if a video stream was found. - connect(m_media, SIGNAL(hasVideoChanged(bool)), videoOut, SLOT(setVisi= ble(bool))); + connect(m_player, SIGNAL(hasVideoChanged(bool)), videoOut, SLOT(setVis= ible(bool))); = //This widget will contain the stop/pause buttons QWidget *buttonBar =3D new QWidget(this); @@ -61,12 +56,13 @@ Player::Player(QWidget* parent, Qt::WindowFlags flags) m_playPause =3D new QPushButton(tr("Play"), buttonBar); m_stop =3D new QPushButton(tr("Stop"), buttonBar); = - Phonon::SeekSlider *seekSlider =3D new Phonon::SeekSlider(this); - seekSlider->setMediaObject(m_media); + // FIXME seek slider +// Phonon::SeekSlider *seekSlider =3D new Phonon::SeekSlider(this); +// seekSlider->setMediaObject(m_player); = QVBoxLayout *layout =3D new QVBoxLayout(this); layout->addWidget(videoOut); - layout->addWidget(seekSlider); +// layout->addWidget(seekSlider); layout->addWidget(buttonBar); setLayout(layout); = @@ -77,32 +73,32 @@ Player::Player(QWidget* parent, Qt::WindowFlags flags) = m_stop->setEnabled(false); = - connect(m_stop, SIGNAL(clicked(bool)), m_media, SLOT(stop())); + connect(m_stop, SIGNAL(clicked(bool)), m_player, SLOT(stop())); connect(m_playPause, SIGNAL(clicked(bool)), this, SLOT(playPause())); = //The mediaStateChanged slot will update the GUI elements to reflect w= hat //the user can do next - connect(m_media, SIGNAL(stateChanged(Phonon::State, Phonon::State)), t= his, SLOT(mediaStateChanged(Phonon::State, Phonon::State))); + connect(m_player, SIGNAL(stateChanged(Phonon::State, Phonon::State)), = this, SLOT(mediaStateChanged(Phonon::State, Phonon::State))); } = void Player::playPause() { - if (m_media->state() =3D=3D Phonon::PlayingState) { - m_media->pause(); + if (m_player->state() =3D=3D Phonon::PlayingState) { + m_player->pause(); } else { - if (m_media->currentSource().type() =3D=3D Phonon::MediaSource::Em= pty) + if (m_player->source().deviceType() =3D=3D Phonon::Source::NoDevic= e) load(); - m_media->play(); + m_player->play(); } } = void Player::load(const QUrl &mrl) { if (mrl.scheme().isEmpty()) - m_media->setCurrentSource(QUrl::fromLocalFile(mrl.toString())); + m_player->setSource(QUrl::fromLocalFile(mrl.toString())); else - m_media->setCurrentSource(mrl); - m_media->play(); + m_player->setSource(mrl); + m_player->play(); } = void Player::load() @@ -117,8 +113,6 @@ void Player::mediaStateChanged(Phonon::State newState, = Phonon::State oldState) { Q_UNUSED(oldState); switch(newState) { - case Phonon::LoadingState: - break; case Phonon::StoppedState: m_playPause->setText(tr("Play")); m_stop->setEnabled(false); @@ -127,13 +121,8 @@ void Player::mediaStateChanged(Phonon::State newState,= Phonon::State oldState) m_playPause->setText(tr("Pause")); m_stop->setEnabled(true); break; - case Phonon::BufferingState: - break; case Phonon::PausedState: m_playPause->setText(tr("Play")); break; - case Phonon::ErrorState: - QMessageBox::critical(this, tr("Error"), tr("Error while playing m= edia: ") + m_media->errorString()); - break; } } diff --git a/demos/simpleplayer/player.h b/demos/simpleplayer/player.h index 2235f9e..d032d46 100644 --- a/demos/simpleplayer/player.h +++ b/demos/simpleplayer/player.h @@ -21,13 +21,14 @@ #ifndef PLAYER_H #define PLAYER_H = +#include + #include #include -#include = class QPushButton; namespace Phonon { - class MediaObject; + class Player; class Mrl; } = @@ -66,7 +67,7 @@ private slots: void playPause(); = private: - Phonon::MediaObject *m_media; + Phonon::Player *m_player; QPushButton *m_playPause; QPushButton *m_stop; =