+
+ refreshPixmapView();
+
+ const QString mimeType = m_item.mimetype();
+ const bool isAnimatedImage = m_preview->isAnimatedImage(itemUrl.toLocalFile());
+ m_isVideo = !isAnimatedImage && mimeType.startsWith(QLatin1String("video/"));
+ usePhonon = m_isVideo || mimeType.startsWith(QLatin1String("audio/"));
+
+ if (usePhonon) {
+ // change the cursor of the preview
+ m_preview->setCursor(Qt::PointingHandCursor);
+ m_preview->installEventFilter(m_phononWidget);
+
+ // if the video is playing, has been paused or stopped
+ // we don't need to update the preview/phonon widget states
+ // unless the previewed file has changed,
+ // or the setting previewshown has changed
+ if ((m_phononWidget->state() != Phonon::State::PlayingState &&
+ m_phononWidget->state() != Phonon::State::PausedState &&
+ m_phononWidget->state() != Phonon::State::StoppedState) ||
+ m_item.targetUrl() != m_phononWidget->url() ||
+ (!m_preview->isVisible() &&! m_phononWidget->isVisible())) {
+
+ if (InformationPanelSettings::previewsAutoPlay() && m_isVideo) {
+ // hides the preview now to avoid flickering when the autoplay video starts
+ m_preview->hide();
+ } else {
+ // the video won't play before the preview is displayed
+ m_preview->show();
+ }
+
+ m_phononWidget->show();
+ m_phononWidget->setUrl(m_item.targetUrl(), m_isVideo ? PhononWidget::MediaKind::Video : PhononWidget::MediaKind::Audio);
+ adjustWidgetSizes(parentWidget()->width());
+ }
+ } else {
+ if (isAnimatedImage) {
+ m_preview->setAnimatedImageFileName(itemUrl.toLocalFile());
+ }
+ // When we don't need it, hide the phonon widget first to avoid flickering
+ m_phononWidget->hide();
+ m_preview->show();
+ m_preview->removeEventFilter(m_phononWidget);
+ m_phononWidget->clearUrl();
+ }