From: coderhyme Date: Tue, 25 Apr 2017 03:47:45 +0000 (+0900) Subject: [Player] Converted get/set methods into properties and merge min/max band level prope... X-Git-Tag: submit/trunk/20170823.075128~94^2~51^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=552b21234eb321368c356e5040df13e8e294cf47;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [Player] Converted get/set methods into properties and merge min/max band level properties into one property Change-Id: Ic0a1cf4a34b4b1e6ada340b36615defee714690d Signed-off-by: coderhyme --- diff --git a/packaging/csapi-multimedia.spec b/packaging/csapi-multimedia.spec index 3f02b33b7..d459765c8 100755 --- a/packaging/csapi-multimedia.spec +++ b/packaging/csapi-multimedia.spec @@ -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 \ diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs b/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs index ee0493e18..a9ca7e994 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/AudioEffect.cs @@ -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 /// - /// Get the minimum band level of the bands in dB. + /// Get the band level range of the bands in dB. /// - public int MinBandLevel { get; } - - /// - /// Gets the maximum band level of the bands in dB. - /// - public int MaxBandLevel { get; } + public Range BandLevelRange { get; } /// /// Gets the value whether the AudioEffect is available or not. diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs b/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs index f826ad442..59dc48536 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/EqualizerBand.cs @@ -51,47 +51,46 @@ namespace Tizen.Multimedia } /// - /// Sets the gain for the equalizer band. + /// Sets or gets the gain for the equalizer band. /// /// The value indicating new gain in decibel(dB). /// The player that this EqualizerBand belongs to has already been disposed of. /// - /// value is less than .\n + /// is less than .\n /// -or-\n - /// value is greater than . + /// is greater than . /// - 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"); } - /// - /// Gets the gain for the equalizer band. - /// - /// The player that this EqualizerBand belongs to has already been disposed of. - 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; - } /// /// Gets the frequency in dB. @@ -99,7 +98,7 @@ namespace Tizen.Multimedia public int Frequency { get; } /// - /// Gets the frequency range oin dB. + /// Gets the frequency range in dB. /// public int FrequencyRange { get; } diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs b/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs index a740ebe93..86cc11982 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.cs @@ -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 /// - /// Gets the mute state. + /// Gets or sets the mute state. /// + /// true if the player is muted; otherwise, false. /// The player has already been disposed of. - 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"); - /// - /// Sets the mute state. - /// - /// true to mute the player; otherwise, false. - /// The player has already been disposed of. - 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"); + } } /// @@ -609,10 +601,8 @@ namespace Tizen.Multimedia } #region Volume - private float _volume; - /// - /// Sets the current volume. + /// Gets or sets the current volume. /// /// Valid volume range is from 0 to 1.0, inclusive. /// The player has already been disposed of. @@ -621,34 +611,28 @@ namespace Tizen.Multimedia /// -or-\n /// is greater than 1.0. /// - 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"); + } } - /// - /// Gets the current volume. - /// - /// the volume range is from 0 to 1.0, inclusive. - /// The player has already been disposed of. - 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 /// diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerTrackInfo.cs b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerTrackInfo.cs index fb68e67f0..4af204dc8 100644 --- a/src/Tizen.Multimedia.MediaPlayer/Player/PlayerTrackInfo.cs +++ b/src/Tizen.Multimedia.MediaPlayer/Player/PlayerTrackInfo.cs @@ -107,50 +107,44 @@ namespace Tizen.Multimedia } /// - /// Gets the selected track index. + /// Gets or sets the selected track index. /// - /// The currently selected track index. - /// The that owns this instance must be in the , or state. - /// The that this instance belongs to has been disposed. - /// The that this instance belongs to is not in the valid state. - 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; - } - - /// - /// Selects the track. - /// - /// The index to select. + /// The currently selected track index. /// The that owns this instance must be in the , or state. /// The that this instance belongs to has been disposed. /// The that this instance belongs to is not in the valid state. /// - /// is less than zero.\n + /// is less than zero.\n /// -or-\n - /// is equal to or greater than + /// is equal to or greater than /// - 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"); + } } - } }