예제 #1
0
        internal static MediaControllerNativePlaybackState ToNative(this MediaControlPlaybackState state)
        {
            switch (state)
            {
            case MediaControlPlaybackState.Playing: return(MediaControllerNativePlaybackState.Play);

            case MediaControlPlaybackState.Paused: return(MediaControllerNativePlaybackState.Pause);

            case MediaControlPlaybackState.Stopped: return(MediaControllerNativePlaybackState.Stop);

            case MediaControlPlaybackState.MovingToNext: return(MediaControllerNativePlaybackState.MovingToNext);

            case MediaControlPlaybackState.MovingToPrevious: return(MediaControllerNativePlaybackState.MovingToPrev);

            case MediaControlPlaybackState.FastForwarding: return(MediaControllerNativePlaybackState.FastForwarding);

            case MediaControlPlaybackState.Rewinding: return(MediaControllerNativePlaybackState.Rewinding);

            case MediaControlPlaybackState.Connecting: return(MediaControllerNativePlaybackState.Connecting);

            case MediaControlPlaybackState.Buffering: return(MediaControllerNativePlaybackState.Buffering);

            case MediaControlPlaybackState.Error: return(MediaControllerNativePlaybackState.Error);
            }
            return(MediaControllerNativePlaybackState.None);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaybackStateUpdatedEventArgs"/> class.
        /// </summary>
        /// <param name="state">The playback state.</param>
        /// <param name="position">The playback position in milliseconds.</param>
        /// <exception cref="ArgumentException"><paramref name="state"/> is invalid.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="position"/> is less than zero.</exception>
        /// <since_tizen> 4 </since_tizen>
        public PlaybackStateUpdatedEventArgs(MediaControlPlaybackState state, long position)
        {
            ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackState), state, nameof(state));

            if (position < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(position), position, "position can't be less than zero.");
            }

            State    = state;
            Position = position;
        }
예제 #3
0
        /// <summary>
        /// Updates playback state and playback position.</summary>
        /// <param name="state">The playback state.</param>
        /// <param name="position">The playback position in milliseconds.</param>
        /// <exception cref="ArgumentException"><paramref name="state"/> is not valid.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="position"/> is less than zero.</exception>
        /// <exception cref="InvalidOperationException">
        ///     The server is not running .<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <since_tizen> 4 </since_tizen>
        public static void SetPlaybackState(MediaControlPlaybackState state, long position)
        {
            ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackState), state, nameof(state));

            if (position < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(position), position, "position can't be less than zero.");
            }

            Native.SetPlaybackState(Handle, state.ToNative()).ThrowIfError("Failed to set playback state.");

            Native.SetPlaybackPosition(Handle, (ulong)position).ThrowIfError("Failed to set playback position.");

            Native.UpdatePlayback(Handle).ThrowIfError("Failed to set playback.");
        }
예제 #4
0
        internal static MediaControllerPlaybackCode ToCode(this MediaControlPlaybackState state)
        {
            switch (state)
            {
            case MediaControlPlaybackState.Playing: return(MediaControllerPlaybackCode.Play);

            case MediaControlPlaybackState.Paused: return(MediaControllerPlaybackCode.Pause);

            case MediaControlPlaybackState.Stopped: return(MediaControllerPlaybackCode.Stop);

            case MediaControlPlaybackState.FastForwarding: return(MediaControllerPlaybackCode.FastForward);

            case MediaControlPlaybackState.Rewinding: return(MediaControllerPlaybackCode.Rewind);
            }
            return(MediaControllerPlaybackCode.None);
        }