From: Peter Penz Date: Sun, 12 Apr 2009 19:17:56 +0000 (+0000) Subject: - hide the video player in any case when the stop-button has been pressed X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/897f481e96afa4ae35a22713552858da69a532a3?ds=inline - hide the video player in any case when the stop-button has been pressed - provide a custom member for the audio media object svn path=/trunk/KDE/kdebase/apps/; revision=952886 --- diff --git a/src/panels/information/phononwidget.cpp b/src/panels/information/phononwidget.cpp index 4294c50b1..405172b8d 100644 --- a/src/panels/information/phononwidget.cpp +++ b/src/panels/information/phononwidget.cpp @@ -38,6 +38,7 @@ PhononWidget::PhononWidget(QWidget *parent) m_url(), m_playButton(0), m_stopButton(0), + m_audioMedia(0), m_media(0), m_seekSlider(0), m_videoPlayer(0) @@ -49,7 +50,6 @@ void PhononWidget::setUrl(const KUrl &url) if (m_url != url) { stop(); // emits playingStopped() signal m_url = url; - m_videoPlayer->hide(); } } @@ -62,12 +62,7 @@ void PhononWidget::setMode(Mode mode) { if (m_mode != mode) { stop(); // emits playingStopped() signal - m_mode = mode; - if (m_mode == Audio) { - m_videoPlayer->hide(); - m_media = 0; - } } } @@ -124,9 +119,6 @@ void PhononWidget::hideEvent(QHideEvent *event) QWidget::hideEvent(event); if (!event->spontaneous()) { stop(); - if (m_videoPlayer != 0) { - m_videoPlayer->hide(); - } } } @@ -151,10 +143,15 @@ void PhononWidget::play() { switch (m_mode) { case Audio: - if (m_media == 0) { - m_media = Phonon::createPlayer(Phonon::MusicCategory, m_url); - m_media->setParent(this); + if (m_audioMedia == 0) { + // Creating an audio player might take up to 2 seconds when doing + // it the first time. To prevent that the user interface gets + // noticable blocked, the creation is delayed until the play button + // has been pressed. + m_audioMedia = Phonon::createPlayer(Phonon::MusicCategory, m_url); + m_audioMedia->setParent(this); } + m_media = m_audioMedia; m_media->setCurrentSource(m_url); break; @@ -187,4 +184,8 @@ void PhononWidget::stop() m_stopButton->hide(); m_playButton->show(); } + + if (m_videoPlayer != 0) { + m_videoPlayer->hide(); + } } diff --git a/src/panels/information/phononwidget.h b/src/panels/information/phononwidget.h index 81fb1e8f0..daea8b1cc 100644 --- a/src/panels/information/phononwidget.h +++ b/src/panels/information/phononwidget.h @@ -72,6 +72,7 @@ class PhononWidget : public QWidget KUrl m_url; QToolButton *m_playButton; QToolButton *m_stopButton; + Phonon::MediaObject *m_audioMedia; Phonon::MediaObject *m_media; Phonon::SeekSlider *m_seekSlider; Phonon::VideoPlayer *m_videoPlayer;