From 206d9b2a93a3704d6e949de91aff6432d947b12a Mon Sep 17 00:00:00 2001
From: nam <36914158+aferin@users.noreply.github.com>
Date: Tue, 16 Apr 2019 15:57:36 +0900
Subject: [PATCH] [MediaPlayer] add APIs for controlling an audio pitch (#783)
* [MediaPlayer] add APIs for controlling an audio pitch
---
.../Interop/Interop.Player.cs | 12 ++++
.../Player/Player.Properties.cs | 80 ++++++++++++++++++++++
.../Player/SphericalVideo.cs | 1 -
3 files changed, 92 insertions(+), 1 deletion(-)
diff --git a/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs b/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
index 500fb79..f40b77d 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Interop/Interop.Player.cs
@@ -337,6 +337,18 @@ internal static partial class Interop
[DllImport(Libraries.Player, EntryPoint = "player_get_video_roi_area")]
internal static extern PlayerErrorCode GetVideoRoi(IntPtr player, out double scaleX, out double scaleY, out double scaleWidth, out double scaleHeight);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_set_enabled")]
+ internal static extern PlayerErrorCode SetAudioPitchEnabled(IntPtr player, bool enabled);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_is_enabled")]
+ internal static extern PlayerErrorCode IsAudioPitchEnabled(IntPtr player, out bool enabled);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_set_value")]
+ internal static extern PlayerErrorCode SetAudioPitch(IntPtr player, float level);
+
+ [DllImport(Libraries.Player, EntryPoint = "player_audio_pitch_get_value")]
+ internal static extern PlayerErrorCode GetAudioPitch(IntPtr player, out float level);
}
internal class PlayerHandle : SafeHandle
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
index 058f56a..1e91387 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/Player.Properties.cs
@@ -560,6 +560,86 @@ namespace Tizen.Multimedia
}
}
+ ///
+ /// Gets or sets the audio pitch.
+ ///
+ /// The value indicating whether or not AudioPitch is enabled. The default is false.
+ /// This function is used for audio content only.
+ /// To set, the player must be in the state.
+ /// The player is not in the valid state.
+ /// The player has already been disposed of.
+ ///
+ /// 6
+ public bool AudioPitchEnabled
+ {
+ get
+ {
+ ValidateNotDisposed();
+ NativePlayer.IsAudioPitchEnabled(Handle, out var value).
+ ThrowIfFailed(this, "Failed to get whether the audio pitch is enabled or not");
+ return value;
+ }
+
+ set
+ {
+ ValidateNotDisposed();
+ ValidatePlayerState(PlayerState.Idle);
+
+ NativePlayer.SetAudioPitchEnabled(Handle, value).
+ ThrowIfFailed(this, "Failed to enable the audio pitch of the player");
+ }
+ }
+
+ ///
+ /// Gets or sets the audio pitch value.
+ ///
+ /// The audio stream pitch value. The default is 1.
+ /// Enabling pitch control could increase the CPU usage on some devices.
+ /// This function is used for audio content only.
+ /// A pitch is not enabled.
+ /// The player has already been disposed of.
+ ///
+ /// value is less than 0.5.
+ /// -or-
+ /// value is greater than 2.0.
+ ///
+ ///
+ /// 6
+ public float AudioPitch
+ {
+ get
+ {
+ ValidateNotDisposed();
+
+ if (AudioPitchEnabled == false)
+ {
+ throw new InvalidOperationException("An audio pitch is not enabled.");
+ }
+
+ NativePlayer.GetAudioPitch(Handle, out var value).
+ ThrowIfFailed(this, "Failed to get the audio pitch");
+
+ return value;
+ }
+
+ set
+ {
+ ValidateNotDisposed();
+
+ if (AudioPitchEnabled == false)
+ {
+ throw new InvalidOperationException("An audio pitch is not enabled.");
+ }
+
+ if (value < 0.5F || 2.0F < value)
+ {
+ throw new ArgumentOutOfRangeException(nameof(value), value, "Valid value is 0.5 to 2.0");
+ }
+
+ NativePlayer.SetAudioPitch(Handle, value).ThrowIfFailed(this, "Failed to set the audio pitch");
+ }
+ }
+
private SphericalVideo _sphericalVideo;
///
diff --git a/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs b/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs
index fccd0cc..a0e53d5 100644
--- a/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs
+++ b/src/Tizen.Multimedia.MediaPlayer/Player/SphericalVideo.cs
@@ -181,7 +181,6 @@ namespace Tizen.Multimedia
/// Gets the level of the zoom of spherical video.
///
/// The current zoom level of spherical video.
- /// Remark.
/// http://tizen.org/feature/opengles.version.2_0
/// http://tizen.org/feature/multimedia.player.spherical_video
/// The required feature is not supported.
--
2.7.4