Beispiel #1
0
        /// <summary>
        /// Returns the all playlists.
        /// </summary>
        /// <returns>The set of <see cref="MediaControlPlaylist"/>.</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 IEnumerable <MediaControlPlaylist> GetPlaylists()
        {
            ThrowIfStopped();

            var playlists = new List <MediaControlPlaylist>();

            Exception caught = null;

            NativePlaylist.PlaylistCallback playlistCallback = (handle, _) =>
            {
                try
                {
                    playlists.Add(new MediaControlPlaylist(handle));
                    return(true);
                }
                catch (Exception e)
                {
                    caught = e;
                    return(false);
                }
            };
            NativePlaylist.ForeachServerPlaylist(Manager.Handle, ServerAppId, playlistCallback, IntPtr.Zero)
            .ThrowIfError("Failed to get playlist.");

            if (caught != null)
            {
                throw caught;
            }

            return(playlists.AsReadOnly());
        }
Beispiel #2
0
        /// <summary>
        /// Returns the all playlists.
        /// </summary>
        /// <returns>The set of <see cref="MediaControlPlaylist"/>.</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 IEnumerable <MediaControlPlaylist> GetPlaylists()
        {
            ThrowIfStopped();

            var playlists = new List <MediaControlPlaylist>();

            NativePlaylist.PlaylistCallback playlistCallback = (handle, _) =>
            {
                playlists.Add(new MediaControlPlaylist(handle));
            };
            NativePlaylist.ForeachServerPlaylist(Manager.Handle, ServerAppId, playlistCallback, IntPtr.Zero)
            .ThrowIfError("Failed to get playlist.");

            return(playlists.AsReadOnly());
        }