Browse Source

Do not reset display mode when seeking in a transcoded video

Seeking in transcoded video is handled by web-client, which simply
reloads the video on each seek. Newer web-client calls streamSwitch(),
which tells us that the next stop() will not leave video playback, but
is for a transcode reload.

Should fix #121.
Vincent Lang 9 years ago
parent
commit
7d0b1dcc8a
2 changed files with 16 additions and 2 deletions
  1. 11 2
      src/player/PlayerComponent.cpp
  2. 5 0
      src/player/PlayerComponent.h

+ 11 - 2
src/player/PlayerComponent.cpp

@@ -30,7 +30,8 @@ static void wakeup_cb(void *context)
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 PlayerComponent::PlayerComponent(QObject* parent)
   : ComponentBase(parent), m_lastPositionUpdate(0.0), m_playbackAudioDelay(0), m_playbackStartSent(false), m_window(0), m_mediaFrameRate(0),
-  m_restoreDisplayTimer(this), m_reloadAudioTimer(this)
+  m_restoreDisplayTimer(this), m_reloadAudioTimer(this),
+  m_streamSwitchImminent(false)
 {
   qmlRegisterType<PlayerQuickItem>("Konvergo", 1, 0, "MpvVideo"); // deprecated name
   qmlRegisterType<PlayerQuickItem>("Konvergo", 1, 0, "KonvergoVideo");
@@ -243,6 +244,12 @@ void PlayerComponent::queueMedia(const QString& url, const QVariantMap& options,
   mpv::qt::command_variant(m_mpv, command);
 }
 
+/////////////////////////////////////////////////////////////////////////////////////////
+void PlayerComponent::streamSwitch()
+{
+  m_streamSwitchImminent = true;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 bool PlayerComponent::switchDisplayFrameRate()
 {
@@ -336,7 +343,9 @@ void PlayerComponent::handleMpvEvent(mpv_event *event)
       emit playbackEnded(m_CurrentUrl);
       m_CurrentUrl = "";
 
-      m_restoreDisplayTimer.start(0);
+      if (!m_streamSwitchImminent)
+        m_restoreDisplayTimer.start(0);
+      m_streamSwitchImminent = false;
       break;
     }
     case MPV_EVENT_IDLE:

+ 5 - 0
src/player/PlayerComponent.h

@@ -52,6 +52,10 @@ public:
   // Stop playback and clear all queued items.
   Q_INVOKABLE virtual void stop();
 
+  // A full reload of the stream is imminent (stop() + load())
+  // Used ofr not resetting display mode with the next stop() call.
+  Q_INVOKABLE virtual void streamSwitch();
+
   Q_INVOKABLE virtual void pause();
   Q_INVOKABLE virtual void play();
   
@@ -164,6 +168,7 @@ private:
   QTimer m_restoreDisplayTimer;
   QTimer m_reloadAudioTimer;
   QSet<QString> m_audioDevices;
+  bool m_streamSwitchImminent;
 };
 
 #endif // PLAYERCOMPONENT_H