namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// CustomCommandRecieved event arguments
- /// </summary>
- /// <remarks>
- /// CustomCommandRecieved event arguments
- /// </remarks>
- public class CustomCommandEventArgs : EventArgs
- {
- internal string _clientName;
- internal string _command;
- internal Bundle _bundle;
+ /// <summary>
+ /// CustomCommandRecieved event arguments
+ /// </summary>
+ /// <remarks>
+ /// CustomCommandRecieved event arguments
+ /// </remarks>
+ public class CustomCommandEventArgs : EventArgs
+ {
+ internal string _clientName;
+ internal string _command;
+ internal Bundle _bundle;
- public CustomCommandEventArgs (string name, string command, Bundle bundle)
- {
- _clientName = name;
- _command = command;
- _bundle = bundle;
- }
+ internal CustomCommandEventArgs (string name, string command, Bundle bundle)
+ {
+ _clientName = name;
+ _command = command;
+ _bundle = bundle;
+ }
- /// <summary>
- /// Get client name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ClientName
- {
- get
- {
- return _clientName;
- }
- }
+ /// <summary>
+ /// Get client name.
+ /// </summary>
+ public string ClientName
+ {
+ get
+ {
+ return _clientName;
+ }
+ }
- /// <summary>
- /// Get custom command.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string Command
- {
- get
- {
- return _command;
- }
- }
+ /// <summary>
+ /// Get custom command.
+ /// </summary>
+ public string Command
+ {
+ get
+ {
+ return _command;
+ }
+ }
- /// <summary>
- /// Get bundle data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public Bundle BundleData
- {
- get
- {
- return _bundle;
- }
- }
- }
+ /// <summary>
+ /// Get bundle data.
+ /// </summary>
+ public Bundle BundleData
+ {
+ get
+ {
+ return _bundle;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// CustomCommandRecieved event arguments
- /// </summary>
- /// <remarks>
- /// CustomCommandRecieved event arguments
- /// </remarks>
- public class CustomCommandReplyEventArgs : EventArgs
- {
- internal string _serverName;
- internal int _result;
- internal Bundle _bundle;
+ /// <summary>
+ /// CustomCommandRecieved event arguments
+ /// </summary>
+ /// <remarks>
+ /// CustomCommandRecieved event arguments
+ /// </remarks>
+ public class CustomCommandReplyEventArgs : EventArgs
+ {
+ internal string _serverName;
+ internal int _result;
+ internal Bundle _bundle;
- public CustomCommandReplyEventArgs (string serverName, int result, Bundle bundle)
- {
- _serverName = serverName;
- _result = result;
- _bundle = bundle;
- }
+ internal CustomCommandReplyEventArgs (string serverName, int result, Bundle bundle)
+ {
+ _serverName = serverName;
+ _result = result;
+ _bundle = bundle;
+ }
- /// <summary>
- /// Get server name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ServerName
- {
- get
- {
- return _serverName;
- }
- }
+ /// <summary>
+ /// Get server name.
+ /// </summary>
+ public string ServerName
+ {
+ get
+ {
+ return _serverName;
+ }
+ }
- /// <summary>
- /// Get playback information.
- /// </summary>
- /// <value> 0 - 100 </value>
- public int Result
- {
- get
- {
- return _result;
- }
- }
+ /// <summary>
+ /// Get playback information.
+ /// </summary>
+ public int Result
+ {
+ get
+ {
+ return _result;
+ }
+ }
- /// <summary>
- /// Get bundle data.
- /// </summary>
- /// <value> 0 - 100 </value>
- public Bundle BundleData
- {
- get
- {
- return _bundle;
- }
- }
- }
+ /// <summary>
+ /// Get bundle data.
+ /// </summary>
+ public Bundle BundleData
+ {
+ get
+ {
+ return _bundle;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// The MediaControllerClient class provides APIs required for media-controller-client.
- /// </summary>
- /// <remarks>
- /// The MediaControllerClient APIs provides functions to
- /// </remarks>
- public class MediaControllerClient : IDisposable
- {
- internal IntPtr _handle = IntPtr.Zero;
-
- private bool _disposed = false;
- private EventHandler<ServerUpdatedEventArgs> _serverUpdated;
- private Interop.MediaControllerClient.ServerUpdatedCallback _serverUpdatedCallback;
- private EventHandler<PlaybackUpdatedEventArgs> _playbackUpdated;
- private Interop.MediaControllerClient.PlaybackUpdatedCallback _playbackUpdatedCallback;
- private EventHandler<MetadataUpdatedEventArgs> _metadataUpdated;
- private Interop.MediaControllerClient.MetadataUpdatedCallback _metadataUpdatedCallback;
- private EventHandler<ShuffleModeUpdatedEventArgs> _shufflemodeUpdated;
- private Interop.MediaControllerClient.ShuffleModeUpdatedCallback _shufflemodeUpdatedCallback;
- private EventHandler<RepeatModeUpdatedEventArgs> _repeatmodeUpdated;
- private Interop.MediaControllerClient.RepeatModeUpdatedCallback _repeatmodeUpdatedCallback;
- private EventHandler<CustomCommandReplyEventArgs> _customcommandReply;
- private Interop.MediaControllerClient.CommandReplyRecievedCallback _customcommandReplyCallback;
-
- public MediaControllerClient ()
- {
- Interop.MediaControllerClient.Create (out _handle);
- }
-
- ~MediaControllerClient ()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if(!_disposed)
- {
- if(disposing)
- {
- // To be used if there are any other disposable objects
- }
- if(_handle != IntPtr.Zero)
- {
- Interop.MediaControllerClient.Destroy(_handle);
- _handle = IntPtr.Zero;
- }
- _disposed = true;
- }
- }
-
- /// <summary>
- /// ServerUpdated event is raised when server is changed
- /// </summary>
- public event EventHandler<ServerUpdatedEventArgs> ServerUpdated
- {
- add
- {
- if(_serverUpdated == null)
- {
- RegisterServerUpdatedEvent();
- }
- _serverUpdated += value;
-
- }
- remove
- {
- _serverUpdated -= value;
- if(_serverUpdated == null)
- {
- UnregisterServerUpdatedEvent();
- }
- }
- }
-
- /// <summary>
- /// PlaybackUpdated event is raised when playback is changed
- /// </summary>
- public event EventHandler<PlaybackUpdatedEventArgs> PlaybackUpdated
- {
- add
- {
- if(_playbackUpdated == null)
- {
- RegisterPlaybackUpdatedEvent();
- }
- _playbackUpdated += value;
-
- }
- remove
- {
- _playbackUpdated -= value;
- if(_playbackUpdated == null)
- {
- UnregisterPlaybackUpdatedEvent();
- }
- }
- }
-
- /// <summary>
- /// MetadataUpdated event is raised when metadata is changed
- /// </summary>
- public event EventHandler<MetadataUpdatedEventArgs> MetadataUpdated
- {
- add
- {
- if(_metadataUpdated == null)
- {
- RegisterMetadataUpdatedEvent();
- }
- _metadataUpdated += value;
-
- }
- remove
- {
- _metadataUpdated -= value;
- if(_metadataUpdated == null)
- {
- UnregisterMetadataUpdatedEvent();
- }
- }
- }
-
- /// <summary>
- /// ShuffleModeUpdated event is raised when shuffle mode is changed
- /// </summary>
- public event EventHandler<ShuffleModeUpdatedEventArgs> ShuffleModeUpdated
- {
- add
- {
- if(_shufflemodeUpdated == null)
- {
- RegisterShuffleModeUpdatedEvent();
- }
- _shufflemodeUpdated += value;
-
- }
- remove
- {
- _shufflemodeUpdated -= value;
- if(_shufflemodeUpdated == null)
- {
- UnregisterShuffleModeUpdatedEvent();
- }
- }
- }
-
- /// <summary>
- /// RepeatModeUpdated event is raised when server is changed
- /// </summary>
- public event EventHandler<RepeatModeUpdatedEventArgs> RepeatModeUpdated
- {
- add
- {
- if(_repeatmodeUpdated == null)
- {
- RegisterRepeatModeUpdatedEvent();
- }
- _repeatmodeUpdated += value;
-
- }
- remove
- {
- _repeatmodeUpdated -= value;
- if(_repeatmodeUpdated == null)
- {
- UnregisterRepeatModeUpdatedEvent();
- }
- }
- }
-
- /// <summary>
- /// CommandReply event is raised when reply for command is recieved
- /// </summary>
- public event EventHandler<CustomCommandReplyEventArgs> CustomCommandReply
- {
- add
- {
- if(_customcommandReply == null)
- {
- _customcommandReplyCallback = (string serverName, int result, IntPtr bundle, IntPtr userData) =>
- {
- SafeBundleHandle bundleHandle = new SafeBundleHandle(bundle, true);
- Applications.Bundle _bundle = new Bundle(bundleHandle);
- CustomCommandReplyEventArgs eventArgs = new CustomCommandReplyEventArgs(serverName, result, _bundle);
- _customcommandReply?.Invoke(this, eventArgs);
- };
- }
- _customcommandReply += value;
-
- }
- remove
- {
- _customcommandReply -= value;
- if(_customcommandReply == null)
- {
- _customcommandReplyCallback = null;
- }
- }
- }
-
- /// <summary>
- /// gets latest server information </summary>
- public ServerInformation GetLatestServer()
- {
- MediaControllerError res = MediaControllerError.None;
- string _name;
- int _state;
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetLatestServer(_handle, out _name, out _state);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Latest server failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Latest server failed");
- }
-
- ServerInformation _serverInfo = new ServerInformation (_name, (MediaControllerServerState)_state);
- return _serverInfo;
- }
-
- /// <summary>
- /// gets playback information for specific server </summary>
- /// <param name="serverName"> Server Name </param>
- public MediaControllerPlayback GetPlayback(String serverName)
- {
- MediaControllerError res = MediaControllerError.None;
- IntPtr _playbackHandle = IntPtr.Zero;
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetServerPlayback(_handle, serverName, out _playbackHandle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
- }
-
- MediaControllerPlayback _playback = new MediaControllerPlayback (_playbackHandle);
- return _playback;
- }
-
- /// <summary>
- /// gets metadata information for specific server </summary>
- /// <param name="serverName"> Server Name </param>
- public MediaControllerMetadata GetMetadata(String serverName)
- {
- MediaControllerError res = MediaControllerError.None;
- IntPtr _metadataHandle = IntPtr.Zero;
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetServerMetadata(_handle, serverName, out _metadataHandle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
- }
-
- MediaControllerMetadata _metadata = new MediaControllerMetadata (_metadataHandle);
- return _metadata;
- }
-
- /// <summary>
- /// gets shuffle mode for specific server </summary>
- /// <param name="serverName"> Server Name </param>
- public MediaControllerShuffleMode GetShuffleMode(String serverName)
- {
- MediaControllerError res = MediaControllerError.None;
- int _shuffleMode;
- res = (MediaControllerError)Interop.MediaControllerClient.GetServerShuffleMode(_handle, serverName, out _shuffleMode);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
- }
-
- return (MediaControllerShuffleMode)_shuffleMode;
- }
-
- /// <summary>
- /// gets repeat mode for specific server </summary>
- /// <param name="serverName"> Server Name </param>
- public MediaControllerRepeatMode GetRepeatMode(String serverName)
- {
- MediaControllerError res = MediaControllerError.None;
- int _repeatMode;
- res = (MediaControllerError)Interop.MediaControllerClient.GetServerRepeatMode(_handle, serverName, out _repeatMode);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
- }
-
- return (MediaControllerRepeatMode)_repeatMode;
- }
-
- /// <summary>
- /// Send command of playback state to server application </summary>
- /// <param name="serverName"> Server Name </param>
- /// <param name="state"> Playback State </param>
- public void SendPlaybackStateCommand(string serverName, MediaControllerPlaybackState state)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerClient.SendPlaybackStateCommand(_handle, serverName, (int)state);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Send playback state command failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Send playback state command failed");
- }
- }
-
- /// <summary>
- /// Send customized command to server application </summary>
- /// <param name="serverName"> Server Name </param>
- /// <param name="command"> Command </param>
- /// <param name="bundle"> Bundle data </param>
- /// <param name="userData"> User Data </param>
- public void SendCustomCommand(string serverName, string command, Bundle bundle)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerClient.SendCustomCommand(_handle, serverName, command, bundle.SafeBundleHandle, _customcommandReplyCallback, IntPtr.Zero);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Send custom command failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Send custom command failed");
- }
- }
-
- /// <summary>
- /// Subscribe subscription type from specific server application </summary>
- /// <param name="type"> Subscription Type </param>
- /// <param name="serverName"> Server Name </param>
- public void Subscribe(MediaControllerSubscriptionType type, string serverName)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerClient.Subscribe(_handle, (int)type, serverName);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Subscribe failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Subscribe failed");
- }
- }
-
- /// <summary>
- /// Subscribe subscription type from specific server application </summary>
- /// <param name="type"> Subscription Type </param>
- /// <param name="serverName"> Server Name </param>
- public void Unsubscribe(MediaControllerSubscriptionType type, string serverName)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerClient.Unsubscribe(_handle, (int)type, serverName);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Unsubscribe failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Unsubscribe failed");
- }
- }
-
- /// <summary>
- /// gets activated server list </summary>
- public Task<IEnumerable<string>> GetActivatedServerList()
- {
- var task = new TaskCompletionSource<IEnumerable<string>>();
-
- List<string> collectionList = ForEachActivatedServer(_handle);
- task.TrySetResult((IEnumerable<string>)collectionList);
-
- return task.Task;
- }
-
- /// <summary>
- /// gets subscribed server list </summary>
- /// <param name="subscriptionType"> Subscription Type </param>
- public Task<IEnumerable<string>> GetSubscribedServerList(MediaControllerSubscriptionType subscriptionType)
- {
- var task = new TaskCompletionSource<IEnumerable<string>>();
-
- List<string> collectionList = ForEachSubscribedServer(_handle, (int)subscriptionType);
- task.TrySetResult((IEnumerable<string>)collectionList);
-
- return task.Task;
- }
-
- private void RegisterServerUpdatedEvent()
- {
- _serverUpdatedCallback = (string serverName, int serverState, IntPtr userData) =>
- {
- ServerUpdatedEventArgs eventArgs = new ServerUpdatedEventArgs(serverName, (MediaControllerServerState)serverState);
- _serverUpdated?.Invoke(this, eventArgs);
- };
- Interop.MediaControllerClient.SetServerUpdatedCb(_handle, _serverUpdatedCallback, IntPtr.Zero);
- }
-
- private void UnregisterServerUpdatedEvent()
- {
- Interop.MediaControllerClient.UnsetServerUpdatedCb(_handle);
- }
-
- private void RegisterPlaybackUpdatedEvent()
- {
- _playbackUpdatedCallback = (string serverName, IntPtr playback, IntPtr userData) =>
- {
- PlaybackUpdatedEventArgs eventArgs = new PlaybackUpdatedEventArgs(serverName, playback);
- _playbackUpdated?.Invoke(this, eventArgs);
- };
- Interop.MediaControllerClient.SetPlaybackUpdatedCb(_handle, _playbackUpdatedCallback, IntPtr.Zero);
- }
-
- private void UnregisterPlaybackUpdatedEvent()
- {
- Interop.MediaControllerClient.UnsetPlaybackUpdatedCb(_handle);
- }
-
- private void RegisterMetadataUpdatedEvent()
- {
- _metadataUpdatedCallback = (string serverName, IntPtr metadata, IntPtr userData) =>
- {
- MetadataUpdatedEventArgs eventArgs = new MetadataUpdatedEventArgs(serverName, metadata);
- _metadataUpdated?.Invoke(this, eventArgs);
- };
- Interop.MediaControllerClient.SetMetadataUpdatedCb(_handle, _metadataUpdatedCallback, IntPtr.Zero);
- }
-
- private void UnregisterMetadataUpdatedEvent()
- {
- Interop.MediaControllerClient.UnsetMetadataUpdatedCb(_handle);
- }
-
- private void RegisterShuffleModeUpdatedEvent()
- {
- MediaControllerError res = MediaControllerError.None;
- _shufflemodeUpdatedCallback = (string serverName, int shuffleMode, IntPtr userData) =>
- {
- ShuffleModeUpdatedEventArgs eventArgs = new ShuffleModeUpdatedEventArgs(serverName, (MediaControllerShuffleMode)shuffleMode);
- _shufflemodeUpdated?.Invoke(this, eventArgs);
- };
- res = (MediaControllerError)Interop.MediaControllerClient.SetShuffleModeUpdatedCb(_handle, _shufflemodeUpdatedCallback, IntPtr.Zero);
- if (res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set ShuffleModeUpdated callback failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set ShuffleModeUpdated callback failed");
- }
- }
-
- private void UnregisterShuffleModeUpdatedEvent()
- {
- Interop.MediaControllerClient.UnsetShuffleModeUpdatedCb(_handle);
- }
-
- private void RegisterRepeatModeUpdatedEvent()
- {
- MediaControllerError res = MediaControllerError.None;
- _repeatmodeUpdatedCallback = (string serverName, int repeatMode, IntPtr userData) =>
- {
- RepeatModeUpdatedEventArgs eventArgs = new RepeatModeUpdatedEventArgs(serverName, (MediaControllerRepeatMode)repeatMode);
- _repeatmodeUpdated?.Invoke(this, eventArgs);
- };
- res = (MediaControllerError)Interop.MediaControllerClient.SetRepeatModeUpdatedCb(_handle, _repeatmodeUpdatedCallback, IntPtr.Zero);
- if (res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set RepeatModeUpdated callback failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set RepeatModeUpdated callback failed");
- }
- }
-
- private void UnregisterRepeatModeUpdatedEvent()
- {
- Interop.MediaControllerClient.UnsetRepeatModeUpdatedCb(_handle);
- }
-
- private static List<string> ForEachSubscribedServer(IntPtr handle, int subscriptionType)
- {
- MediaControllerError res = MediaControllerError.None;
- List<string> subscribedServerCollections = new List<string>();
-
- Interop.MediaControllerClient.SubscribedServerCallback serverCallback = (string serverName, IntPtr userData) =>
- {
- subscribedServerCollections.Add (serverName);
- return true;
- };
- res = (MediaControllerError)Interop.MediaControllerClient.ForeachSubscribedServer (handle, subscriptionType, serverCallback, IntPtr.Zero);
- if (res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Foreach Subscribed server failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Foreach Subscribed server failed");
- }
- return subscribedServerCollections;
- }
-
- private static List<string> ForEachActivatedServer(IntPtr handle)
- {
- MediaControllerError res = MediaControllerError.None;
- List<string> activatedServerCollections = new List<string>();
-
- Interop.MediaControllerClient.ActivatedServerCallback serverCallback = (string serverName, IntPtr userData) =>
- {
- activatedServerCollections.Add (serverName);
- return true;
- };
- res = (MediaControllerError)Interop.MediaControllerClient.ForeachActivatedServer (handle, serverCallback, IntPtr.Zero);
- if (res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Foreach Activated server failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Foreach Activated server failed");
- }
- return activatedServerCollections;
- }
-
-
- }
+ /// <summary>
+ /// The MediaControllerClient class provides APIs required for media-controller-client.
+ /// </summary>
+ /// <remarks>
+ /// The MediaControllerClient APIs provides functions to get media information from server.
+ /// </remarks>
+ public class MediaControllerClient : IDisposable
+ {
+ internal IntPtr _handle = IntPtr.Zero;
+
+ private bool _disposed = false;
+ private EventHandler<ServerUpdatedEventArgs> _serverUpdated;
+ private Interop.MediaControllerClient.ServerUpdatedCallback _serverUpdatedCallback;
+ private EventHandler<PlaybackUpdatedEventArgs> _playbackUpdated;
+ private Interop.MediaControllerClient.PlaybackUpdatedCallback _playbackUpdatedCallback;
+ private EventHandler<MetadataUpdatedEventArgs> _metadataUpdated;
+ private Interop.MediaControllerClient.MetadataUpdatedCallback _metadataUpdatedCallback;
+ private EventHandler<ShuffleModeUpdatedEventArgs> _shufflemodeUpdated;
+ private Interop.MediaControllerClient.ShuffleModeUpdatedCallback _shufflemodeUpdatedCallback;
+ private EventHandler<RepeatModeUpdatedEventArgs> _repeatmodeUpdated;
+ private Interop.MediaControllerClient.RepeatModeUpdatedCallback _repeatmodeUpdatedCallback;
+ private EventHandler<CustomCommandReplyEventArgs> _customcommandReply;
+ private Interop.MediaControllerClient.CommandReplyRecievedCallback _customcommandReplyCallback;
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public MediaControllerClient ()
+ {
+ Interop.MediaControllerClient.Create (out _handle);
+ }
+
+ ~MediaControllerClient ()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if(!_disposed)
+ {
+ if(disposing)
+ {
+ // To be used if there are any other disposable objects
+ }
+ if(_handle != IntPtr.Zero)
+ {
+ Interop.MediaControllerClient.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// ServerUpdated event is raised when server is changed
+ /// </summary>
+ public event EventHandler<ServerUpdatedEventArgs> ServerUpdated
+ {
+ add
+ {
+ if(_serverUpdated == null)
+ {
+ RegisterServerUpdatedEvent();
+ }
+ _serverUpdated += value;
+
+ }
+ remove
+ {
+ _serverUpdated -= value;
+ if(_serverUpdated == null)
+ {
+ UnregisterServerUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// PlaybackUpdated event is raised when playback is changed
+ /// </summary>
+ public event EventHandler<PlaybackUpdatedEventArgs> PlaybackUpdated
+ {
+ add
+ {
+ if(_playbackUpdated == null)
+ {
+ RegisterPlaybackUpdatedEvent();
+ }
+ _playbackUpdated += value;
+
+ }
+ remove
+ {
+ _playbackUpdated -= value;
+ if(_playbackUpdated == null)
+ {
+ UnregisterPlaybackUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// MetadataUpdated event is raised when metadata is changed
+ /// </summary>
+ public event EventHandler<MetadataUpdatedEventArgs> MetadataUpdated
+ {
+ add
+ {
+ if(_metadataUpdated == null)
+ {
+ RegisterMetadataUpdatedEvent();
+ }
+ _metadataUpdated += value;
+
+ }
+ remove
+ {
+ _metadataUpdated -= value;
+ if(_metadataUpdated == null)
+ {
+ UnregisterMetadataUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// ShuffleModeUpdated event is raised when shuffle mode is changed
+ /// </summary>
+ public event EventHandler<ShuffleModeUpdatedEventArgs> ShuffleModeUpdated
+ {
+ add
+ {
+ if(_shufflemodeUpdated == null)
+ {
+ RegisterShuffleModeUpdatedEvent();
+ }
+ _shufflemodeUpdated += value;
+
+ }
+ remove
+ {
+ _shufflemodeUpdated -= value;
+ if(_shufflemodeUpdated == null)
+ {
+ UnregisterShuffleModeUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// RepeatModeUpdated event is raised when server is changed
+ /// </summary>
+ public event EventHandler<RepeatModeUpdatedEventArgs> RepeatModeUpdated
+ {
+ add
+ {
+ if(_repeatmodeUpdated == null)
+ {
+ RegisterRepeatModeUpdatedEvent();
+ }
+ _repeatmodeUpdated += value;
+
+ }
+ remove
+ {
+ _repeatmodeUpdated -= value;
+ if(_repeatmodeUpdated == null)
+ {
+ UnregisterRepeatModeUpdatedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// CommandReply event is raised when reply for command is recieved
+ /// </summary>
+ public event EventHandler<CustomCommandReplyEventArgs> CustomCommandReply
+ {
+ add
+ {
+ if(_customcommandReply == null)
+ {
+ _customcommandReplyCallback = (string serverName, int result, IntPtr bundle, IntPtr userData) =>
+ {
+ SafeBundleHandle bundleHandle = new SafeBundleHandle(bundle, true);
+ Applications.Bundle _bundle = new Bundle(bundleHandle);
+ CustomCommandReplyEventArgs eventArgs = new CustomCommandReplyEventArgs(serverName, result, _bundle);
+ _customcommandReply?.Invoke(this, eventArgs);
+ };
+ }
+ _customcommandReply += value;
+
+ }
+ remove
+ {
+ _customcommandReply -= value;
+ if(_customcommandReply == null)
+ {
+ _customcommandReplyCallback = null;
+ }
+ }
+ }
+
+ /// <summary>
+ /// gets latest server information </summary>
+ public ServerInformation GetLatestServer()
+ {
+ MediaControllerError res = MediaControllerError.None;
+ string _name;
+ int _state;
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetLatestServer(_handle, out _name, out _state);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Latest server failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Latest server failed");
+ }
+
+ ServerInformation _serverInfo = new ServerInformation (_name, (MediaControllerServerState)_state);
+ return _serverInfo;
+ }
+
+ /// <summary>
+ /// gets playback information for specific server </summary>
+ /// <param name="serverName"> Server Name </param>
+ public MediaControllerPlayback GetPlayback(String serverName)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ IntPtr _playbackHandle = IntPtr.Zero;
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetServerPlayback(_handle, serverName, out _playbackHandle);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
+ }
+
+ MediaControllerPlayback _playback = new MediaControllerPlayback (_playbackHandle);
+ return _playback;
+ }
+
+ /// <summary>
+ /// gets metadata information for specific server </summary>
+ /// <param name="serverName"> Server Name </param>
+ public MediaControllerMetadata GetMetadata(String serverName)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ IntPtr _metadataHandle = IntPtr.Zero;
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetServerMetadata(_handle, serverName, out _metadataHandle);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
+ }
+
+ MediaControllerMetadata _metadata = new MediaControllerMetadata (_metadataHandle);
+ return _metadata;
+ }
+
+ /// <summary>
+ /// gets shuffle mode for specific server </summary>
+ /// <param name="serverName"> Server Name </param>
+ public MediaControllerShuffleMode GetShuffleMode(String serverName)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ int _shuffleMode;
+ res = (MediaControllerError)Interop.MediaControllerClient.GetServerShuffleMode(_handle, serverName, out _shuffleMode);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
+ }
+
+ return (MediaControllerShuffleMode)_shuffleMode;
+ }
+
+ /// <summary>
+ /// gets repeat mode for specific server </summary>
+ /// <param name="serverName"> Server Name </param>
+ public MediaControllerRepeatMode GetRepeatMode(String serverName)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ int _repeatMode;
+ res = (MediaControllerError)Interop.MediaControllerClient.GetServerRepeatMode(_handle, serverName, out _repeatMode);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Playback handle failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Playback handle failed");
+ }
+
+ return (MediaControllerRepeatMode)_repeatMode;
+ }
+
+ /// <summary>
+ /// Send command of playback state to server application </summary>
+ /// <param name="serverName"> Server Name </param>
+ /// <param name="state"> Playback State </param>
+ public void SendPlaybackStateCommand(string serverName, MediaControllerPlaybackState state)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerClient.SendPlaybackStateCommand(_handle, serverName, (int)state);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Send playback state command failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Send playback state command failed");
+ }
+ }
+
+ /// <summary>
+ /// Send customized command to server application </summary>
+ /// <param name="serverName"> Server Name </param>
+ /// <param name="command"> Command </param>
+ /// <param name="bundle"> Bundle data </param>
+ public void SendCustomCommand(string serverName, string command, Bundle bundle)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerClient.SendCustomCommand(_handle, serverName, command, bundle.SafeBundleHandle, _customcommandReplyCallback, IntPtr.Zero);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Send custom command failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Send custom command failed");
+ }
+ }
+
+ /// <summary>
+ /// Subscribe subscription type from specific server application </summary>
+ /// <param name="type"> Subscription Type </param>
+ /// <param name="serverName"> Server Name </param>
+ public void Subscribe(MediaControllerSubscriptionType type, string serverName)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerClient.Subscribe(_handle, (int)type, serverName);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Subscribe failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Subscribe failed");
+ }
+ }
+
+ /// <summary>
+ /// Subscribe subscription type from specific server application </summary>
+ /// <param name="type"> Subscription Type </param>
+ /// <param name="serverName"> Server Name </param>
+ public void Unsubscribe(MediaControllerSubscriptionType type, string serverName)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerClient.Unsubscribe(_handle, (int)type, serverName);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Unsubscribe failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Unsubscribe failed");
+ }
+ }
+
+ /// <summary>
+ /// gets activated server list </summary>
+ public Task<IEnumerable<string>> GetActivatedServerList()
+ {
+ var task = new TaskCompletionSource<IEnumerable<string>>();
+
+ List<string> collectionList = ForEachActivatedServer(_handle);
+ task.TrySetResult((IEnumerable<string>)collectionList);
+
+ return task.Task;
+ }
+
+ /// <summary>
+ /// gets subscribed server list </summary>
+ /// <param name="subscriptionType"> Subscription Type </param>
+ public Task<IEnumerable<string>> GetSubscribedServerList(MediaControllerSubscriptionType subscriptionType)
+ {
+ var task = new TaskCompletionSource<IEnumerable<string>>();
+
+ List<string> collectionList = ForEachSubscribedServer(_handle, (int)subscriptionType);
+ task.TrySetResult((IEnumerable<string>)collectionList);
+
+ return task.Task;
+ }
+
+ private void RegisterServerUpdatedEvent()
+ {
+ _serverUpdatedCallback = (string serverName, int serverState, IntPtr userData) =>
+ {
+ ServerUpdatedEventArgs eventArgs = new ServerUpdatedEventArgs(serverName, (MediaControllerServerState)serverState);
+ _serverUpdated?.Invoke(this, eventArgs);
+ };
+ Interop.MediaControllerClient.SetServerUpdatedCb(_handle, _serverUpdatedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterServerUpdatedEvent()
+ {
+ Interop.MediaControllerClient.UnsetServerUpdatedCb(_handle);
+ }
+
+ private void RegisterPlaybackUpdatedEvent()
+ {
+ _playbackUpdatedCallback = (string serverName, IntPtr playback, IntPtr userData) =>
+ {
+ PlaybackUpdatedEventArgs eventArgs = new PlaybackUpdatedEventArgs(serverName, playback);
+ _playbackUpdated?.Invoke(this, eventArgs);
+ };
+ Interop.MediaControllerClient.SetPlaybackUpdatedCb(_handle, _playbackUpdatedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterPlaybackUpdatedEvent()
+ {
+ Interop.MediaControllerClient.UnsetPlaybackUpdatedCb(_handle);
+ }
+
+ private void RegisterMetadataUpdatedEvent()
+ {
+ _metadataUpdatedCallback = (string serverName, IntPtr metadata, IntPtr userData) =>
+ {
+ MetadataUpdatedEventArgs eventArgs = new MetadataUpdatedEventArgs(serverName, metadata);
+ _metadataUpdated?.Invoke(this, eventArgs);
+ };
+ Interop.MediaControllerClient.SetMetadataUpdatedCb(_handle, _metadataUpdatedCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterMetadataUpdatedEvent()
+ {
+ Interop.MediaControllerClient.UnsetMetadataUpdatedCb(_handle);
+ }
+
+ private void RegisterShuffleModeUpdatedEvent()
+ {
+ MediaControllerError res = MediaControllerError.None;
+ _shufflemodeUpdatedCallback = (string serverName, int shuffleMode, IntPtr userData) =>
+ {
+ ShuffleModeUpdatedEventArgs eventArgs = new ShuffleModeUpdatedEventArgs(serverName, (MediaControllerShuffleMode)shuffleMode);
+ _shufflemodeUpdated?.Invoke(this, eventArgs);
+ };
+ res = (MediaControllerError)Interop.MediaControllerClient.SetShuffleModeUpdatedCb(_handle, _shufflemodeUpdatedCallback, IntPtr.Zero);
+ if (res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set ShuffleModeUpdated callback failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set ShuffleModeUpdated callback failed");
+ }
+ }
+
+ private void UnregisterShuffleModeUpdatedEvent()
+ {
+ Interop.MediaControllerClient.UnsetShuffleModeUpdatedCb(_handle);
+ }
+
+ private void RegisterRepeatModeUpdatedEvent()
+ {
+ MediaControllerError res = MediaControllerError.None;
+ _repeatmodeUpdatedCallback = (string serverName, int repeatMode, IntPtr userData) =>
+ {
+ RepeatModeUpdatedEventArgs eventArgs = new RepeatModeUpdatedEventArgs(serverName, (MediaControllerRepeatMode)repeatMode);
+ _repeatmodeUpdated?.Invoke(this, eventArgs);
+ };
+ res = (MediaControllerError)Interop.MediaControllerClient.SetRepeatModeUpdatedCb(_handle, _repeatmodeUpdatedCallback, IntPtr.Zero);
+ if (res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set RepeatModeUpdated callback failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set RepeatModeUpdated callback failed");
+ }
+ }
+
+ private void UnregisterRepeatModeUpdatedEvent()
+ {
+ Interop.MediaControllerClient.UnsetRepeatModeUpdatedCb(_handle);
+ }
+
+ private static List<string> ForEachSubscribedServer(IntPtr handle, int subscriptionType)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ List<string> subscribedServerCollections = new List<string>();
+
+ Interop.MediaControllerClient.SubscribedServerCallback serverCallback = (string serverName, IntPtr userData) =>
+ {
+ subscribedServerCollections.Add (serverName);
+ return true;
+ };
+ res = (MediaControllerError)Interop.MediaControllerClient.ForeachSubscribedServer (handle, subscriptionType, serverCallback, IntPtr.Zero);
+ if (res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Foreach Subscribed server failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Foreach Subscribed server failed");
+ }
+ return subscribedServerCollections;
+ }
+
+ private static List<string> ForEachActivatedServer(IntPtr handle)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ List<string> activatedServerCollections = new List<string>();
+
+ Interop.MediaControllerClient.ActivatedServerCallback serverCallback = (string serverName, IntPtr userData) =>
+ {
+ activatedServerCollections.Add (serverName);
+ return true;
+ };
+ res = (MediaControllerError)Interop.MediaControllerClient.ForeachActivatedServer (handle, serverCallback, IntPtr.Zero);
+ if (res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Foreach Activated server failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Foreach Activated server failed");
+ }
+ return activatedServerCollections;
+ }
+
+
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// Enumeration for server state
- /// </summary>
- public enum MediaControllerServerState
- {
- /// <summary>
- /// Server state is unknown
- /// </summary>
- None,
-
- /// <summary>
- /// Server is activated
- /// </summary>
- Activated,
-
- /// <summary>
- /// Server is deactivated
- /// </summary>
- Deactivated,
- }
-
- /// <summary>
- /// Enumeration for playback state
- /// </summary>
- public enum MediaControllerPlaybackState
- {
- /// <summary>
- /// Playback state is unknown
- /// </summary>
- None,
-
- /// <summary>
- /// Playback is playing
- /// </summary>
- Play,
-
- /// <summary>
- /// Playback is paused
- /// </summary>
- Pause,
-
- /// <summary>
- /// Playback is next
- /// </summary>
- Next,
-
- /// <summary>
- /// Playback is prev
- /// </summary>
- Prev,
-
- /// <summary>
- /// Playback is fastforward
- /// </summary>
- FastForward,
-
- /// <summary>
- /// Playback is rewind
- /// </summary>
- Rewind,
- }
-
- /// <summary>
- /// Enumeration for shuffle mode
- /// </summary>
- public enum MediaControllerShuffleMode
- {
- /// <summary>
- /// Shuffle mode is On
- /// </summary>
- On,
-
- /// <summary>
- /// Shuffle mode is Off
- /// </summary>
- Off,
- }
-
- /// <summary>
- /// Enumeration for repeat mode
- /// </summary>
- public enum MediaControllerRepeatMode
- {
- /// <summary>
- /// Repeat mode is On
- /// </summary>
- On,
-
- /// <summary>
- /// Repeat mode is Off
- /// </summary>
- Off,
- }
-
- /// <summary>
- /// Enumeration for repeat mode
- /// </summary>
- public enum MediaControllerSubscriptionType
- {
- /// <summary>
- /// Repeat mode is Off
- /// </summary>
- ServerState,
-
- /// <summary>
- /// Repeat mode is Off
- /// </summary>
- Playback,
-
- /// <summary>
- /// Repeat mode is Off
- /// </summary>
- Metadata,
-
- /// <summary>
- /// Repeat mode is Off
- /// </summary>
- ShuffleMode,
-
- /// <summary>
- /// Repeat mode is Off
- /// </summary>
- RepeatMode,
- }
-
- /// <summary>
- /// Enumeration for metadata attributes
- /// </summary>
- internal enum MediaControllerAttributes
- {
- /// <summary>
- /// Attribute is title
- /// </summary>
- Title,
-
- /// <summary>
- /// Attribute is artist
- /// </summary>
- Artist,
-
- /// <summary>
- /// Attribute is album
- /// </summary>
- Album,
-
- /// <summary>
- /// Attribute is author
- /// </summary>
- Author,
-
- /// <summary>
- /// Attribute is genre
- /// </summary>
- Genre,
-
- /// <summary>
- /// Attribute is duration
- /// </summary>
- Duration,
-
- /// <summary>
- /// Attribute is date
- /// </summary>
- Date,
-
- /// <summary>
- /// Attribute is copyright
- /// </summary>
- Copyright,
-
- /// <summary>
- /// Attribute is description
- /// </summary>
- Description,
-
- /// <summary>
- /// Attribute is track number
- /// </summary>
- TrackNumber,
-
- /// <summary>
- /// Attribute is picture
- /// </summary>
- Picture,
- }
+ /// <summary>
+ /// Enumeration for server state
+ /// </summary>
+ public enum MediaControllerServerState
+ {
+ /// <summary>
+ /// Server state is unknown
+ /// </summary>
+ None,
+
+ /// <summary>
+ /// Server is activated
+ /// </summary>
+ Activated,
+
+ /// <summary>
+ /// Server is deactivated
+ /// </summary>
+ Deactivated,
+ }
+
+ /// <summary>
+ /// Enumeration for playback state
+ /// </summary>
+ public enum MediaControllerPlaybackState
+ {
+ /// <summary>
+ /// Playback state is unknown
+ /// </summary>
+ None,
+
+ /// <summary>
+ /// Playback is playing
+ /// </summary>
+ Play,
+
+ /// <summary>
+ /// Playback is paused
+ /// </summary>
+ Pause,
+
+ /// <summary>
+ /// Playback is next
+ /// </summary>
+ Next,
+
+ /// <summary>
+ /// Playback is prev
+ /// </summary>
+ Prev,
+
+ /// <summary>
+ /// Playback is fastforward
+ /// </summary>
+ FastForward,
+
+ /// <summary>
+ /// Playback is rewind
+ /// </summary>
+ Rewind,
+ }
+
+ /// <summary>
+ /// Enumeration for shuffle mode
+ /// </summary>
+ public enum MediaControllerShuffleMode
+ {
+ /// <summary>
+ /// Shuffle mode is On
+ /// </summary>
+ On,
+
+ /// <summary>
+ /// Shuffle mode is Off
+ /// </summary>
+ Off,
+ }
+
+ /// <summary>
+ /// Enumeration for repeat mode
+ /// </summary>
+ public enum MediaControllerRepeatMode
+ {
+ /// <summary>
+ /// Repeat mode is On
+ /// </summary>
+ On,
+
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ Off,
+ }
+
+ /// <summary>
+ /// Enumeration for repeat mode
+ /// </summary>
+ public enum MediaControllerSubscriptionType
+ {
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ ServerState,
+
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ Playback,
+
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ Metadata,
+
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ ShuffleMode,
+
+ /// <summary>
+ /// Repeat mode is Off
+ /// </summary>
+ RepeatMode,
+ }
+
+ /// <summary>
+ /// Enumeration for metadata attributes
+ /// </summary>
+ internal enum MediaControllerAttributes
+ {
+ /// <summary>
+ /// Attribute is title
+ /// </summary>
+ Title,
+
+ /// <summary>
+ /// Attribute is artist
+ /// </summary>
+ Artist,
+
+ /// <summary>
+ /// Attribute is album
+ /// </summary>
+ Album,
+
+ /// <summary>
+ /// Attribute is author
+ /// </summary>
+ Author,
+
+ /// <summary>
+ /// Attribute is genre
+ /// </summary>
+ Genre,
+
+ /// <summary>
+ /// Attribute is duration
+ /// </summary>
+ Duration,
+
+ /// <summary>
+ /// Attribute is date
+ /// </summary>
+ Date,
+
+ /// <summary>
+ /// Attribute is copyright
+ /// </summary>
+ Copyright,
+
+ /// <summary>
+ /// Attribute is description
+ /// </summary>
+ Description,
+
+ /// <summary>
+ /// Attribute is track number
+ /// </summary>
+ TrackNumber,
+
+ /// <summary>
+ /// Attribute is picture
+ /// </summary>
+ Picture,
+ }
}
namespace Tizen.Multimedia.MediaController
{
- internal enum MediaControllerError
- {
- None = ErrorCode.None,
- InvalidParameter = ErrorCode.InvalidParameter,
- OutOfMemory = ErrorCode.OutOfMemory,
- InvalidOperation = ErrorCode.InvalidOperation,
- NoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice,
- PermissionDenied = ErrorCode.PermissionDenied,
- };
- internal static class MediaControllerErrorFactory
- {
- internal static void ThrowException(MediaControllerError errorCode, string errorMessage = null, string paramName = null)
- {
- MediaControllerError err = errorCode;
- if(string.IsNullOrEmpty(errorMessage))
- {
- errorMessage = err.ToString();
- }
- switch(errorCode)
- {
- case MediaControllerError.InvalidParameter:
- throw new ArgumentException(errorMessage, paramName);
+ internal enum MediaControllerError
+ {
+ None = ErrorCode.None,
+ InvalidParameter = ErrorCode.InvalidParameter,
+ OutOfMemory = ErrorCode.OutOfMemory,
+ InvalidOperation = ErrorCode.InvalidOperation,
+ NoSpaceOnDevice = ErrorCode.FileNoSpaceOnDevice,
+ PermissionDenied = ErrorCode.PermissionDenied,
+ };
+ internal static class MediaControllerErrorFactory
+ {
+ internal static void ThrowException(MediaControllerError errorCode, string errorMessage = null, string paramName = null)
+ {
+ MediaControllerError err = errorCode;
+ if(string.IsNullOrEmpty(errorMessage))
+ {
+ errorMessage = err.ToString();
+ }
+ switch(errorCode)
+ {
+ case MediaControllerError.InvalidParameter:
+ throw new ArgumentException(errorMessage, paramName);
- case MediaControllerError.OutOfMemory:
- case MediaControllerError.InvalidOperation:
- case MediaControllerError.NoSpaceOnDevice:
- case MediaControllerError.PermissionDenied:
- throw new InvalidOperationException(errorMessage);
- }
- }
- }
+ case MediaControllerError.OutOfMemory:
+ case MediaControllerError.InvalidOperation:
+ case MediaControllerError.NoSpaceOnDevice:
+ case MediaControllerError.PermissionDenied:
+ throw new InvalidOperationException(errorMessage);
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- static internal class MediaControllerLog
- {
- internal const string LogTag = "Tizen.Multimedia.MediaController";
- }
+ static internal class MediaControllerLog
+ {
+ internal const string LogTag = "Tizen.Multimedia.MediaController";
+ }
}
\ No newline at end of file
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* limitations under the License.
*/
-
-
using System;
using System.Collections.Generic;
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// Metadata represents a metadata of media for server application to play
- /// </summary>
- public class MediaControllerMetadata
- {
- /// <summary>
- /// The title of media
- /// </summary>
- public string Title;
-
- /// <summary>
- /// The artist of media
- /// </summary>
- public string Artist;
-
- /// <summary>
- /// The album of media
- /// </summary>
- public string Album;
-
- /// <summary>
- /// The author of media
- /// </summary>
- public string Author;
-
- /// <summary>
- /// The genre of media
- /// </summary>
- public string Genre;
-
- /// <summary>
- /// The duration of media
- /// </summary>
- public string Duration;
-
- /// <summary>
- /// The date of media
- /// </summary>
- public string Date;
-
- /// <summary>
- /// The copyright of media
- /// </summary>
- public string Copyright;
-
- /// <summary>
- /// The description of media
- /// </summary>
- public string Description;
-
- /// <summary>
- /// The track number of media
- /// </summary>
- public string TrackNumber;
-
- /// <summary>
- /// The picture of media
- /// </summary>
- public string Picture;
+ /// <summary>
+ /// Metadata represents a metadata of media for server application to play
+ /// </summary>
+ public class MediaControllerMetadata
+ {
+ private string _title;
+ private string _artist;
+ private string _album;
+ private string _author;
+ private string _genre;
+ private string _duration;
+ private string _date;
+ private string _copyright;
+ private string _description;
+ private string _track_number;
+ private string _picture;
+ /// <summary>
+ /// Constructor
+ /// </summary>
public MediaControllerMetadata()
{
-
+ _title = null;
+ _artist = null;
+ _album = null;
+ _author = null;
+ _genre = null;
+ _duration = null;
+ _date = null;
+ _copyright = null;
+ _description = null;
+ _track_number = null;
+ _picture = null;
}
internal MediaControllerMetadata(IntPtr _metadataHandle) {
- MediaControllerError res = MediaControllerError.None;
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Title, out Title);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Artist, out Artist);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Album, out Album);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Author, out Author);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Genre, out Genre);
+ MediaControllerError res = MediaControllerError.None;
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Title, out _title);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Artist, out _artist);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Album, out _album);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Author, out _author);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Genre, out _genre);
if (res != MediaControllerError.None)
{
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Duration, out Duration);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Date, out Date);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Copyright, out Copyright);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Description, out Description);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.TrackNumber, out TrackNumber);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Picture, out Picture);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
- }
- }
- }
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Duration, out _duration);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Date, out _date);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Copyright, out _copyright);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Description, out _description);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.TrackNumber, out _track_number);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerClient.GetMetadata(_metadataHandle, (int)MediaControllerAttributes.Picture, out _picture);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Metadata failed");
+ }
+ }
+
+ /// <summary>
+ /// The title of media
+ /// </summary>
+ public string Title
+ {
+ get
+ {
+ return _title;
+ }
+ set {
+ _title = value;
+ }
+ }
+
+ /// <summary>
+ /// The artist of media
+ /// </summary>
+ public string Artist
+ {
+ get
+ {
+ return _artist;
+ }
+ set
+ {
+ _artist = value;
+ }
+ }
+
+ /// <summary>
+ /// The album of media
+ /// </summary>
+ public string Album
+ {
+ get
+ {
+ return _album;
+ }
+ set
+ {
+ _album = value;
+ }
+ }
+
+ /// <summary>
+ /// The author of media
+ /// </summary>
+ public string Author
+ {
+ get
+ {
+ return _author;
+ }
+ set
+ {
+ _author = value;
+ }
+ }
+
+ /// <summary>
+ /// The genre of media
+ /// </summary>
+ public string Genre
+ {
+ get
+ {
+ return _genre;
+ }
+ set
+ {
+ _genre = value;
+ }
+ }
+
+ /// <summary>
+ /// The duration of media
+ /// </summary>
+ public string Duration
+ {
+ get
+ {
+ return _duration;
+ }
+ set
+ {
+ _duration = value;
+ }
+ }
+
+ /// <summary>
+ /// The date of media
+ /// </summary>
+ public string Date
+ {
+ get
+ {
+ return _date;
+ }
+ set
+ {
+ _date = value;
+ }
+ }
+
+ /// <summary>
+ /// The copyright of media
+ /// </summary>
+ public string Copyright
+ {
+ get
+ {
+ return _copyright;
+ }
+ set
+ {
+ _copyright = value;
+ }
+ }
+
+ /// <summary>
+ /// The description of media
+ /// </summary>
+ public string Description
+ {
+ get
+ {
+ return _description;
+ }
+ set
+ {
+ _description = value;
+ }
+ }
+
+ /// <summary>
+ /// The track number of media
+ /// </summary>
+ public string TrackNumber
+ {
+ get
+ {
+ return _track_number;
+ }
+ set
+ {
+ _track_number = value;
+ }
+ }
+
+ /// <summary>
+ /// The picture of media
+ /// </summary>
+ public string Picture
+ {
+ get
+ {
+ return _picture;
+ }
+ set
+ {
+ _picture = value;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
/// <summary>
- /// Playback represents a playback state and playback position.
- /// </summary>
- public class MediaControllerPlayback
- {
- public MediaControllerPlayback(MediaControllerPlaybackState state, ulong position) {
- State = state;
- Position = position;
- }
+ /// Playback represents a playback state and playback position.
+ /// </summary>
+ public class MediaControllerPlayback
+ {
+ private MediaControllerPlaybackState _state;
+ private ulong _position;
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public MediaControllerPlayback(MediaControllerPlaybackState state, ulong position) {
+ _state = state;
+ _position = position;
+ }
- internal MediaControllerPlayback(IntPtr _playbackHandle) {
- MediaControllerError res = MediaControllerError.None;
- int _state = 0;
- ulong _position = 0L;
+ internal MediaControllerPlayback(IntPtr _playbackHandle) {
+ MediaControllerError res = MediaControllerError.None;
+ int state = 0;
+ ulong position = 0L;
- res = (MediaControllerError)Interop.MediaControllerClient.GetPlaybackState(_playbackHandle, out _state);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Playback state failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Playback state failed");
- }
+ res = (MediaControllerError)Interop.MediaControllerClient.GetPlaybackState(_playbackHandle, out state);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Playback state failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Playback state failed");
+ }
- res = (MediaControllerError)Interop.MediaControllerClient.GetPlaybackPosition(_playbackHandle, out _position);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Get Playback position failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Get Playback position failed");
- }
+ res = (MediaControllerError)Interop.MediaControllerClient.GetPlaybackPosition(_playbackHandle, out position);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Get Playback position failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Get Playback position failed");
+ }
- State = (MediaControllerPlaybackState)_state;
- Position = _position;
- }
+ _state = (MediaControllerPlaybackState)state;
+ _position = position;
+ }
/// <summary>
/// The state of playback of media application
/// </summary>
- public MediaControllerPlaybackState State;
+ public MediaControllerPlaybackState State
+ {
+ get
+ {
+ return _state;
+ }
+ }
- /// <summary>
- /// The position of playback of media application
- /// </summary>
- public ulong Position;
- }
+ /// <summary>
+ /// The position of playback of media application
+ /// </summary>
+ public ulong Position
+ {
+ get
+ {
+ return _position;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// The MediaControllerServer class provides APIs required for media-controller-server.
- /// </summary>
- /// <remarks>
- /// The MediaControllerServer APIs provides functions to
- /// </remarks>
- public class MediaControllerServer : IDisposable
- {
- internal IntPtr _handle = IntPtr.Zero;
-
- private bool _disposed = false;
- private EventHandler<PlaybackStateCommandEventArgs> _playbackCommand;
- private Interop.MediaControllerServer.PlaybackStateCommandRecievedCallback _playbackCommandCallback;
- private EventHandler<CustomCommandEventArgs> _customCommand;
- private Interop.MediaControllerServer.CustomCommandRecievedCallback _customCommandCallback;
-
- public MediaControllerServer ()
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.Create (out _handle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Create server failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Create server failed");
- }
- }
-
- ~MediaControllerServer ()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if(!_disposed)
- {
- if(disposing)
- {
- // To be used if there are any other disposable objects
- }
- if(_handle != IntPtr.Zero)
- {
- Interop.MediaControllerServer.Destroy(_handle);
- _handle = IntPtr.Zero;
- }
- _disposed = true;
- }
- }
-
- /// <summary>
- /// PlaybackStateCommandRecieved event is raised when client send command for playback
- /// </summary>
- public event EventHandler<PlaybackStateCommandEventArgs> PlaybackStateCommand
- {
- add
- {
- if(_playbackCommand == null)
- {
- RegisterPlaybackCmdRecvEvent();
- }
- _playbackCommand += value;
-
- }
- remove
- {
- _playbackCommand -= value;
- if(_playbackCommand == null)
- {
- UnregisterPlaybackCmdRecvEvent();
- }
- }
- }
-
- /// <summary>
- /// CustomCommandRecieved event is raised when client send customized command
- /// </summary>
- public event EventHandler<CustomCommandEventArgs> CustomCommand
- {
- add
- {
- if(_customCommand == null)
- {
- RegisterCustomCommandEvent();
- }
- _customCommand += value;
-
- }
- remove
- {
- _customCommand -= value;
- if(_customCommand == null)
- {
- UnregisterCustomCommandEvent();
- }
- }
- }
-
- /// <summary>
- /// Update playback state and playback position</summary>
- /// <param name="playback"> playback state and playback position </param>
- public void UpdatePlayback(MediaControllerPlayback playback)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.SetPlaybackState(_handle, (int)playback.State);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Playback state failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Playback state failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetPlaybackPosition(_handle, playback.Position);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Playback position failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Playback position failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.UpdatePlayback(_handle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Update Playback failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Update Playback failed");
- }
- }
-
- /// <summary>
- /// Update metadata information </summary>
- /// <param name="metadata"> metadata information </param>
- public void UpdateMetadata(MediaControllerMetadata metadata)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Title, metadata.Title);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Artist, metadata.Artist);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Album, metadata.Album);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Author, metadata.Author);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }\r
-\r
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Genre, metadata.Genre);\r
- if (res != MediaControllerError.None)\r
- {\r
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);\r
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");\r
- }\r
-\r
+ /// <summary>
+ /// The MediaControllerServer class provides APIs required for media-controller-server.
+ /// </summary>
+ /// <remarks>
+ /// The MediaControllerServer APIs provides functions to update media information.
+ /// </remarks>
+ public class MediaControllerServer : IDisposable
+ {
+ internal IntPtr _handle = IntPtr.Zero;
+
+ private bool _disposed = false;
+ private EventHandler<PlaybackStateCommandEventArgs> _playbackCommand;
+ private Interop.MediaControllerServer.PlaybackStateCommandRecievedCallback _playbackCommandCallback;
+ private EventHandler<CustomCommandEventArgs> _customCommand;
+ private Interop.MediaControllerServer.CustomCommandRecievedCallback _customCommandCallback;
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ public MediaControllerServer ()
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerServer.Create (out _handle);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Create server failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Create server failed");
+ }
+ }
+
+ ~MediaControllerServer ()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if(!_disposed)
+ {
+ if(disposing)
+ {
+ // To be used if there are any other disposable objects
+ }
+ if(_handle != IntPtr.Zero)
+ {
+ Interop.MediaControllerServer.Destroy(_handle);
+ _handle = IntPtr.Zero;
+ }
+ _disposed = true;
+ }
+ }
+
+ /// <summary>
+ /// PlaybackStateCommandRecieved event is raised when client send command for playback
+ /// </summary>
+ public event EventHandler<PlaybackStateCommandEventArgs> PlaybackStateCommand
+ {
+ add
+ {
+ if(_playbackCommand == null)
+ {
+ RegisterPlaybackCmdRecvEvent();
+ }
+ _playbackCommand += value;
+
+ }
+ remove
+ {
+ _playbackCommand -= value;
+ if(_playbackCommand == null)
+ {
+ UnregisterPlaybackCmdRecvEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// CustomCommandRecieved event is raised when client send customized command
+ /// </summary>
+ public event EventHandler<CustomCommandEventArgs> CustomCommand
+ {
+ add
+ {
+ if(_customCommand == null)
+ {
+ RegisterCustomCommandEvent();
+ }
+ _customCommand += value;
+
+ }
+ remove
+ {
+ _customCommand -= value;
+ if(_customCommand == null)
+ {
+ UnregisterCustomCommandEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Update playback state and playback position</summary>
+ /// <param name="playback"> playback state and playback position </param>
+ public void UpdatePlayback(MediaControllerPlayback playback)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerServer.SetPlaybackState(_handle, (int)playback.State);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Playback state failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Playback state failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetPlaybackPosition(_handle, playback.Position);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Playback position failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Playback position failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.UpdatePlayback(_handle);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Update Playback failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Update Playback failed");
+ }
+ }
+
+ /// <summary>
+ /// Update metadata information </summary>
+ /// <param name="metadata"> metadata information </param>
+ public void UpdateMetadata(MediaControllerMetadata metadata)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Title, metadata.Title);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Artist, metadata.Artist);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Album, metadata.Album);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Author, metadata.Author);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Genre, metadata.Genre);
+ if (res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Duration, metadata.Duration);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Date, metadata.Date);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Copyright, metadata.Copyright);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Description, metadata.Description);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.TrackNumber, metadata.TrackNumber);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Picture, metadata.Picture);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
- }
-
- res = (MediaControllerError)Interop.MediaControllerServer.UpdateMetadata(_handle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Update Metadata failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Update Metadata failed");
- }
- }
-
- /// <summary>
- /// Update shuffle mode </summary>
- /// <param name="mode"> shuffle mode </param>
- public void UpdateShuffleMode(MediaControllerShuffleMode mode)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.UpdateShuffleMode(_handle, (int)mode);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Update Shuffle Mode failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Update Shuffle Mode failed");
- }
- }
-
- /// <summary>
- /// Update repeat mode </summary>
- /// <param name="mode"> repeat mode </param>
- public void UpdateRepeatMode(MediaControllerRepeatMode mode)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.UpdateRepeatMode(_handle, (int)mode);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Update Repeat Mode failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Update Repeat Mode failed");
- }
- }
-
- /// <summary>
- /// Send reply for command from server to client </summary>
- /// <param name="clientName"> client name to recieve reply </param>
- /// <param name="result"> result to run command </param>
- /// <param name="bundleData"> Bundle data </param>
- public void SendCustomCommandReply(string clientName, int result, Bundle bundle)
- {
- MediaControllerError res = MediaControllerError.None;
- res = (MediaControllerError)Interop.MediaControllerServer.SendCommandReply (_handle, clientName, result, bundle.SafeBundleHandle);
- if(res != MediaControllerError.None)
- {
- Log.Error(MediaControllerLog.LogTag, "Send reply for command failed" + res);
- MediaControllerErrorFactory.ThrowException(res, "Send reply for command failed");
- }
- }
-
- private void RegisterPlaybackCmdRecvEvent()
- {
- _playbackCommandCallback = (string clientName, int state, IntPtr userData) =>
- {
- PlaybackStateCommandEventArgs eventArgs = new PlaybackStateCommandEventArgs(clientName, (MediaControllerPlaybackState)state);
- _playbackCommand?.Invoke(this, eventArgs);
- };
- Interop.MediaControllerServer.SetPlaybackStateCmdRecvCb(_handle, _playbackCommandCallback, IntPtr.Zero);
- }
-
- private void UnregisterPlaybackCmdRecvEvent()
- {
- Interop.MediaControllerServer.UnsetPlaybackStateCmdRecvCb(_handle);
- }
-
- private void RegisterCustomCommandEvent()
- {
- _customCommandCallback = (string clientName, string command, IntPtr bundle, IntPtr userData) =>
- {
- SafeBundleHandle bundleHandle = new SafeBundleHandle(bundle, true);
- Applications.Bundle _bundle = new Bundle(bundleHandle);
- CustomCommandEventArgs eventArgs = new CustomCommandEventArgs(clientName, command, _bundle);
- _customCommand?.Invoke(this, eventArgs);
- };
- Interop.MediaControllerServer.SetCustomCmdRecvCb(_handle, _customCommandCallback, IntPtr.Zero);
- }
-
- private void UnregisterCustomCommandEvent()
- {
- Interop.MediaControllerServer.UnsetCustomCmdRecvCb(_handle);
- }
- }
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Date, metadata.Date);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Copyright, metadata.Copyright);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Description, metadata.Description);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.TrackNumber, metadata.TrackNumber);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.SetMetadata(_handle, (int)MediaControllerAttributes.Picture, metadata.Picture);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Set Title failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Set Title failed");
+ }
+
+ res = (MediaControllerError)Interop.MediaControllerServer.UpdateMetadata(_handle);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Update Metadata failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Update Metadata failed");
+ }
+ }
+
+ /// <summary>
+ /// Update shuffle mode </summary>
+ /// <param name="mode"> shuffle mode </param>
+ public void UpdateShuffleMode(MediaControllerShuffleMode mode)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerServer.UpdateShuffleMode(_handle, (int)mode);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Update Shuffle Mode failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Update Shuffle Mode failed");
+ }
+ }
+
+ /// <summary>
+ /// Update repeat mode </summary>
+ /// <param name="mode"> repeat mode </param>
+ public void UpdateRepeatMode(MediaControllerRepeatMode mode)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerServer.UpdateRepeatMode(_handle, (int)mode);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Update Repeat Mode failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Update Repeat Mode failed");
+ }
+ }
+
+ /// <summary>
+ /// Send reply for command from server to client </summary>
+ /// <param name="clientName"> client name to recieve reply </param>
+ /// <param name="result"> result to run command </param>
+ /// <param name="bundleData"> Bundle data </param>
+ public void SendCustomCommandReply(string clientName, int result, Bundle bundle)
+ {
+ MediaControllerError res = MediaControllerError.None;
+ res = (MediaControllerError)Interop.MediaControllerServer.SendCommandReply (_handle, clientName, result, bundle.SafeBundleHandle);
+ if(res != MediaControllerError.None)
+ {
+ Log.Error(MediaControllerLog.LogTag, "Send reply for command failed" + res);
+ MediaControllerErrorFactory.ThrowException(res, "Send reply for command failed");
+ }
+ }
+
+ private void RegisterPlaybackCmdRecvEvent()
+ {
+ _playbackCommandCallback = (string clientName, int state, IntPtr userData) =>
+ {
+ PlaybackStateCommandEventArgs eventArgs = new PlaybackStateCommandEventArgs(clientName, (MediaControllerPlaybackState)state);
+ _playbackCommand?.Invoke(this, eventArgs);
+ };
+ Interop.MediaControllerServer.SetPlaybackStateCmdRecvCb(_handle, _playbackCommandCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterPlaybackCmdRecvEvent()
+ {
+ Interop.MediaControllerServer.UnsetPlaybackStateCmdRecvCb(_handle);
+ }
+
+ private void RegisterCustomCommandEvent()
+ {
+ _customCommandCallback = (string clientName, string command, IntPtr bundle, IntPtr userData) =>
+ {
+ SafeBundleHandle bundleHandle = new SafeBundleHandle(bundle, true);
+ Applications.Bundle _bundle = new Bundle(bundleHandle);
+ CustomCommandEventArgs eventArgs = new CustomCommandEventArgs(clientName, command, _bundle);
+ _customCommand?.Invoke(this, eventArgs);
+ };
+ Interop.MediaControllerServer.SetCustomCmdRecvCb(_handle, _customCommandCallback, IntPtr.Zero);
+ }
+
+ private void UnregisterCustomCommandEvent()
+ {
+ Interop.MediaControllerServer.UnsetCustomCmdRecvCb(_handle);
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// MetadataUpdated event arguments
- /// </summary>
- /// <remarks>
- /// MetadataUpdated event arguments
- /// </remarks>
- public class MetadataUpdatedEventArgs : EventArgs
- {
- internal string _serverName;
- internal MediaControllerMetadata _metadata;
+ /// <summary>
+ /// MetadataUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// MetadataUpdated event arguments
+ /// </remarks>
+ public class MetadataUpdatedEventArgs : EventArgs
+ {
+ internal string _serverName;
+ internal MediaControllerMetadata _metadata;
- public MetadataUpdatedEventArgs (string name, IntPtr handle)
- {
- _serverName = name;
- _metadata = new MediaControllerMetadata (handle);
- }
-
- /// <summary>
- /// Get server name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ServerName
- {
- get
- {
- return _serverName;
- }
- }
+ internal MetadataUpdatedEventArgs (string name, IntPtr handle)
+ {
+ _serverName = name;
+ _metadata = new MediaControllerMetadata (handle);
+ }
- /// <summary>
- /// Get playback information.
- /// </summary>
- /// <value> 0 - 100 </value>
- public MediaControllerMetadata Metadata
- {
- get
- {
- return _metadata;
- }
- }
- }
+ /// <summary>
+ /// Get server name.
+ /// </summary>
+ public string ServerName
+ {
+ get
+ {
+ return _serverName;
+ }
+ }
+
+ /// <summary>
+ /// Get playback information.
+ /// </summary>
+ public MediaControllerMetadata Metadata
+ {
+ get
+ {
+ return _metadata;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// PlaybackStateCommand event arguments
- /// </summary>
- /// <remarks>
- /// PlaybackStateCommand event arguments
- /// </remarks>
- public class PlaybackStateCommandEventArgs : EventArgs
- {
- internal string _clientName;
- internal MediaControllerPlaybackState _state;
-
- public PlaybackStateCommandEventArgs (string name, MediaControllerPlaybackState state)
- {
- _clientName = name;
- _state = state;
- }
-
- /// <summary>
- /// Get client name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ClientName
- {
- get
- {
- return _clientName;
- }
- }
-
- /// <summary>
- /// Get playback state.
- /// </summary>
- /// <value> 0 - 100 </value>
- public MediaControllerPlaybackState State
- {
- get
- {
- return _state;
- }
- }
- }
+ /// <summary>
+ /// PlaybackStateCommand event arguments
+ /// </summary>
+ /// <remarks>
+ /// PlaybackStateCommand event arguments
+ /// </remarks>
+ public class PlaybackStateCommandEventArgs : EventArgs
+ {
+ internal string _clientName;
+ internal MediaControllerPlaybackState _state;
+
+ internal PlaybackStateCommandEventArgs (string name, MediaControllerPlaybackState state)
+ {
+ _clientName = name;
+ _state = state;
+ }
+
+ /// <summary>
+ /// Get client name.
+ /// </summary>
+ public string ClientName
+ {
+ get
+ {
+ return _clientName;
+ }
+ }
+
+ /// <summary>
+ /// Get playback state.
+ /// </summary>
+ public MediaControllerPlaybackState State
+ {
+ get
+ {
+ return _state;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// PlaybackUpdated event arguments
- /// </summary>
- /// <remarks>
- /// PlaybackUpdated event arguments
- /// </remarks>
- public class PlaybackUpdatedEventArgs : EventArgs
- {
- internal string _serverName;
- internal MediaControllerPlayback _playback;
+ /// <summary>
+ /// PlaybackUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// PlaybackUpdated event arguments
+ /// </remarks>
+ public class PlaybackUpdatedEventArgs : EventArgs
+ {
+ internal string _serverName;
+ internal MediaControllerPlayback _playback;
- public PlaybackUpdatedEventArgs (string name, IntPtr handle)
- {
- _serverName = name;
- _playback = new MediaControllerPlayback (handle);
- }
-
- /// <summary>
- /// Get server name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ServerName
- {
- get
- {
- return _serverName;
- }
- }
+ internal PlaybackUpdatedEventArgs (string name, IntPtr handle)
+ {
+ _serverName = name;
+ _playback = new MediaControllerPlayback (handle);
+ }
- /// <summary>
- /// Get playback information.
- /// </summary>
- /// <value> 0 - 100 </value>
- public MediaControllerPlayback PlaybackInfo
- {
- get
- {
- return _playback;
- }
- }
- }
+ /// <summary>
+ /// Get server name.
+ /// </summary>
+ public string ServerName
+ {
+ get
+ {
+ return _serverName;
+ }
+ }
+
+ /// <summary>
+ /// Get playback information.
+ /// </summary>
+ public MediaControllerPlayback PlaybackInfo
+ {
+ get
+ {
+ return _playback;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// RepeatModeUpdated event arguments
- /// </summary>
- /// <remarks>
- /// RepeatModeUpdated event arguments
- /// </remarks>
- public class RepeatModeUpdatedEventArgs : EventArgs
- {
- internal string _serverName;
- internal MediaControllerRepeatMode _mode;
+ /// <summary>
+ /// RepeatModeUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// RepeatModeUpdated event arguments
+ /// </remarks>
+ public class RepeatModeUpdatedEventArgs : EventArgs
+ {
+ internal string _serverName;
+ internal MediaControllerRepeatMode _mode;
- public RepeatModeUpdatedEventArgs (string name, MediaControllerRepeatMode mode)
- {
- _serverName = name;
- _mode = mode;
- }
-
- /// <summary>
- /// Get server name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ServerName
- {
- get
- {
- return _serverName;
- }
- }
+ internal RepeatModeUpdatedEventArgs (string name, MediaControllerRepeatMode mode)
+ {
+ _serverName = name;
+ _mode = mode;
+ }
- /// <summary>
- /// Get repeat mode.
- /// </summary>
- /// <value> 0 - 100 </value>
- public MediaControllerRepeatMode RepeatMode
- {
- get
- {
- return _mode;
- }
- }
- }
+ /// <summary>
+ /// Get server name.
+ /// </summary>
+ public string ServerName
+ {
+ get
+ {
+ return _serverName;
+ }
+ }
+
+ /// <summary>
+ /// Get repeat mode.
+ /// </summary>
+ public MediaControllerRepeatMode RepeatMode
+ {
+ get
+ {
+ return _mode;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// ServerInformation represents a name and state of server application.
- /// </summary>
- public class ServerInformation
- {
- internal ServerInformation(string _name, MediaControllerServerState _state)
- {
- Name = _name;
- State = _state;
- }
+ /// <summary>
+ /// ServerInformation represents a name and state of server application.
+ /// </summary>
+ public class ServerInformation
+ {
+ private string _name;
+ private MediaControllerServerState _state;
+ internal ServerInformation(string name, MediaControllerServerState state)
+ {
+ _name = name;
+ _state = state;
+ }
- /// <summary>
- /// The name of server
- /// </summary>
- public readonly string Name;
+ /// <summary>
+ /// The name of server
+ /// </summary>
+ public string Name
+ {
+ get
+ {
+ return _name;
+ }
+ }
- /// <summary>
- /// The state of server
- /// </summary>
- public readonly MediaControllerServerState State;
- }
+ /// <summary>
+ /// The state of server
+ /// </summary>
+ public MediaControllerServerState State
+ {
+ get
+ {
+ return _state;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// ServerUpdated event arguments
- /// </summary>
- /// <remarks>
- /// ServerUpdated event arguments
- /// </remarks>
- public class ServerUpdatedEventArgs : EventArgs
- {
- internal ServerInformation _serverInfo;
+ /// <summary>
+ /// ServerUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// ServerUpdated event arguments
+ /// </remarks>
+ public class ServerUpdatedEventArgs : EventArgs
+ {
+ internal ServerInformation _serverInfo;
- /// <summary>
- /// Constructor.
- /// </summary>
- internal ServerUpdatedEventArgs(string name, MediaControllerServerState state)
- {
- _serverInfo = new ServerInformation (name, state);
- }
+ internal ServerUpdatedEventArgs(string name, MediaControllerServerState state)
+ {
+ _serverInfo = new ServerInformation (name, state);
+ }
- /// <summary>
- /// Get server information.
- /// </summary>
- /// <value> 0 - 100 </value>
- public ServerInformation ServerInfo
- {
- get
- {
- return _serverInfo;
- }
- }
- }
+ /// <summary>
+ /// Get server information.
+ /// </summary>
+ public ServerInformation ServerInfo
+ {
+ get
+ {
+ return _serverInfo;
+ }
+ }
+ }
}
namespace Tizen.Multimedia.MediaController
{
- /// <summary>
- /// ShuffleModeUpdated event arguments
- /// </summary>
- /// <remarks>
- /// ShuffleModeUpdated event arguments
- /// </remarks>
- public class ShuffleModeUpdatedEventArgs : EventArgs
- {
- internal string _serverName;
- internal MediaControllerShuffleMode _mode;
+ /// <summary>
+ /// ShuffleModeUpdated event arguments
+ /// </summary>
+ /// <remarks>
+ /// ShuffleModeUpdated event arguments
+ /// </remarks>
+ public class ShuffleModeUpdatedEventArgs : EventArgs
+ {
+ internal string _serverName;
+ internal MediaControllerShuffleMode _mode;
- public ShuffleModeUpdatedEventArgs (string name, MediaControllerShuffleMode mode)
- {
- _serverName = name;
- _mode = mode;
- }
-
- /// <summary>
- /// Get server name.
- /// </summary>
- /// <value> 0 - 100 </value>
- public string ServerName
- {
- get
- {
- return _serverName;
- }
- }
+ internal ShuffleModeUpdatedEventArgs (string name, MediaControllerShuffleMode mode)
+ {
+ _serverName = name;
+ _mode = mode;
+ }
- /// <summary>
- /// Get shuffle mode.
- /// </summary>
- /// <value> 0 - 100 </value>
- public MediaControllerShuffleMode ShuffleMode
- {
- get
- {
- return _mode;
- }
- }
- }
+ /// <summary>
+ /// Get server name.
+ /// </summary>
+ public string ServerName
+ {
+ get
+ {
+ return _serverName;
+ }
+ }
+
+ /// <summary>
+ /// Get shuffle mode.
+ /// </summary>
+ public MediaControllerShuffleMode ShuffleMode
+ {
+ get
+ {
+ return _mode;
+ }
+ }
+ }
}