* [MediaController] fix bugs and svace issues.
/// </summary>
/// <param name="requestId">The request id for each command.</param>
/// <param name="result">The result of commands.</param>
+ /// <exception cref="ArgumentException"><paramref name="result"/> is not vailid.</exception>
+ /// <exception cref="ArgumentNullException"><paramref name="requestId"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
internal CommandCompletedEventArgs(string requestId, MediaControllerError result)
{
- RequestId = requestId;
+ ValidationUtil.ValidateEnum(typeof(MediaControllerError), result, nameof(result));
+
+ RequestId = requestId ?? throw new ArgumentNullException(nameof(requestId));
Result = result;
}
/// Initializes a new instance of the <see cref="CustomCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The playback position command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public CustomCommandReceivedEventArgs(CustomCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>
/// Initializes a new instance of the <see cref="PlaybackCommand"/> class.
/// </summary>
/// <param name="action">A <see cref="MediaControlPlaybackCommand"/>.</param>
+ /// <exception cref="ArgumentException"><paramref name="action"/> is not valid.</exception>
/// <since_tizen> 5 </since_tizen>
public PlaybackCommand(MediaControlPlaybackCommand action)
{
+ ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), action, nameof(action));
+
Action = action;
}
internal override string Request(NativeClientHandle clientHandle)
{
- ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), Action, nameof(MediaControlPlaybackCommand));
+ ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), Action, nameof(Action));
NativeClient.SendPlaybackActionCommand(clientHandle, ReceiverId, Action.ToNative(), out string requestId)
.ThrowIfError("Failed to send playback command.");
/// <param name="playlistName">The playlist name of the server.</param>
/// <param name="index">The index of the media in the playlist.</param>
/// <param name="position">The playback position in milliseconds.</param>
- /// <exception cref="ArgumentException"><paramref name="index"/> cannot be converted to number.</exception>
+ /// <exception cref="ArgumentException"><paramref name="action"/>is not valid.</exception>
/// <exception cref="ArgumentNullException">
- /// <paramref name="playlistName"/> or <paramref name="index"/> is not vailed.
+ /// <paramref name="playlistName"/> or <paramref name="index"/> is null.
/// </exception>
/// <since_tizen> 5 </since_tizen>
public PlaylistCommand(MediaControlPlaybackCommand action, string playlistName, string index, ulong position)
{
+ ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), action, nameof(action));
+
Action = action;
Index = index ?? throw new ArgumentNullException(nameof(index));
Name = playlistName ?? throw new ArgumentNullException(nameof(playlistName));
/// <param name="action">A <see cref="MediaControlPlaybackCommand"/>.</param>
/// <param name="playlistName">The playlist name of the server.</param>
/// <param name="index">The index of the media in the playlist.</param>
- /// <exception cref="ArgumentException"><paramref name="index"/> cannot be converted to number.</exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="playlistName"/> or <paramref name="index"/> is null.
/// </exception>
internal override string Request(NativeClientHandle clientHandle)
{
- ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), Action, nameof(MediaControlPlaybackCommand));
+ ValidationUtil.ValidateEnum(typeof(MediaControlPlaybackCommand), Action, nameof(Action));
NativeClient.SendPlaylistCommand(clientHandle, ReceiverId, Name, Index, Action.ToNative(),
Position, out string requestId).ThrowIfError("Failed to send playlist command.");
/// Initializes a new instance of the <see cref="RepeatModeCommand"/> class.
/// </summary>
/// <param name="mode">The <see cref="MediaControlRepeatMode"/>.</param>
+ /// <exception cref="ArgumentException"><paramref name="mode"/> is not vailid.</exception>
/// <since_tizen> 5 </since_tizen>
public RepeatModeCommand(MediaControlRepeatMode mode)
{
+ ValidationUtil.ValidateEnum(typeof(MediaControlRepeatMode), mode, nameof(mode));
+
Mode = mode;
}
internal override string Request(NativeClientHandle clientHandle)
{
- ValidationUtil.ValidateEnum(typeof(MediaControlRepeatMode), Mode, nameof(MediaControlRepeatMode));
+ ValidationUtil.ValidateEnum(typeof(MediaControlRepeatMode), Mode, nameof(Mode));
NativeClient.SendRepeatModeCommand(clientHandle, ReceiverId, Mode.ToNative(), out string requestId).
ThrowIfError("Failed to send playback repeat command.");
/// <summary>
/// Initializes a new instance of the <see cref="SearchCommand"/> class.
/// </summary>
+ /// <exception cref="ArgumentNullException"><paramref name="condition"/> is not set.</exception>
/// <exception cref="InvalidOperationException">An internal error occurs.</exception>
/// <param name="condition">The set of <see cref="MediaControlSearchCondition"/>.</param>
/// <since_tizen> 5 </since_tizen>
public SearchCommand(MediaControlSearchCondition condition)
{
+ if (condition == null)
+ {
+ throw new ArgumentNullException(nameof(condition));
+ }
+
NativeClient.CreateSearchHandle(out _searchHandle).ThrowIfError("Failed to create search handle.");
try
{
get
{
- return _metadata != null ? _metadata.Count : 0;
+ return _metadata?.Count ?? 0;
}
}
/// <returns>The dictionary set of index and <see cref="MediaControlMetadata"/> pair.</returns>
public Dictionary<string, MediaControlMetadata> GetMetadata()
{
- if (_metadata == null)
+ if (TotalCount == 0)
{
UpdateMetadata(Handle);
}
/// Gets the metadata by index.
/// </summary>
/// <param name="index">The index of media in the playlist.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="index"/> is null.</exception>
/// <returns>A <see cref="MediaControlMetadata"/> instance.</returns>
public MediaControlMetadata GetMetadata(string index)
{
- if (_metadata == null)
+ if (index == null)
+ {
+ throw new ArgumentNullException(nameof(index));
+ }
+
+ if (TotalCount == 0)
{
UpdateMetadata(Handle);
}
/// Sets the metadata to the playlist.
/// </summary>
/// <param name="metadata">The metadata of media.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="metadata"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public void AddMetadata(Dictionary<string, MediaControlMetadata> metadata)
{
+ if (metadata == null)
+ {
+ throw new ArgumentNullException(nameof(metadata));
+ }
+
foreach (var data in metadata)
{
AddMetadata(data.Key, data.Value);
/// </summary>
/// <param name="index">The index of media in the playlist.</param>
/// <param name="metadata">The metadata of media.</param>
+ /// <exception cref="ArgumentNullException">
+ /// <paramref name="index"/> or <paramref name="metadata"/> is null.
+ /// </exception>
/// <since_tizen> 5 </since_tizen>
public void AddMetadata(string index, MediaControlMetadata metadata)
{
+ if (index == null)
+ {
+ throw new ArgumentNullException(nameof(index));
+ }
+ if (metadata == null)
+ {
+ throw new ArgumentNullException(nameof(metadata));
+ }
+
AddItemToPlaylist(index, metadata);
_metadata.Add(index, metadata);
/// </remarks>
/// <param name="command">A <see cref="Command"/> class.</param>
/// <param name="clientId">The client Id to send command.</param>
- /// <returns>A task that represents the asynchronous operation.</returns>
+ /// <returns><see cref="Bundle"/> represents the extra data from client and it can be null.</returns>
/// <exception cref="InvalidOperationException">
/// The server has already been stopped.<br/>
/// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <since_tizen> 5 </since_tizen>
- public static async Task RequestAsync(Command command, string clientId)
+ public static async Task<Bundle> RequestAsync(Command command, string clientId)
{
command.SetRequestInformation(clientId);
var tcs = new TaskCompletionSource<MediaControllerError>();
string reqeustId = null;
+ Bundle bundle = null;
EventHandler<CommandCompletedEventArgs> eventHandler = (s, e) =>
{
if (e.RequestId == reqeustId)
{
+ bundle = e.Bundle;
tcs.TrySetResult(e.Result);
}
};
reqeustId = command.Request(Handle);
(await tcs.Task).ThrowIfError("Failed to request event.");
+
+ return bundle;
}
finally
{
/// <since_tizen> 4 </since_tizen>
public MediaControlServerStartedEventArgs(MediaController mediaController)
{
- if (mediaController == null)
- {
- throw new ArgumentNullException(nameof(mediaController));
- }
-
- Controller = mediaController;
+ Controller = mediaController ?? throw new ArgumentNullException(nameof(mediaController));
}
/// <summary>
/// <since_tizen> 4 </since_tizen>
public MediaControlServerStoppedEventArgs(string serverAppId)
{
- if (serverAppId == null)
- {
- throw new ArgumentNullException(nameof(serverAppId));
- }
-
- ServerAppId = serverAppId;
+ ServerAppId = serverAppId ?? throw new ArgumentNullException(nameof(serverAppId));
}
/// <summary>
/// and then, the client receive the result of each request(command).
/// </remarks>
/// <param name="command">A <see cref="Command"/> class.</param>
- /// <returns>A task that represents the asynchronous operation.</returns>
+ /// <returns><see cref="Bundle"/> represents the extra data from server and it can be null.</returns>
/// <exception cref="InvalidOperationException">
/// The server has already been stopped.<br/>
/// -or-<br/>
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MediaControllerManager"/> has already been disposed of.</exception>
/// <since_tizen> 5 </since_tizen>
- public async Task RequestAsync(Command command)
+ public async Task<Bundle> RequestAsync(Command command)
{
ThrowIfStopped();
var tcs = new TaskCompletionSource<MediaControllerError>();
string reqeustId = null;
+ Bundle bundle = null;
EventHandler<CommandCompletedEventArgs> eventHandler = (s, e) =>
{
if (e.RequestId == reqeustId)
{
+ bundle = e.Bundle;
tcs.TrySetResult(e.Result);
}
};
reqeustId = command.Request(Manager.Handle);
(await tcs.Task).ThrowIfError("Failed to request command");
+
+ return bundle;
}
finally
{
/// Initializes a new instance of the <see cref="PlaybackActionCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The playback command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public PlaybackActionCommandReceivedEventArgs(PlaybackCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>
/// Initializes a new instance of the <see cref="PlaybackPositionCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The playback position command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public PlaybackPositionCommandReceivedEventArgs(PlaybackPositionCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>
/// Initializes a new instance of the <see cref="PlaylistCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The playback position command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public PlaylistCommandReceivedEventArgs(PlaylistCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>
/// <param name="name">A value indicating the playlist name.</param>
/// <param name="playlist">A value indicating the playlist.</param>
/// <exception cref="ArgumentException"><paramref name="mode"/> is invalid.</exception>
+ /// <exception cref="ArgumentNullException">
+ /// <paramref name="name"/> or <paramref name="playlist"/> is null.
+ /// </exception>
/// <since_tizen> 5 </since_tizen>
public PlaylistUpdatedEventArgs(MediaControlPlaylistMode mode, string name, MediaControlPlaylist playlist)
{
ValidationUtil.ValidateEnum(typeof(MediaControlPlaylistMode), mode, nameof(mode));
Mode = mode;
- Name = name;
- Playlist = playlist;
+ Name = name ?? throw new ArgumentNullException(nameof(name));
+ Playlist = playlist ?? throw new ArgumentNullException(nameof(playlist));
}
/// <summary>
/// Initializes a new instance of the <see cref="RepeatModeCapabilityUpdatedEventArgs"/> class.
/// </summary>
/// <param name="support">The repeat mode capabilities.</param>
+ /// <exception cref="ArgumentException"><paramref name="support"/> is not vaild.</exception>
/// <since_tizen> 5 </since_tizen>
public RepeatModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support)
{
+ ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support));
+
Support = support;
}
/// Initializes a new instance of the <see cref="RepeatModeCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The playback position command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public RepeatModeCommandReceivedEventArgs(RepeatModeCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>
/// Initializes a new instance of the <see cref="SearchCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The search command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public SearchCommandReceivedEventArgs(SearchCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>
/// Initializes a new instance of the <see cref="ShuffleModeCapabilityUpdatedEventArgs"/> class.
/// </summary>
/// <param name="support">The shuffle mode capabilities.</param>
+ /// <exception cref="ArgumentException"><paramref name="support"/> is not vaild.</exception>
/// <since_tizen> 5 </since_tizen>
public ShuffleModeCapabilityUpdatedEventArgs(MediaControlCapabilitySupport support)
{
+ ValidationUtil.ValidateEnum(typeof(MediaControlCapabilitySupport), support, nameof(support));
+
Support = support;
}
/// Initializes a new instance of the <see cref="ShuffleModeCommandReceivedEventArgs"/> class.
/// </summary>
/// <param name="command">The playback position command.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="command"/> is null.</exception>
/// <since_tizen> 5 </since_tizen>
public ShuffleModeCommandReceivedEventArgs(ShuffleModeCommand command)
{
- Command = command;
+ Command = command ?? throw new ArgumentNullException(nameof(command));
}
/// <summary>