2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
19 using System.Diagnostics;
21 namespace Tizen.Multimedia.Remoting
24 /// Specifies the playlist mode.
26 /// <since_tizen> 5 </since_tizen>
27 public enum MediaControlPlaylistMode
30 /// Playlist is created or update.
35 /// Playlist is removed.
41 /// Specifies the repeat mode.
43 /// <since_tizen> 4 </since_tizen>
44 public enum MediaControlRepeatMode
59 /// <since_tizen> 5 </since_tizen>
64 /// Specifies playback commands.
66 /// <since_tizen> 4 </since_tizen>
67 public enum MediaControlPlaybackCommand
105 /// Toggle play/pause.
107 /// <since_tizen> 5 </since_tizen>
112 /// Specifies playback states.
114 /// <since_tizen> 4 </since_tizen>
115 public enum MediaControlPlaybackState
118 /// Unknown; no state is set.
148 /// Skipping to the next item.
150 /// <since_tizen> 5 </since_tizen>
154 /// Skipping to the previous item.
156 /// <since_tizen> 5 </since_tizen>
162 /// <since_tizen> 8 </since_tizen>
168 /// <since_tizen> 8 </since_tizen>
172 /// Error while playback.
174 /// <since_tizen> 8 </since_tizen>
179 /// Specifies the support type of media control capability.
181 /// <since_tizen> 5 </since_tizen>
182 public enum MediaControlCapabilitySupport
195 /// There's no support info in server.
197 /// <remarks>User should not set this value directly.</remarks>
202 /// Specifies the content type.
204 /// <since_tizen> 5 </since_tizen>
205 public enum MediaControlContentType
228 /// There's no content type info in server.
234 /// Specifies the search category.
236 /// <since_tizen> 5 </since_tizen>
237 public enum MediaControlSearchCategory
240 /// Search by all category.
245 /// Search by content title.
250 /// Search by content artist.
255 /// Search by content album.
260 /// Search by content genre.
265 /// Search by TPO(Time Place Occasion).
271 /// Specifies the display mode.
273 /// <since_tizen> 6 </since_tizen>
274 public enum MediaControlDisplayMode
292 /// Cropped full screen
298 /// Specifies the code which represents the result of communication between client and server.
300 /// <since_tizen> 8 </since_tizen>
301 public enum MediaControlResult
304 /// The command or the event has been successfully completed.
309 /// The command or the event had already been completed.
314 /// The command or the event is aborted by some external event (e.g. aborted play command by incoming call).
319 /// The command or the event is denied due to application policy (e.g. cannot rewind in recording).
324 /// The command or the event is not supported.
329 /// The command or the event is out of supported range or the limit is reached.
334 /// Timeout has occurred.
339 /// The application has failed.
344 /// The command or the event has failed because the application has no media.
349 /// The command or the event has failed because there is no audio output device.
354 /// The command or the event has failed because there is no peer.
359 /// The network has failed.
364 /// The application does not have account.
369 /// The application could not log in.
376 Unknown = Int32.MaxValue
379 internal static class EnumExtensions
381 internal static MediaControlPlaybackState ToPublic(this MediaControllerNativePlaybackState nativeState)
385 case MediaControllerNativePlaybackState.None: return MediaControlPlaybackState.None;
386 case MediaControllerNativePlaybackState.Play: return MediaControlPlaybackState.Playing;
387 case MediaControllerNativePlaybackState.Pause: return MediaControlPlaybackState.Paused;
388 case MediaControllerNativePlaybackState.Stop: return MediaControlPlaybackState.Stopped;
389 case MediaControllerNativePlaybackState.Next:
390 case MediaControllerNativePlaybackState.MovingToNext: return MediaControlPlaybackState.MovingToNext;
391 case MediaControllerNativePlaybackState.Prev:
392 case MediaControllerNativePlaybackState.MovingToPrev: return MediaControlPlaybackState.MovingToPrevious;
393 case MediaControllerNativePlaybackState.FastForward:
394 case MediaControllerNativePlaybackState.FastForwarding: return MediaControlPlaybackState.FastForwarding;
395 case MediaControllerNativePlaybackState.Rewind:
396 case MediaControllerNativePlaybackState.Rewinding: return MediaControlPlaybackState.Rewinding;
397 case MediaControllerNativePlaybackState.Connecting: return MediaControlPlaybackState.Connecting;
398 case MediaControllerNativePlaybackState.Buffering: return MediaControlPlaybackState.Buffering;
399 case MediaControllerNativePlaybackState.Error: return MediaControlPlaybackState.Error;
403 Debug.Fail($"Not supported code for playback state{nativeState}.");
404 return MediaControlPlaybackState.None;
407 internal static MediaControllerNativePlaybackState ToNative(this MediaControlPlaybackState state)
411 case MediaControlPlaybackState.Playing: return MediaControllerNativePlaybackState.Play;
412 case MediaControlPlaybackState.Paused: return MediaControllerNativePlaybackState.Pause;
413 case MediaControlPlaybackState.Stopped: return MediaControllerNativePlaybackState.Stop;
414 case MediaControlPlaybackState.MovingToNext: return MediaControllerNativePlaybackState.MovingToNext;
415 case MediaControlPlaybackState.MovingToPrevious: return MediaControllerNativePlaybackState.MovingToPrev;
416 case MediaControlPlaybackState.FastForwarding: return MediaControllerNativePlaybackState.FastForwarding;
417 case MediaControlPlaybackState.Rewinding: return MediaControllerNativePlaybackState.Rewinding;
418 case MediaControlPlaybackState.Connecting: return MediaControllerNativePlaybackState.Connecting;
419 case MediaControlPlaybackState.Buffering: return MediaControllerNativePlaybackState.Buffering;
420 case MediaControlPlaybackState.Error: return MediaControllerNativePlaybackState.Error;
423 return MediaControllerNativePlaybackState.None;
426 internal static MediaControlPlaybackCommand ToPublic(this MediaControllerNativePlaybackAction nativeAction)
428 switch (nativeAction)
430 case MediaControllerNativePlaybackAction.Play: return MediaControlPlaybackCommand.Play;
431 case MediaControllerNativePlaybackAction.Pause: return MediaControlPlaybackCommand.Pause;
432 case MediaControllerNativePlaybackAction.Stop: return MediaControlPlaybackCommand.Stop;
433 case MediaControllerNativePlaybackAction.Next: return MediaControlPlaybackCommand.Next;
434 case MediaControllerNativePlaybackAction.Prev: return MediaControlPlaybackCommand.Previous;
435 case MediaControllerNativePlaybackAction.FastForward: return MediaControlPlaybackCommand.FastForward;
436 case MediaControllerNativePlaybackAction.Rewind: return MediaControlPlaybackCommand.Rewind;
437 case MediaControllerNativePlaybackAction.Toggle: return MediaControlPlaybackCommand.Toggle;
441 Debug.Fail($"Not supported code for playback command{nativeAction}.");
442 return MediaControlPlaybackCommand.Play;
445 internal static MediaControllerNativePlaybackAction ToNative(this MediaControlPlaybackCommand command)
449 case MediaControlPlaybackCommand.Play: return MediaControllerNativePlaybackAction.Play;
450 case MediaControlPlaybackCommand.Pause: return MediaControllerNativePlaybackAction.Pause;
451 case MediaControlPlaybackCommand.Stop: return MediaControllerNativePlaybackAction.Stop;
452 case MediaControlPlaybackCommand.Next: return MediaControllerNativePlaybackAction.Next;
453 case MediaControlPlaybackCommand.Previous: return MediaControllerNativePlaybackAction.Prev;
454 case MediaControlPlaybackCommand.FastForward: return MediaControllerNativePlaybackAction.FastForward;
455 case MediaControlPlaybackCommand.Rewind: return MediaControllerNativePlaybackAction.Rewind;
456 case MediaControlPlaybackCommand.Toggle: return MediaControllerNativePlaybackAction.Toggle;
459 return MediaControllerNativePlaybackAction.Play;
462 internal static MediaControlRepeatMode ToPublic(this MediaControllerNativeRepeatMode mode)
464 Debug.Assert(Enum.IsDefined(typeof(MediaControllerNativeRepeatMode), mode));
466 return mode == MediaControllerNativeRepeatMode.Off ? MediaControlRepeatMode.On :
467 (mode == MediaControllerNativeRepeatMode.On ? MediaControlRepeatMode.Off : MediaControlRepeatMode.OneMedia);
470 internal static MediaControllerNativeRepeatMode ToNative(this MediaControlRepeatMode mode)
472 Debug.Assert(Enum.IsDefined(typeof(MediaControlRepeatMode), mode));
474 return mode == MediaControlRepeatMode.Off ? MediaControllerNativeRepeatMode.On :
475 (mode == MediaControlRepeatMode.On ? MediaControllerNativeRepeatMode.Off : MediaControllerNativeRepeatMode.OneMedia);
478 internal static MediaControlNativeDisplayMode ToNative(this MediaControlDisplayMode mode)
480 Debug.Assert(Enum.IsDefined(typeof(MediaControlDisplayMode), mode));
482 MediaControlNativeDisplayMode nativeMode = MediaControlNativeDisplayMode.LetterBox;
485 case MediaControlDisplayMode.LetterBox:
486 nativeMode = MediaControlNativeDisplayMode.LetterBox;
488 case MediaControlDisplayMode.OriginSize:
489 nativeMode = MediaControlNativeDisplayMode.OriginSize;
491 case MediaControlDisplayMode.FullScreen:
492 nativeMode = MediaControlNativeDisplayMode.FullScreen;
494 case MediaControlDisplayMode.CroppedFull:
495 nativeMode = MediaControlNativeDisplayMode.CroppedFull;
503 internal static MediaControlDisplayMode ToPublic(this MediaControlNativeDisplayMode mode)
505 Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayMode), mode));
506 MediaControlDisplayMode nativeMode = MediaControlDisplayMode.LetterBox;
509 case MediaControlNativeDisplayMode.LetterBox:
510 nativeMode = MediaControlDisplayMode.LetterBox;
512 case MediaControlNativeDisplayMode.OriginSize:
513 nativeMode = MediaControlDisplayMode.OriginSize;
515 case MediaControlNativeDisplayMode.FullScreen:
516 nativeMode = MediaControlDisplayMode.FullScreen;
518 case MediaControlNativeDisplayMode.CroppedFull:
519 nativeMode = MediaControlDisplayMode.CroppedFull;
527 internal static IList<MediaControlDisplayMode> ToPublicList(this MediaControlNativeDisplayMode modes)
529 var supportedModes = new List<MediaControlDisplayMode>();
531 foreach (MediaControlNativeDisplayMode mode in Enum.GetValues(typeof(MediaControlNativeDisplayMode)))
533 if (modes.HasFlag(mode))
535 supportedModes.Add(mode.ToPublic());
539 return supportedModes.AsReadOnly();
542 internal static MediaControlNativeDisplayRotation ToNative(this Rotation mode)
544 Debug.Assert(Enum.IsDefined(typeof(Rotation), mode));
546 MediaControlNativeDisplayRotation nativeMode = MediaControlNativeDisplayRotation.Rotate0;
549 case Rotation.Rotate0:
550 nativeMode = MediaControlNativeDisplayRotation.Rotate0;
552 case Rotation.Rotate90:
553 nativeMode = MediaControlNativeDisplayRotation.Rotate90;
555 case Rotation.Rotate180:
556 nativeMode = MediaControlNativeDisplayRotation.Rotate180;
558 case Rotation.Rotate270:
559 nativeMode = MediaControlNativeDisplayRotation.Rotate270;
567 internal static Rotation ToPublic(this MediaControlNativeDisplayRotation mode)
569 Debug.Assert(Enum.IsDefined(typeof(MediaControlNativeDisplayRotation), mode));
570 Rotation nativeMode = Rotation.Rotate0;
573 case MediaControlNativeDisplayRotation.Rotate0:
574 nativeMode = Rotation.Rotate0;
576 case MediaControlNativeDisplayRotation.Rotate90:
577 nativeMode = Rotation.Rotate90;
579 case MediaControlNativeDisplayRotation.Rotate180:
580 nativeMode = Rotation.Rotate180;
582 case MediaControlNativeDisplayRotation.Rotate270:
583 nativeMode = Rotation.Rotate270;
591 internal static IList<Rotation> ToPublicList(this MediaControlNativeDisplayRotation modes)
593 var supportedRotations = new List<Rotation>();
595 foreach (MediaControlNativeDisplayRotation mode in Enum.GetValues(typeof(MediaControlNativeDisplayRotation)))
597 if (modes.HasFlag(mode))
599 supportedRotations.Add(mode.ToPublic());
603 return supportedRotations.AsReadOnly();