[Player] Converted get/set methods into properties and merge min/max band level prope...
authorcoderhyme <jhyo.kim@samsung.com>
Tue, 25 Apr 2017 03:47:45 +0000 (12:47 +0900)
committercoderhyme <jhyo.kim@samsung.com>
Wed, 7 Jun 2017 11:18:04 +0000 (20:18 +0900)
Change-Id: Ic0a1cf4a34b4b1e6ada340b36615defee714690d
Signed-off-by: coderhyme <jhyo.kim@samsung.com>
packaging/csapi-multimedia.spec
src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs
src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs
src/Tizen.Multimedia.MediaPlayer/Player/Player.cs
src/Tizen.Multimedia.MediaPlayer/Player/PlayerTrackInfo.cs

index 3f02b33..d459765 100755 (executable)
@@ -24,7 +24,7 @@ BuildRequires: csapi-information-nuget
        Tizen.Multimedia.AudioIO 1.0.0 \
        Tizen.Multimedia.Camera 1.0.0 \
        Tizen.Multimedia.MediaCodec 1.0.0 \
-       Tizen.Multimedia.MediaPlayer 1.0.0 \
+       Tizen.Multimedia.MediaPlayer 1.0.1 \
        Tizen.Multimedia.Metadata 1.0.0 \
        Tizen.Multimedia.Radio 1.0.1 \
        Tizen.Multimedia.Recorder 1.0.0 \
index ee0493e..a9ca7e9 100644 (file)
@@ -52,8 +52,7 @@ namespace Tizen.Multimedia
                 ThrowIfFailed("Failed to initialize the AudioEffect");
 
             Count = count;
-            MinBandLevel = min;
-            MaxBandLevel = max;
+            BandLevelRange = new Range(min, max);
 
             _bands = new EqualizerBand[count];
         }
@@ -106,16 +105,10 @@ namespace Tizen.Multimedia
 
         public int Count{ get; }
 
-        // TODO replace with range struct
         /// <summary>
-        /// Get the minimum band level of the bands in dB.
+        /// Get the band level range of the bands in dB.
         /// </summary>
-        public int MinBandLevel { get; }
-
-        /// <summary>
-        /// Gets the maximum band level of the bands in dB.
-        /// </summary>
-        public int MaxBandLevel { get; }
+        public Range BandLevelRange { get; }
 
         /// <summary>
         /// Gets the value whether the AudioEffect is available or not.
index f826ad4..59dc485 100644 (file)
@@ -51,47 +51,46 @@ namespace Tizen.Multimedia
         }
 
         /// <summary>
-        /// Sets the gain for the equalizer band.
+        /// Sets or gets the gain for the equalizer band.
         /// </summary>
         /// <param name="value">The value indicating new gain in decibel(dB).</param>
         /// <exception cref="ObjectDisposedException">The player that this EqualizerBand belongs to has already been disposed of.</exception>
         /// <exception cref="ArgumentOutOfRangeException">
-        ///     value is less than <see cref="AudioEffect.MinBandLevel"/>.\n
+        ///     <paramref name="value"/> is less than <see cref="AudioEffect.MinBandLevel"/>.\n
         ///     -or-\n
-        ///     value is greater than <see cref="AudioEffect.MaxBandLevel"/>.
+        ///     <paramref name="value"/> is greater than <see cref="AudioEffect.MaxBandLevel"/>.
         /// </exception>
-        public void SetLevel(int value)
+        public int Level
         {
-            Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
-            _owner.Player.ValidateNotDisposed();
-
-            if (value < _owner.MinBandLevel || _owner.MaxBandLevel < value)
+            get
             {
-                Log.Error(PlayerLog.Tag, "invalid level : " + value);
-                throw new ArgumentOutOfRangeException(nameof(value), value,
-                    $"valid value range is { nameof(AudioEffect.MinBandLevel) } <= level <= { nameof(AudioEffect.MaxBandLevel) }. " +
-                    $"but got {value}.");
+                Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
+                _owner.Player.ValidateNotDisposed();
+
+                int value = 0;
+                Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out value).
+                    ThrowIfFailed("Failed to get the level of the equalizer band");
+                Log.Info(PlayerLog.Tag, "get level : " + value);
+                return value;
+            }
+            set
+            {
+                Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
+                _owner.Player.ValidateNotDisposed();
+
+                if (value < _owner.BandLevelRange.Min || _owner.BandLevelRange.Max < value)
+                {
+                    Log.Error(PlayerLog.Tag, "invalid level : " + value);
+                    throw new ArgumentOutOfRangeException(nameof(value), value,
+                        $"valid value range is { nameof(AudioEffect.BandLevelRange) }." +
+                        $"but got {value}.");
+                }
+
+                Native.SetEqualizerBandLevel(_owner.Player.Handle, _index, value).
+                    ThrowIfFailed("Failed to set the level of the equalizer band");
             }
-
-            Native.SetEqualizerBandLevel(_owner.Player.Handle, _index, value).
-                ThrowIfFailed("Failed to set the level of the equalizer band");
         }
 
-        /// <summary>
-        /// Gets the gain for the equalizer band.
-        /// </summary>
-        /// <exception cref="ObjectDisposedException">The player that this EqualizerBand belongs to has already been disposed of.</exception>
-        public int GetLevel()
-        {
-            Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
-            _owner.Player.ValidateNotDisposed();
-
-            int value = 0;
-            Native.GetEqualizerBandLevel(_owner.Player.Handle, _index, out value).
-                ThrowIfFailed("Failed to get the level of the equalizer band");
-            Log.Info(PlayerLog.Tag, "get level : " + value);
-            return value;
-        }
 
         /// <summary>
         /// Gets the frequency in dB.
@@ -99,7 +98,7 @@ namespace Tizen.Multimedia
         public int Frequency { get; }
 
         /// <summary>
-        /// Gets the frequency range oin dB.
+        /// Gets the frequency range in dB.
         /// </summary>
         public int FrequencyRange { get; }
 
index a740ebe..86cc119 100644 (file)
@@ -120,8 +120,6 @@ namespace Tizen.Multimedia
         private void RetrieveProperties()
         {
             Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
-            NativePlayer.GetVolume(Handle, out _volume, out _volume).
-                ThrowIfFailed("Failed to initialize the player");
 
             NativePlayer.GetAudioLatencyMode(Handle, out _audioLatencyMode).
                 ThrowIfFailed("Failed to initialize the player");
@@ -554,33 +552,27 @@ namespace Tizen.Multimedia
         #region Methods
 
         /// <summary>
-        /// Gets the mute state.
+        /// Gets or sets the mute state.
         /// </summary>
+        /// <value>true if the player is muted; otherwise, false.</value>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
-        public bool IsMuted()
+        public bool Muted
         {
-            Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
-            ValidateNotDisposed();
-
-            bool value = false;
-            NativePlayer.IsMuted(Handle, out value).ThrowIfFailed("Failed to get the mute state of the player");
-
-            Log.Info(PlayerLog.Tag, "get mute : " + value);
+            get
+            {
+                Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
 
-            return value;
-        }
+                bool value = false;
+                NativePlayer.IsMuted(Handle, out value).ThrowIfFailed("Failed to get the mute state of the player");
 
-        /// <summary>
-        /// Sets the mute state.
-        /// </summary>
-        /// <param name="mute">true to mute the player; otherwise, false.</param>
-        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
-        public void SetMute(bool mute)
-        {
-            Log.Debug(PlayerLog.Tag, PlayerLog.Enter);
-            ValidateNotDisposed();
+                Log.Info(PlayerLog.Tag, "get mute : " + value);
 
-            NativePlayer.SetMute(Handle, mute).ThrowIfFailed("Failed to set the mute state of the player");
+                return value;
+            }
+            set
+            {
+                NativePlayer.SetMute(Handle, value).ThrowIfFailed("Failed to set the mute state of the player");
+            }
         }
 
         /// <summary>
@@ -609,10 +601,8 @@ namespace Tizen.Multimedia
         }
 
         #region Volume
-        private float _volume;
-
         /// <summary>
-        /// Sets the current volume.
+        /// Gets or sets the current volume.
         /// </summary>
         /// <remarks>Valid volume range is from 0 to 1.0, inclusive.</remarks>
         /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
@@ -621,34 +611,28 @@ namespace Tizen.Multimedia
         ///     -or-\n
         ///     <paramref name="value"/> is greater than 1.0.
         /// </exception>
-        public void SetVolume(float value)
+        public float Volume
         {
-            ValidateNotDisposed();
-
-            if (value < 0F || 1.0F < value)
+            get
             {
-                throw new ArgumentOutOfRangeException(nameof(value), value,
-                    $"Valid volume range is 0 <= value <= 1.0, but got { value }.");
+                float value = 0.0F;
+                NativePlayer.GetVolume(Handle, out value, out value).
+                    ThrowIfFailed("Failed to get the volume of the player");
+                return value;
             }
+            set
+            {
+                if (value < 0F || 1.0F < value)
+                {
+                    throw new ArgumentOutOfRangeException(nameof(value), value,
+                        $"Valid volume range is 0 <= value <= 1.0, but got { value }.");
+                }
 
-            NativePlayer.SetVolume(Handle, value, value).
-                ThrowIfFailed("Failed to set the volume of the player");
+                NativePlayer.SetVolume(Handle, value, value).
+                    ThrowIfFailed("Failed to set the volume of the player");
+            }
         }
 
-        /// <summary>
-        /// Gets the current volume.
-        /// </summary>
-        /// <remarks>the volume range is from 0 to 1.0, inclusive.</remarks>
-        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
-        public float GetVolume()
-        {
-            ValidateNotDisposed();
-
-            float value = 0.0F;
-            NativePlayer.GetVolume(Handle, out value, out value).
-                ThrowIfFailed("Failed to get the volume of the player");
-            return value;
-        }
         #endregion
 
         /// <summary>
index fb68e67..4af204d 100644 (file)
@@ -107,50 +107,44 @@ namespace Tizen.Multimedia
         }
 
         /// <summary>
-        /// Gets the selected track index.
+        /// Gets or sets the selected track index.
         /// </summary>
-        /// <returns>The currently selected track index.</returns>
-        /// <remarks>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
-        /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed.</exception>
-        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
-        public int GetSelected()
-        {
-            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
-
-            int value = 0;
-
-            NativePlayer.GetCurrentTrack(_owner.Handle, _streamType, out value).
-                ThrowIfFailed("Failed to get the selected index of the player");
-            Log.Debug(PlayerLog.Tag, "get selected index : " + value);
-            return value;
-        }
-
-        /// <summary>
-        /// Selects the track.
-        /// </summary>
-        /// <param name="index">The index to select.</param>
+        /// <value>The currently selected track index.</value>
         /// <remarks>The <see cref="Player"/> that owns this instance must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
         /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed.</exception>
         /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
         /// <exception cref="ArgumentOutOfRangeException">
-        ///     <paramref name="index"/> is less than zero.\n
+        ///     <paramref name="value"/> is less than zero.\n
         ///     -or-\n
-        ///     <paramref name="index"/> is equal to or greater than <see cref="GetCount()"/>
+        ///     <paramref name="value"/> is equal to or greater than <see cref="GetCount()"/>
         /// </exception>
-        public void SetSelected(int index)
+        public int Selected
         {
-            if (index < 0 || GetCount() <= index)
+            get
             {
-                Log.Error(PlayerLog.Tag, "invalid index");
-                throw new ArgumentOutOfRangeException(nameof(index), index,
-                    $"valid index range is 0 <= x < {nameof(GetCount)}(), but got { index }.");
+                _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+
+                int value = 0;
+
+                NativePlayer.GetCurrentTrack(_owner.Handle, _streamType, out value).
+                    ThrowIfFailed("Failed to get the selected index of the player");
+                Log.Debug(PlayerLog.Tag, "get selected index : " + value);
+                return value;
             }
+            set
+            {
+                if (value < 0 || GetCount() <= value)
+                {
+                    Log.Error(PlayerLog.Tag, "invalid index");
+                    throw new ArgumentOutOfRangeException(nameof(value), value,
+                        $"valid index range is 0 <= x < {nameof(GetCount)}(), but got { value }.");
+                }
 
-            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
+                _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);
 
-            NativePlayer.SelectTrack(_owner.Handle, _streamType, index).
-                ThrowIfFailed("Failed to set the selected index of the player");
+                NativePlayer.SelectTrack(_owner.Handle, _streamType, value).
+                    ThrowIfFailed("Failed to set the selected index of the player");
+            }
         }
-
     }
 }