[MediaPlayer] add API to set audio-only mode (#207)
authornam <36914158+kqjy777@users.noreply.github.com>
Mon, 30 Apr 2018 07:26:25 +0000 (16:26 +0900)
committerhsgwon <haesu.gwon@samsung.com>
Mon, 30 Apr 2018 07:26:25 +0000 (16:26 +0900)
* [MediaPlayer] add API to set audio-only mode

src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs

index 373ee5d..6380d0f 100644 (file)
@@ -261,6 +261,12 @@ internal static partial class Interop
         [DllImport(Libraries.Player, EntryPoint = "player_get_track_language_code")]
         internal static extern PlayerErrorCode GetTrackLanguageCode(IntPtr player, StreamType type,
             int index, out IntPtr code);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_set_audio_only")]
+        internal static extern PlayerErrorCode SetAudioOnly(IntPtr player, bool audioOnly);
+
+        [DllImport(Libraries.Player, EntryPoint = "player_is_audio_only")]
+        internal static extern PlayerErrorCode IsAudioOnly(IntPtr player, out bool audioOnly);
     }
 
     internal class PlayerHandle : SafeHandle
index 81f0490..cd1e46b 100644 (file)
@@ -417,5 +417,32 @@ namespace Tizen.Multimedia
                     ThrowIfFailed(this, "Failed to set the volume of the player");
             }
         }
+
+        /// <summary>
+        /// Gets or sets the audio-only state.
+        /// </summary>
+        /// <value>true if the playback is audio-only mode; otherwise, false. The default value is false.</value>
+        /// The <see cref="Player"/> must be in the <see cref="PlayerState.Ready"/>,
+        /// <see cref="PlayerState.Playing"/>, or <see cref="PlayerState.Paused"/> state.
+        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
+        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public bool IsAudioOnly
+        {
+            get
+            {
+                ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+                NativePlayer.IsAudioOnly(Handle, out var value).
+                    ThrowIfFailed(this, "Failed to get the audio-only state of the player");
+                return value;
+            }
+            set
+            {
+                ValidateNotDisposed();
+                ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+                NativePlayer.SetAudioOnly(Handle, value).
+                    ThrowIfFailed(this, "Failed to set the audio-only state of the player");
+            }
+        }
     }
 }