+ if (m_url != url) {
+ stop(); // emits playingStopped() signal
+ m_url = url;
+ m_videoPlayer->hide();
+ }
+}
+
+KUrl PhononWidget::url() const
+{
+ return m_url;
+}
+
+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;
+ }
+ }
+}
+
+PhononWidget::Mode PhononWidget::mode() const
+{
+ return m_mode;
+}
+
+void PhononWidget::showEvent(QShowEvent *event)
+{
+ if (event->spontaneous()) {
+ QWidget::showEvent(event);
+ return;
+ }
+
+ if (m_playButton == 0) {
+ QVBoxLayout *topLayout = new QVBoxLayout(this);
+ topLayout->setMargin(0);
+ topLayout->setSpacing(0);
+ QHBoxLayout *controlsLayout = new QHBoxLayout(this);
+ controlsLayout->setMargin(0);
+ controlsLayout->setSpacing(0);
+
+ m_playButton = new QToolButton(this);
+ m_stopButton = new QToolButton(this);
+ m_seekSlider = new Phonon::SeekSlider(this);
+ m_videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, this);
+ m_videoPlayer->hide();
+
+ controlsLayout->addWidget(m_playButton);
+ controlsLayout->addWidget(m_stopButton);
+ controlsLayout->addWidget(m_seekSlider);
+
+ topLayout->addWidget(m_videoPlayer);
+ topLayout->addLayout(controlsLayout);
+
+ m_playButton->setToolTip(i18n("play"));
+ m_playButton->setIconSize(QSize(16, 16));
+ m_playButton->setIcon(KIcon("media-playback-start"));
+ connect(m_playButton, SIGNAL(clicked()), this, SLOT(play()));
+
+ m_stopButton->setToolTip(i18n("stop"));
+ m_stopButton->setIconSize(QSize(16, 16));
+ m_stopButton->setIcon(KIcon("media-playback-stop"));
+ m_stopButton->hide();
+ connect(m_stopButton, SIGNAL(clicked()), this, SLOT(stop()));
+
+ m_seekSlider->setIconVisible(false);
+ }
+}
+
+void PhononWidget::hideEvent(QHideEvent *event)
+{
+ QWidget::hideEvent(event);
+ if (!event->spontaneous()) {
+ stop();
+ if (m_videoPlayer != 0) {
+ m_videoPlayer->hide();
+ }