Exemple #1
0
        /// <summary>
        /// Returns the index of current playing media.
        /// </summary>
        /// <returns>The index of current playing media.</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.</exception>
        /// <since_tizen> 5 </since_tizen>
        public string GetIndexOfCurrentPlayingMedia()
        {
            ThrowIfStopped();

            IntPtr playbackHandle = IntPtr.Zero;

            try
            {
                Native.GetServerPlaybackHandle(Manager.Handle, ServerAppId, out playbackHandle).ThrowIfError("Failed to get playback.");

                var(name, index) = NativePlaylist.GetPlaylistInfo(playbackHandle);
                return(index);
            }
            finally
            {
                if (playbackHandle != IntPtr.Zero)
                {
                    Native.DestroyPlayback(playbackHandle).ThrowIfError("Failed to destroy playback handle.");
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Returns the playlist name of current playing media.
        /// </summary>
        /// <returns>The playlist name.</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.</exception>
        /// <since_tizen> 5 </since_tizen>
        public MediaControlPlaylist GetPlaylistOfCurrentPlayingMedia()
        {
            ThrowIfStopped();

            IntPtr playbackHandle = IntPtr.Zero;

            // Get the playlist name of current playing media.
            try
            {
                Native.GetServerPlaybackHandle(Manager.Handle, ServerAppId, out playbackHandle).ThrowIfError("Failed to get playback.");

                var(name, index) = NativePlaylist.GetPlaylistInfo(playbackHandle);

                return(GetPlaylists().FirstOrDefault(playlist => playlist.Name == name));
            }
            finally
            {
                if (playbackHandle != IntPtr.Zero)
                {
                    Native.DestroyPlayback(playbackHandle).ThrowIfError("Failed to destroy playback handle.");
                }
            }
        }