Exemplo n.º 1
0
        /// <summary>
        /// Gets the value whether <see cref="MediaControlPlaybackCommand"/> is supported or not.
        /// </summary>
        /// <returns>
        /// the set of <see cref="MediaControlPlaybackCommand"/> and <see cref="MediaControlCapabilitySupport"/>.
        /// </returns>
        /// <exception cref="InvalidOperationException">
        ///     The server has already been stopped.<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed of.</exception>
        /// <since_tizen> 5 </since_tizen>
        public Dictionary <MediaControlPlaybackCommand, MediaControlCapabilitySupport> GetPlaybackCapabilities()
        {
            ThrowIfStopped();

            IntPtr playbackCapaHandle = IntPtr.Zero;

            var playbackCapabilities = new Dictionary <MediaControlPlaybackCommand, MediaControlCapabilitySupport>();

            try
            {
                Native.GetPlaybackCapabilityHandle(Manager.Handle, ServerAppId, out playbackCapaHandle).
                ThrowIfError("Failed to get playback capability handle.");

                foreach (MediaControllerNativePlaybackAction action in Enum.GetValues(typeof(MediaControllerNativePlaybackAction)))
                {
                    Native.IsCapabilitySupported(playbackCapaHandle, action, out MediaControlCapabilitySupport support);
                    playbackCapabilities.Add(action.ToPublic(), support);
                }

                return(playbackCapabilities);
            }
            finally
            {
                if (playbackCapaHandle != IntPtr.Zero)
                {
                    Native.DestroyCapability(playbackCapaHandle);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the value whether <paramref name="action"/> is supported or not.
        /// </summary>
        /// <param name="action">A playback command.</param>
        /// <returns>A <see cref="MediaControlCapabilitySupport"/>.</returns>
        /// <exception cref="ArgumentException"><paramref name="action"/> is not valid.</exception>
        /// <exception cref="InvalidOperationException">
        ///     The server has already been stopped.<br/>
        ///     -or-<br/>
        ///     An internal error occurs.
        /// </exception>
        /// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed of.</exception>
        /// <since_tizen> 5 </since_tizen>
        public MediaControlCapabilitySupport GetPlaybackCapability(MediaControlPlaybackCommand action)
        {
            ThrowIfStopped();

            ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), action, nameof(action));

            IntPtr playbackCapaHandle = IntPtr.Zero;

            try
            {
                Native.GetPlaybackCapabilityHandle(Manager.Handle, ServerAppId, out playbackCapaHandle).
                ThrowIfError("Failed to get playback capability handle.");

                Native.IsCapabilitySupported(playbackCapaHandle, action.ToNative(), out MediaControlCapabilitySupport support);

                return(support);
            }
            finally
            {
                if (playbackCapaHandle != IntPtr.Zero)
                {
                    Native.DestroyCapability(playbackCapaHandle);
                }
            }
        }
Exemplo n.º 3
0
        private PlaybackCapabilityUpdatedEventArgs CreatePlaybackCapabilityUpdatedEventArgs(IntPtr playbackCapaHandle)
        {
            var capabilities = new Dictionary <MediaControlPlaybackCommand, MediaControlCapabilitySupport>();

            try
            {
                foreach (MediaControllerNativePlaybackAction action in Enum.GetValues(typeof(MediaControllerNativePlaybackAction)))
                {
                    Native.IsCapabilitySupported(playbackCapaHandle, action, out MediaControlCapabilitySupport support);
                    capabilities.Add(action.ToPublic(), support);
                }

                return(new PlaybackCapabilityUpdatedEventArgs(capabilities));
            }
            catch (Exception e)
            {
                Log.Error(GetType().FullName, e.ToString());
            }
            return(null);
        }