示例#1
0
        /// <summary>
        /// Sets the playback rate.
        /// </summary>
        /// <param name="rate">The value for the playback rate. Valid range is -5.0 to 5.0, inclusive.</param>
        /// <remarks>
        ///     <para>The player must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/>,
        ///     or <see cref="PlayerState.Paused"/> state.</para>
        ///     <para>The sound will be muted, when the playback rate is under 0.0 or over 2.0.</para>
        /// </remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">
        ///     The player is not in the valid state.<br/>
        ///     -or-<br/>
        ///     Streaming playback.
        ///     -or-<br/>
        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <paramref name="rate"/> is less than -5.0.<br/>
        ///     -or-<br/>
        ///     <paramref name="rate"/> is greater than 5.0.<br/>
        ///     -or-<br/>
        ///     <paramref name="rate"/> is zero.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public void SetPlaybackRate(float rate)
        {
            if (rate < -5.0F || 5.0F < rate || rate == 0.0F)
            {
                throw new ArgumentOutOfRangeException(nameof(rate), rate, "Valid range is -5.0 to 5.0 (except 0.0)");
            }

            AudioOffload.CheckDisabled();
            ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.SetPlaybackRate(Handle, rate).ThrowIfFailed(this, "Failed to set the playback rate.");
        }
示例#2
0
        /// <summary>
        /// Enable to decode an audio data for exporting PCM from a data.
        /// </summary>
        /// <param name="format">The media format handle required to audio PCM specification.
        /// The format has to include <see cref="AudioMediaFormat.MimeType"/>,
        /// <see cref="AudioMediaFormat.Channel"/> and <see cref="AudioMediaFormat.SampleRate"/>.
        /// If the format is NULL, the original PCM format or platform default PCM format will be applied.</param>
        /// <param name="option">The audio extract option.</param>
        /// <remarks><para>The player must be in the <see cref="PlayerState.Idle"/> state.</para>
        /// <para>A <see cref="AudioDataDecoded"/> event is called in a separate thread(not in the main loop).</para>
        /// <para>The audio PCM data can be retrieved using a <see cref="AudioDataDecoded"/> event as a media packet
        /// and it is available until it's destroyed by <see cref="MediaPacket.Dispose()"/>.
        /// The packet has to be destroyed as quickly as possible after rendering the data
        /// and all the packets have to be destroyed before <see cref="Unprepare"/> is called.</para>
        /// <para>This function could be unavailable depending on the audio codec type.</para></remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="ArgumentException">The value is not valid.</exception>
        /// <exception cref="InvalidOperationException">
        ///     Operation failed; internal error.
        ///     -or-<br/>
        ///     The player is not in the valid state.
        ///     -or-<br/>
        ///     If audio offload is enabled by calling <see cref="AudioOffload.IsEnabled"/>. (Since tizen 6.0)
        ///     </exception>
        /// <exception cref="NotAvailableException">The function is not available depending on the audio codec type. (Since tizen 6.0)</exception>
        /// <seealso cref="PlayerAudioExtractOption"/>
        /// <seealso cref="DisableExportingAudioData"/>
        /// <seealso cref="AudioCodecType"/>
        /// <since_tizen> 6 </since_tizen>
        public void EnableExportingAudioData(AudioMediaFormat format, PlayerAudioExtractOption option)
        {
            ValidationUtil.ValidateEnum(typeof(PlayerAudioExtractOption), option, nameof(option));
            AudioOffload.CheckDisabled();
            ValidatePlayerState(PlayerState.Idle);

            _audioFrameDecodedCallback = (IntPtr packetHandle, IntPtr userData) =>
            {
                var handler = AudioDataDecoded;
                if (handler != null)
                {
                    Log.Debug(PlayerLog.Tag, "packet : " + packetHandle.ToString());
                    handler.Invoke(this,
                                   new AudioDataDecodedEventArgs(MediaPacket.From(packetHandle)));
                }
                else
                {
                    MediaPacket.From(packetHandle).Dispose();
                }
            };

            NativePlayer.SetAudioFrameDecodedCb(Handle, format == null ? IntPtr.Zero : format.AsNativeHandle(), option,
                                                _audioFrameDecodedCallback, IntPtr.Zero).ThrowIfFailed(this, "Failed to register the _audioFrameDecoded");
        }