[MediaController] Code refactoring
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia / MediaController / MediaControllerPlayback.cs
1 /*
2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 using System;
19
20 namespace Tizen.Multimedia.MediaController
21 {
22     /// <summary>
23     /// Playback represents a playback state and playback position.
24     /// </summary>
25     public class MediaControllerPlayback
26     {
27         /// <summary>
28         /// The constructor of MediaControllerPlayback class.
29         /// </summary>
30         public MediaControllerPlayback(MediaControllerPlaybackState state, ulong position) {
31             State = state;
32             Position = position;
33         }
34
35         internal MediaControllerPlayback(IntPtr _handle) {
36             MediaControllerPlaybackState state = MediaControllerPlaybackState.None;
37             ulong position = 0L;
38
39             MediaControllerValidator.ThrowIfError(
40                 Interop.MediaControllerClient.GetPlaybackState(_handle, out state), "Get Playback state failed");
41
42             MediaControllerValidator.ThrowIfError(
43                 Interop.MediaControllerClient.GetPlaybackPosition(_handle, out position), "Get Playback position failed");
44
45             State = state;
46             Position = position;
47         }
48
49        /// <summary>
50        /// Set/Get the State of playback information
51        /// </summary>
52         public MediaControllerPlaybackState State { get; }
53
54         /// <summary>
55         /// Set/Get the Position of playback information
56         /// </summary>
57         public ulong Position { get; }
58     }
59 }
60