IntPtr handle, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void PlaylistCallback(IntPtr handle, IntPtr userData);
+ internal delegate bool PlaylistCallback(IntPtr handle, IntPtr userData);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool PlaylistItemCallback(string index, IntPtr handle, IntPtr userData);
var playlists = new List<MediaControlPlaylist>();
+ Exception caught = null;
+
NativePlaylist.PlaylistCallback playlistCallback = (handle, _) =>
{
- playlists.Add(new MediaControlPlaylist(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();
}