瀏覽代碼

Export audio mute setting to web-client

Also extend the documentation comments.
Vincent Lang 9 年之前
父節點
當前提交
2ecd548c38
共有 2 個文件被更改,包括 24 次插入1 次删除
  1. 16 0
      src/player/PlayerComponent.cpp
  2. 8 1
      src/player/PlayerComponent.h

+ 16 - 0
src/player/PlayerComponent.cpp

@@ -546,6 +546,22 @@ int PlayerComponent::volume()
   return 0;
 }
 
+///////////////////////////////////////////////////////////////////////////////////////////////////
+void PlayerComponent::setMuted(bool muted)
+{
+  // Will fail if no audio output opened (i.e. no file playing)
+  mpv::qt::set_property_variant(m_mpv, "mute", muted);
+}
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+bool PlayerComponent::muted()
+{
+  QVariant mute = mpv::qt::get_property_variant(m_mpv, "mute");
+  if (mute.isValid())
+    return mute.toBool();
+  return false;
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 void PlayerComponent::setSubtitleStream(const QString &subtitleStream)
 {

+ 8 - 1
src/player/PlayerComponent.h

@@ -59,10 +59,17 @@ public:
   Q_INVOKABLE virtual void pause();
   Q_INVOKABLE virtual void play();
   
-  /* 0-100 volume 0=mute and 100=normal */
+  // 0-100 volume 0=mute and 100=normal
+  // Ignored if no audio output active (e.g. when no file is playing).
   Q_INVOKABLE virtual void setVolume(int volume);
+  // Returns 0 if no audio output active.
   Q_INVOKABLE virtual int volume();
 
+  // Ignored if no audio output active.
+  Q_INVOKABLE virtual void setMuted(bool muted);
+  // Returns 0 if no audio output active.
+  Q_INVOKABLE virtual bool muted();
+
   // Returns a QVariant of the following format:
   // QVariantList                   (list of audio device entries)
   //    QVariantMap                 (an audio device entry)