internal delegate void RepeatCapabilityUpdatedCallback(string serverName, MediaControlCapabilitySupport support,
IntPtr userData = default(IntPtr));
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void SimpleCapabilityCallback(string serverName, MediaControlCapabilityCategory category,
+ MediaControlCapabilitySupport support, IntPtr userData = default(IntPtr));
+
[DllImport(Libraries.MediaController, EntryPoint = "mc_client_get_playback_content_type")]
internal static extern MediaControllerError GetPlaybackContentType(IntPtr playbackHandle,
internal static extern MediaControllerError GetPlaybackCapabilityHandle(MediaControllerClientHandle clientHandle,
string serverName, out IntPtr capaHandle);
- [DllImport(Libraries.MediaController, EntryPoint = "mc_client_get_server_shuffle_ability_support")]
- internal static extern MediaControllerError GetShuffleCapability(MediaControllerClientHandle clientHandle,
- string serverName, out MediaControlCapabilitySupport type);
-
- [DllImport(Libraries.MediaController, EntryPoint = "mc_client_get_server_repeat_ability_support")]
- internal static extern MediaControllerError GetRepeatCapability(MediaControllerClientHandle clientHandle,
- string serverName, out MediaControlCapabilitySupport type);
-
[DllImport(Libraries.MediaController, EntryPoint = "mc_client_set_playback_ability_updated_cb")]
internal static extern MediaControllerError SetPlaybackCapabilityUpdatedCb(MediaControllerClientHandle clientHandle,
PlaybackCapabilityUpdatedCallback callback, IntPtr userData = default(IntPtr));
[DllImport(Libraries.MediaController, EntryPoint = "mc_client_unset_playback_ability_updated_cb")]
internal static extern MediaControllerError UnsetPlaybackCapabilityUpdatedCb(MediaControllerClientHandle clientHandle);
- [DllImport(Libraries.MediaController, EntryPoint = "mc_client_set_shuffle_ability_updated_cb")]
- internal static extern MediaControllerError SetShuffleCapabilityUpdatedCb(MediaControllerClientHandle clientHandle,
- ShuffleCapabilityUpdatedCallback callback, IntPtr userData = default(IntPtr));
-
- [DllImport(Libraries.MediaController, EntryPoint = "mc_client_unset_shuffle_ability_updated_cb")]
- internal static extern MediaControllerError UnsetShuffleCapabilityUpdatedCb(MediaControllerClientHandle clientHandle);
-
- [DllImport(Libraries.MediaController, EntryPoint = "mc_client_set_repeat_ability_updated_cb")]
- internal static extern MediaControllerError SetRepeatCapabilityUpdatedCb(MediaControllerClientHandle clientHandle,
- RepeatCapabilityUpdatedCallback callback, IntPtr userData = default(IntPtr));
+ [DllImport(Libraries.MediaController, EntryPoint = "mc_client_set_ability_support_updated_cb")]
+ internal static extern MediaControllerError SetSimpleCapabilityUpdatedCb(MediaControllerClientHandle clientHandle,
+ SimpleCapabilityCallback callback, IntPtr userData = default(IntPtr));
- [DllImport(Libraries.MediaController, EntryPoint = "mc_client_unset_repeat_ability_updated_cb")]
- internal static extern MediaControllerError UnsetRepeatCapabilityUpdatedCb(MediaControllerClientHandle clientHandle);
+ [DllImport(Libraries.MediaController, EntryPoint = "mc_client_get_server_ability_support")]
+ internal static extern MediaControllerError GetSimpleCapability(MediaControllerClientHandle clientHandle,
+ string serverName, MediaControlCapabilityCategory category, out MediaControlCapabilitySupport type);
[DllImport(Libraries.MediaController, EntryPoint = "mc_playback_ability_clone")]
internal static extern MediaControllerError CloneCapability(IntPtr capaSrcHandle, out IntPtr capaDstHandle);
[DllImport(Libraries.MediaController, EntryPoint = "mc_server_update_playback_ability")]
internal static extern MediaControllerError SaveAndNotifyPlaybackCapabilityUpdated(IntPtr serverHandle);
- [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_shuffle_ability")]
- internal static extern MediaControllerError SetShuffleModeCapability(IntPtr serverHandle,
- MediaControlCapabilitySupport support);
-
- [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_repeat_ability")]
- internal static extern MediaControllerError SetRepeatModeCapability(IntPtr serverHandle,
- MediaControlCapabilitySupport support);
+ [DllImport(Libraries.MediaController, EntryPoint = "mc_server_set_ability_support")]
+ internal static extern MediaControllerError SetSimpleCapability(IntPtr serverHandle,
+ MediaControlCapabilityCategory category, MediaControlCapabilitySupport support);
#endregion Capability
#region Search
Episode,
Resolution
}
+
+ internal enum MediaControlCapabilityCategory
+ {
+ Shuffle,
+ Repeat,
+ PlaybackPosition,
+ Playlist,
+ ClientCustom,
+ Search,
+ Subtitle,
+ Mode360
+ }
}
\ No newline at end of file
{
ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support));
- Native.SetShuffleModeCapability(Handle, support).ThrowIfError("Failed to set shuffle mode capability.");
+ Native.SetSimpleCapability(Handle, MediaControlCapabilityCategory.Shuffle, support).
+ ThrowIfError("Failed to set shuffle mode capability.");
}
/// <summary>
{
ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support));
- Native.SetRepeatModeCapability(Handle, support).ThrowIfError("Failed to set shuffle mode capability.");
+ Native.SetSimpleCapability(Handle, MediaControlCapabilityCategory.Repeat, support).
+ ThrowIfError("Failed to set repeat mode capability.");
}
#endregion Capabilities
Native.GetPlaybackCapabilityHandle(Manager.Handle, ServerAppId, out playbackCapaHandle).
ThrowIfError("Failed to get playback capability handle.");
- Native.GetShuffleCapability(Manager.Handle, ServerAppId, out MediaControlCapabilitySupport support);
+ Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlCapabilityCategory.Shuffle, out MediaControlCapabilitySupport support).
+ ThrowIfError("Failed to get shuffle mode capability");
return support;
}
Native.GetPlaybackCapabilityHandle(Manager.Handle, ServerAppId, out playbackCapaHandle).
ThrowIfError("Failed to get playback capability handle.");
- Native.GetRepeatCapability(Manager.Handle, ServerAppId, out MediaControlCapabilitySupport support);
+ Native.GetSimpleCapability(Manager.Handle, ServerAppId, MediaControlCapabilityCategory.Repeat, out MediaControlCapabilitySupport support).
+ ThrowIfError("Failed to get repeat mode capability");
return support;
}
private NativePlaylist.MetadataUpdatedCallback _metadataUpdatedCallback;
private NativePlaylist.PlaylistUpdatedCallback _playlistUpdatedCallback;
private Native.PlaybackCapabilityUpdatedCallback _playbackCapabilityUpdatedCallback;
- private Native.ShuffleCapabilityUpdatedCallback _shuffleModeCapabilityUpdatedCallback;
- private Native.RepeatCapabilityUpdatedCallback _repeatModeCapabilityUpdatedCallback;
+ private Native.SimpleCapabilityCallback _simpleCapabilityUpdatedCallback;
private Native.CustomCommandReceivedCallback _customCommandReceivedCallback;
/// <summary>
RegisterPlaylistUpdatedEvent();
RegisterCommandCompletedEvent();
RegisterPlaybackCapabilitiesEvent();
- RegisterRepeatModeCapabilitiesEvent();
- RegisterShuffleModeCapabilitiesEvent();
RegisterCustomCommandReceivedEvent();
+ RegisterSimpleCapabilityEvent();
}
private void RaiseServerChangedEvent(MediaControllerNativeServerState state, MediaController controller)
ThrowIfError("Failed to init PlaybackCapabilityUpdated event.");
}
- private void RegisterRepeatModeCapabilitiesEvent()
- {
- _repeatModeCapabilityUpdatedCallback = (serverName, support, _) =>
- {
- GetController(serverName)?.RaiseRepeatModeCapabilityUpdatedEvent(support);
- };
-
- Native.SetRepeatCapabilityUpdatedCb(Handle, _repeatModeCapabilityUpdatedCallback).
- ThrowIfError("Failed to init RepeatModeCapabilityUpdated event.");
- }
-
- private void RegisterShuffleModeCapabilitiesEvent()
- {
- _shuffleModeCapabilityUpdatedCallback = (serverName, support, _) =>
- {
- GetController(serverName)?.RaiseShuffleModeCapabilityUpdatedEvent(support);
- };
-
- Native.SetShuffleCapabilityUpdatedCb(Handle, _shuffleModeCapabilityUpdatedCallback).
- ThrowIfError("Failed to init ShuffleModeCapabilityUpdated event.");
- }
-
private void RegisterCustomCommandReceivedEvent()
{
_customCommandReceivedCallback = (serverName, requestId, customEvent, bundleHandle, _) =>
Native.SetCustomEventCb(Handle, _customCommandReceivedCallback).
ThrowIfError("Failed to init CustomCommandReceived event.");
}
+
+ private void RegisterSimpleCapabilityEvent()
+ {
+ _simpleCapabilityUpdatedCallback = (serverName, category, support, _) =>
+ {
+ switch (category)
+ {
+ case MediaControlCapabilityCategory.Repeat:
+ GetController(serverName)?.RaiseRepeatModeCapabilityUpdatedEvent(support);
+ break;
+ case MediaControlCapabilityCategory.Shuffle:
+ GetController(serverName)?.RaiseShuffleModeCapabilityUpdatedEvent(support);
+ break;
+ }
+ };
+
+ Native.SetSimpleCapabilityUpdatedCb(Handle, _simpleCapabilityUpdatedCallback).
+ ThrowIfError("Failed to init capability updated event.");
+ }
}
}
\ No newline at end of file