Example #1
0
        private void RetrieveProperties()
        {
            NativePlayer.GetAudioLatencyMode(Handle, out _audioLatencyMode).
            ThrowIfFailed("Failed to initialize the player");

            NativePlayer.IsLooping(Handle, out _isLooping).ThrowIfFailed("Failed to initialize the player");
        }
Example #2
0
        /// <summary>
        /// Removes the subtitle path.
        /// </summary>
        /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> state.</remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <since_tizen> 3 </since_tizen>
        public void ClearSubtitle()
        {
            ValidatePlayerState(PlayerState.Idle);

            NativePlayer.SetSubtitlePath(Handle, null).
            ThrowIfFailed(this, "Failed to clear the subtitle of the player");
        }
Example #3
0
        /// <summary>
        /// Enables to decode a video data for every frame.
        /// </summary>
        /// <remarks><para>The player must be in the <see cref="PlayerState.Idle"/> state,
        /// but <see cref="Multimedia.Display"/> must not be set.</para>
        /// <para>A <see cref="VideoFrameDecoded"/> event is called in a separate thread, not called in the main loop.</para>
        /// <para>The video frame can be retrieved using a <see cref="VideoFrameDecoded"/> event with a media packet parameter.
        /// If you change the media packet in the <see cref="VideoFrameDecoded"/> event, it will be displayed on the device.
        /// The callback function holds the same buffer that is drawn on the display device.
        /// and the <see cref="MediaPacket"/> is available until it is destroyed by <see cref="MediaPacket.Dispose()"/>.
        /// It is recommended to destroy the packet as quickly as possible after the decoded data is rendered on the display.
        /// All the packets have to be destroyed before <see cref="Unprepare"/> is called.</para></remarks>
        /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">
        ///     Operation failed; internal error.
        ///     -or-<br/>
        ///     The player is not in the valid state.
        ///     </exception>
        /// <seealso cref="DisableExportingVideoFrame"/>
        /// <since_tizen> 6 </since_tizen>
        public void EnableExportingVideoFrame()
        {
            ValidationUtil.ValidateFeatureSupported(PlayerFeatures.RawVideo);
            ValidatePlayerState(PlayerState.Idle);

            if (Display != null)
            {
                throw new InvalidOperationException("Display must be none.");
            }

            _videoFrameDecodedCallback = (packetHandle, _) =>
            {
                var handler = VideoFrameDecoded;
                if (handler != null)
                {
                    Log.Debug(PlayerLog.Tag, "packet : " + packetHandle);
                    handler.Invoke(this,
                                   new VideoFrameDecodedEventArgs(MediaPacket.From(packetHandle)));
                }
                else
                {
                    MediaPacket.From(packetHandle).Dispose();
                }
            };

            NativePlayer.SetVideoFrameDecodedCb(Handle, _videoFrameDecodedCallback).
            ThrowIfFailed(this, "Failed to register the VideoFrameDecoded");
        }
Example #4
0
        private string GetCodecInfo(bool audioInfo)
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            IntPtr audioPtr = IntPtr.Zero;
            IntPtr videoPtr = IntPtr.Zero;

            try
            {
                NativePlayer.GetCodecInfo(Player.Handle, out audioPtr, out videoPtr).
                ThrowIfFailed("Failed to get codec info");

                if (audioInfo)
                {
                    Log.Debug(PlayerLog.Tag, "it is audio case");
                    return(Marshal.PtrToStringAnsi(audioPtr));
                }
                else
                {
                    Log.Debug(PlayerLog.Tag, "it is video case");
                    return(Marshal.PtrToStringAnsi(videoPtr));
                }
            }
            finally
            {
                LibcSupport.Free(audioPtr);
                LibcSupport.Free(videoPtr);
            }
        }
Example #5
0
        /// <summary>
        /// Gets the language code for the specified index, or null if the language is undefined.
        /// </summary>
        /// <returns>The number of tracks.</returns>
        /// <remarks>
        ///     <para>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.</para>
        ///     <para>The language codes are defined in ISO 639-1.</para>
        /// </remarks>
        /// <exception cref="ObjectDisposedException">The <see cref="Player"/> that this instance belongs to has been disposed of.</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.<br/>
        ///     -or-<br/>
        ///     <paramref name="index"/> is equal to or greater than <see cref="GetCount()"/>.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public string GetLanguageCode(int index)
        {
            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            if (index < 0 || GetCount() <= index)
            {
                throw new ArgumentOutOfRangeException(nameof(index), index,
                                                      $"Valid index range is 0 <= x < {nameof(GetCount)}(), but got { index }.");
            }

            IntPtr code = IntPtr.Zero;

            try
            {
                NativePlayer.GetTrackLanguageCode(_owner.Handle, _streamType, index, out code).
                ThrowIfFailed(_owner, "Failed to get the selected language of the player");

                string result = Marshal.PtrToStringAnsi(code);

                if (result == "und")
                {
                    Log.Error(PlayerLog.Tag, "not defined code");
                    return(null);
                }
                Log.Info(PlayerLog.Tag, "get language code : " + result);
                return(result);
            }
            finally
            {
                LibcSupport.Free(code);
            }
        }
Example #6
0
        /// <summary>
        /// Captures a video frame, asynchronously.
        /// </summary>
        /// <returns>A task that represents the asynchronous capture operation.</returns>
        /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
        /// <remarks>The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.</remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <since_tizen> 3 </since_tizen>
        public async Task <CapturedFrame> CaptureVideoAsync()
        {
            ValidationUtil.ValidateFeatureSupported(PlayerFeatures.RawVideo);

            ValidatePlayerState(PlayerState.Playing, PlayerState.Paused);

            TaskCompletionSource <CapturedFrame> t = new TaskCompletionSource <CapturedFrame>();

            NativePlayer.VideoCaptureCallback cb = (data, width, height, size, _) =>
            {
                Debug.Assert(size <= int.MaxValue);

                byte[] buf = new byte[size];
                Marshal.Copy(data, buf, 0, (int)size);

                t.TrySetResult(new CapturedFrame(buf, width, height));
            };

            using (var cbKeeper = ObjectKeeper.Get(cb))
            {
                NativePlayer.CaptureVideo(Handle, cb)
                .ThrowIfFailed(this, "Failed to capture the video");

                return(await t.Task);
            }
        }
Example #7
0
        /// <summary>
        /// Sets the zoom with the field of view for spherical video.
        /// </summary>
        /// <param name="level">The zoom level.</param>
        /// <param name="fieldOfView">The degree values to display.</param>
        /// <feature>http://tizen.org/feature/opengles.version.2_0</feature>
        /// <feature>http://tizen.org/feature/multimedia.player.spherical_video</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="ObjectDisposedException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to has been disposed of.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <pramref name="level"/> is less than 1.0.
        ///     -or-<br/>
        ///     <paramref name="level"/> is greater than 10.0.<br/>
        ///     -or-<br/>
        ///     <pramref name="fieldOfView.HorizontalDegrees"/> is less than 1.<br/>
        ///     -or-<br/>
        ///     <pramref name="fieldOfView.HorizontalDegrees"/> is greater than 360.<br/>
        ///     -or-<br/>
        ///     <pramref name="fieldOfView.VerticalDegrees"/> is less than 1.<br/>
        ///     -or-<br/>
        ///     <pramref name="fieldOfView.VerticalDegrees"/> is greater than 180.<br/>
        /// </exception>
        /// <seealso cref="FieldOfView"/>
        /// <seealso cref="GetZoom()"/>
        /// <since_tizen> 5 </since_tizen>
        public void SetZoomWithFieldOfView(float level, FieldOfView fieldOfView)
        {
            ValidationUtil.ValidateFeatureSupported(PlayerFeatures.OpenGl);
            ValidationUtil.ValidateFeatureSupported(PlayerFeatures.SphericalVideo);

            Player.ValidateNotDisposed();

            if (level < 1.0F || 10.0F < level)
            {
                throw new ArgumentOutOfRangeException(nameof(level), level, "Valid level is 1.0 to 10.0");
            }

            if (fieldOfView.HorizontalDegrees < 1 || fieldOfView.HorizontalDegrees > 360)
            {
                throw new ArgumentOutOfRangeException(nameof(fieldOfView.HorizontalDegrees), fieldOfView.HorizontalDegrees,
                                                      $"Valid range is 1-360 degrees. : " + fieldOfView.HorizontalDegrees);
            }

            if (fieldOfView.VerticalDegrees < 1 || fieldOfView.VerticalDegrees > 180)
            {
                throw new ArgumentOutOfRangeException(nameof(fieldOfView.VerticalDegrees), fieldOfView.VerticalDegrees,
                                                      $"Valid range is 1-180 degrees. : " + fieldOfView.VerticalDegrees);
            }

            NativePlayer.SetZoomWithFieldOfView(Player.Handle, level, fieldOfView.HorizontalDegrees, fieldOfView.VerticalDegrees).
            ThrowIfFailed(Player, "Failed to set the zoom with the field of the view.");
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Player"/> class.
        /// </summary>
        /// <since_tizen> 3 </since_tizen>
        public Player()
        {
            NativePlayer.Create(out _handle).ThrowIfFailed(null, "Failed to create player");

            Debug.Assert(_handle != null);

            Initialize();
        }
Example #9
0
        /// <summary>
        /// Disable to decode an audio data.
        /// </summary>
        /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> or <see cref="PlayerState.Ready"/>
        /// state.
        /// This function could be unavailable depending on the audio codec type.</remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <exception cref="NotAvailableException">The function is not available depending on the audio codec type. (Since tizen 6.0)</exception>
        /// <seealso cref="EnableExportingAudioData"/>
        /// <seealso cref="AudioCodecType"/>
        /// <since_tizen> 6 </since_tizen>
        public void DisableExportingAudioData()
        {
            ValidatePlayerState(PlayerState.Idle, PlayerState.Ready);

            NativePlayer.UnsetAudioFrameDecodedCb(Handle).
            ThrowIfFailed(this, "Failed to unset the AudioFrameDecoded");

            _audioFrameDecodedCallback = null;
        }
Example #10
0
        /// <summary>
        /// Gets the maximum limit of the streaming variant.
        /// </summary>
        /// <returns>The <see cref="VariantInfo"/> containing the variant information.</returns>
        /// <exception cref="ObjectDisposedException">The <see cref="Player"/> has already been disposed of.</exception>
        /// <seealso cref="SetMaxLimit(int, int, int)"/>
        /// <since_tizen> 5 </since_tizen>
        public VariantInfo GetMaxLimit()
        {
            Player.ValidateNotDisposed();

            NativePlayer.GetMaxLimit(Player.Handle, out var bandwidth, out var width, out var height).
            ThrowIfFailed(Player, "Failed to get the max limit to the player");

            return(new VariantInfo(bandwidth, width, height));
        }
Example #11
0
        private Size GetVideoSize()
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.GetVideoSize(Player.Handle, out var width, out var height).
            ThrowIfFailed(Player, "Failed to get the video size");

            return(new Size(width, height));
        }
Example #12
0
        /// <summary>
        /// Gets the properties of the video.
        /// </summary>
        /// <returns>A <see cref="VideoStreamProperties"/> that contains the video stream information.</returns>
        /// <remarks>
        /// The <see cref="Multimedia.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="Multimedia.Player"/> that this instance belongs to has been disposed of.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public VideoStreamProperties GetVideoProperties()
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.GetVideoStreamInfo(Player.Handle, out var fps, out var bitRate).
            ThrowIfFailed(Player, "Failed to get the video stream info");

            return(new VideoStreamProperties(fps, bitRate, GetVideoSize()));
        }
Example #13
0
        /// <summary>
        /// Get the relative ROI (Region Of Interest) area as a decimal fraction based on the video source.
        /// </summary>
        /// <returns>The <see cref="ScaleRectangle"/> containing the ROI area information.</returns>
        /// <remarks>The specified ROI area is valid only in <see cref="PlayerDisplayType.Overlay"/>.</remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">
        ///     Operation failed; internal error.
        ///     </exception>
        /// <seealso cref="Display"/>
        /// <seealso cref="StreamInfo.GetVideoProperties"/>
        /// <seealso cref="SetVideoRoi"/>
        /// <since_tizen> 5 </since_tizen>
        public ScaleRectangle GetVideoRoi()
        {
            ValidateNotDisposed();

            NativePlayer.GetVideoRoi(Handle, out var scaleX, out var scaleY,
                                     out var scaleWidth, out var scaleHeight).ThrowIfFailed(this, "Failed to get the video roi area");

            return(new ScaleRectangle(scaleX, scaleY, scaleWidth, scaleHeight));
        }
Example #14
0
        /// <summary>
        /// Gets the duration.
        /// </summary>
        /// <returns>The duration of the stream.</returns>
        /// <remarks>
        /// The <see cref="Multimedia.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="Multimedia.Player"/> that this instance belongs to has been disposed of.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public int GetDuration()
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.GetDuration(Player.Handle, out var duration).
            ThrowIfFailed(Player, "Failed to get the duration");

            Log.Info(PlayerLog.Tag, "get duration : " + duration);
            return(duration);
        }
Example #15
0
        /// <summary>
        /// Disables to decode a video data.
        /// </summary>
        /// <remarks>The player must be in the <see cref="PlayerState.Idle"/> or <see cref="PlayerState.Ready"/>
        /// state.</remarks>
        /// <feature>http://tizen.org/feature/multimedia.raw_video</feature>
        /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <seealso cref="EnableExportingVideoFrame"/>
        /// <since_tizen> 6 </since_tizen>
        public void DisableExportingVideoFrame()
        {
            ValidationUtil.ValidateFeatureSupported(PlayerFeatures.RawVideo);
            ValidatePlayerState(PlayerState.Idle, PlayerState.Ready);

            NativePlayer.UnsetVideoFrameDecodedCb(Handle).
            ThrowIfFailed(this, "Failed to unset the VideoFrameDecoded");

            _videoFrameDecodedCallback = null;
        }
Example #16
0
        /// <summary>
        /// Gets the properties of the audio.
        /// </summary>
        /// <returns>A <see cref="AudioStreamProperties"/> that contains the audio stream information.</returns>
        /// <remarks>
        /// The <see cref="Multimedia.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="Multimedia.Player"/> that this instance belongs to has been disposed of.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.
        /// </exception>
        /// <since_tizen> 3 </since_tizen>
        public AudioStreamProperties GetAudioProperties()
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.GetAudioStreamInfo(Player.Handle, out var sampleRate,
                                            out var channels, out var bitRate).
            ThrowIfFailed(Player, "Failed to get audio stream info");

            return(new AudioStreamProperties(sampleRate, channels, bitRate));
        }
Example #17
0
        /// <summary>
        /// Gets the duration in nanoseconds.
        /// </summary>
        /// <returns>The duration of the stream.</returns>
        /// <remarks>
        /// The <see cref="Multimedia.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="Multimedia.Player"/> that this instance belongs to has been disposed of.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// The <see cref="Multimedia.Player"/> that this instance belongs to is not in the valid state.
        /// </exception>
        /// <seealso cref="GetDuration"/>
        /// <since_tizen> 5 </since_tizen>
        public long GetDurationNanoseconds()
        {
            Player.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.GetDurationNanoseconds(Player.Handle, out var duration).
            ThrowIfFailed(Player, "Failed to get the duration in nanoseconds");

            Log.Info(PlayerLog.Tag, "get duration(nsec) : " + duration);
            return(duration);
        }
Example #18
0
 private void RegisterPlaybackCompletedCallback()
 {
     _playbackCompletedCallback = _ =>
     {
         Log.Debug(PlayerLog.Tag, "completed callback");
         PlaybackCompleted?.Invoke(this, EventArgs.Empty);
     };
     NativePlayer.SetCompletedCb(Handle, _playbackCompletedCallback).
     ThrowIfFailed(this, "Failed to set PlaybackCompleted");
 }
Example #19
0
        private void RegisterSubtitleUpdatedCallback()
        {
            _subtitleUpdatedCallback = (duration, text, _) =>
            {
                Log.Debug(PlayerLog.Tag, $"duration : {duration}, text : {text}");
                SubtitleUpdated?.Invoke(this, new SubtitleUpdatedEventArgs(duration, text));
            };

            NativePlayer.SetSubtitleUpdatedCb(Handle, _subtitleUpdatedCallback).
            ThrowIfFailed(this, "Failed to initialize the player");
        }
Example #20
0
        private void RegisterBufferingCallback()
        {
            _bufferingProgressCallback = (percent, _) =>
            {
                Log.Debug(PlayerLog.Tag, $"Buffering callback with percent { percent }");
                BufferingProgressChanged?.Invoke(this, new BufferingProgressChangedEventArgs(percent));
            };

            NativePlayer.SetBufferingCb(Handle, _bufferingProgressCallback).
            ThrowIfFailed("Failed to set BufferingProgress");
        }
Example #21
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.
        /// </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)");
            }

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

            NativePlayer.SetPlaybackRate(Handle, rate).ThrowIfFailed(this, "Failed to set the playback rate.");
        }
Example #22
0
        /// <summary>
        /// Gets the number of tracks.
        /// </summary>
        /// <returns>The number of tracks.</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 of.</exception>
        /// <exception cref="InvalidOperationException">The <see cref="Player"/> that this instance belongs to is not in the valid state.</exception>
        /// <since_tizen> 3 </since_tizen>
        public int GetCount()
        {
            _owner.ValidatePlayerState(PlayerState.Ready, PlayerState.Playing, PlayerState.Paused);

            NativePlayer.GetTrackCount(_owner.Handle, _streamType, out var count).
            ThrowIfFailed(_owner, "Failed to get count of the track");

            Log.Info(PlayerLog.Tag, "get count : " + count);

            return(count);
        }
Example #23
0
 public void Update(float delta)
 {
     if (_player == null)
     {
         _player = NativeEntityMgr.singleton.Player;
     }
     if (_camera != null && _player != null)
     {
         _camera.transform.position = _player.transfrom.position + _offset;
     }
 }
Example #24
0
        /// <summary>
        /// Starts or resumes playback.
        /// </summary>
        /// <remarks>
        /// The player must be in the <see cref="PlayerState.Ready"/> or <see cref="PlayerState.Paused"/> state.
        /// It has no effect if the player is already in the <see cref="PlayerState.Playing"/> state.<br/>
        /// <br/>
        /// Sound can be mixed with other sounds if you don't control the stream focus using <see cref="ApplyAudioStreamPolicy"/>.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <seealso cref="PrepareAsync"/>
        /// <seealso cref="Stop"/>
        /// <seealso cref="Pause"/>
        /// <seealso cref="PlaybackCompleted"/>
        /// <seealso cref="ApplyAudioStreamPolicy"/>
        /// <since_tizen> 3 </since_tizen>
        public virtual void Start()
        {
            if (State == PlayerState.Playing)
            {
                Log.Warn(PlayerLog.Tag, "playing state already");
                return;
            }
            ValidatePlayerState(PlayerState.Ready, PlayerState.Paused);

            NativePlayer.Start(Handle).ThrowIfFailed("Failed to start the player");
        }
Example #25
0
        /// <summary>
        /// Stops playing the media content.
        /// </summary>
        /// <remarks>
        /// The player must be in the <see cref="PlayerState.Playing"/> or <see cref="PlayerState.Paused"/> state.
        /// It has no effect if the player is already in the <see cref="PlayerState.Ready"/> state.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <seealso cref="Start"/>
        /// <seealso cref="Pause"/>
        /// <since_tizen> 3 </since_tizen>
        public virtual void Stop()
        {
            if (State == PlayerState.Ready)
            {
                Log.Warn(PlayerLog.Tag, "ready state already");
                return;
            }
            ValidatePlayerState(PlayerState.Paused, PlayerState.Playing);

            NativePlayer.Stop(Handle).ThrowIfFailed(this, "Failed to stop the player");
        }
Example #26
0
        /// <summary>
        /// Gets the play position in nanoseconds.
        /// </summary>
        /// <returns>The current position in nanoseconds.</returns>
        /// <remarks>The player must be in the <see cref="PlayerState.Ready"/>, <see cref="PlayerState.Playing"/>,
        /// or <see cref="PlayerState.Paused"/> state.</remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <seealso cref="SetPlayPositionAsync(int, bool)"/>
        /// <seealso cref="SetPlayPositionNanosecondsAsync(long, bool)"/>
        /// <seealso cref="GetPlayPosition"/>
        /// <since_tizen> 5 </since_tizen>
        public long GetPlayPositionNanoseconds()
        {
            ValidatePlayerState(PlayerState.Ready, PlayerState.Paused, PlayerState.Playing);

            NativePlayer.GetPlayPositionNanoseconds(Handle, out long playPosition).
            ThrowIfFailed(this, "Failed to get the play position(nsec) of the player");

            Log.Info(PlayerLog.Tag, $"get play position(nsec) : {playPosition}");

            return(playPosition);
        }
Example #27
0
        private void RegisterVideoStreamChangedCallback()
        {
            _videoStreamChangedCallback = (width, height, fps, bitrate, _) =>
            {
                Log.Debug(PlayerLog.Tag, $"height={height}, width={width}, fps={fps}, bitrate={bitrate}");

                VideoStreamChanged?.Invoke(this, new VideoStreamChangedEventArgs(height, width, fps, bitrate));
            };

            NativePlayer.SetVideoStreamChangedCb(Handle, _videoStreamChangedCallback).
            ThrowIfFailed(this, "Failed to set the video stream changed callback");
        }
Example #28
0
        private void RegisterErrorOccurredCallback()
        {
            _playbackErrorCallback = (code, _) =>
            {
                //TODO handle service disconnected error.
                Log.Warn(PlayerLog.Tag, "error code : " + code);
                ErrorOccurred?.Invoke(this, new PlayerErrorOccurredEventArgs((PlayerError)code));
            };

            NativePlayer.SetErrorCb(Handle, _playbackErrorCallback).
            ThrowIfFailed(this, "Failed to set PlaybackError");
        }
Example #29
0
        protected override bool ReleaseHandle()
        {
            var ret = NativePlayer.Destroy(handle);

            if (ret != PlayerErrorCode.None)
            {
                Log.Debug(GetType().FullName, $"Failed to release native {GetType().Name}");
                return(false);
            }

            return(true);
        }
Example #30
0
        /// <summary>
        /// Pauses the player.
        /// </summary>
        /// <remarks>
        /// The player must be in the <see cref="PlayerState.Playing"/> state.
        /// It has no effect if the player is already in the <see cref="PlayerState.Paused"/> state.
        /// </remarks>
        /// <exception cref="ObjectDisposedException">The player has already been disposed of.</exception>
        /// <exception cref="InvalidOperationException">The player is not in the valid state.</exception>
        /// <seealso cref="Start"/>
        /// <since_tizen> 3 </since_tizen>
        public virtual void Pause()
        {
            if (State == PlayerState.Paused)
            {
                Log.Warn(PlayerLog.Tag, "pause state already");
                return;
            }

            ValidatePlayerState(PlayerState.Playing);

            NativePlayer.Pause(Handle).ThrowIfFailed(this, "Failed to pause the player");
        }