Release 4.0.0-preview1-00172
[platform/core/csapi/tizenfx.git] / src / Tizen.Content.MediaContent / Tizen.Content.MediaContent / PlayList.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 using System;
18
19 namespace Tizen.Content.MediaContent
20 {
21     /// <summary>
22     /// Represents the playlist that is a group of media (usually songs).
23     /// </summary>
24     public class Playlist
25     {
26         internal Playlist(IntPtr handle)
27         {
28             Name = InteropHelper.GetString(handle, Interop.Playlist.GetName);
29             ThumbnailPath = InteropHelper.GetString(handle, Interop.Playlist.GetThumbnailPath);
30
31             Id = InteropHelper.GetValue<IntPtr, int>(handle, Interop.Playlist.GetId);
32         }
33
34         internal static Playlist FromHandle(IntPtr handle) => new Playlist(handle);
35
36         /// <summary>
37         /// Gets the ID of the playlist.
38         /// </summary>
39         /// <value>The unique ID of the playlist.</value>
40         public int Id { get; }
41
42         /// <summary>
43         /// Gets the name of the playlist.
44         /// </summary>
45         /// <value>The name of the playlist.</value>
46         public string Name { get; }
47
48         /// <summary>
49         /// Gets the path to the thumbnail.
50         /// </summary>
51         /// <value>The path to the thumbnail.</value>
52         public string ThumbnailPath { get; }
53
54         /// <summary>
55         /// Returns a string representation of the playlist.
56         /// </summary>
57         /// <returns>A string representation of the current playlist.</returns>
58         public override string ToString() =>
59             $"Id={Id}, Name={Name}, ThumbnailPath={ThumbnailPath}";
60     }
61
62     /// <summary>
63     /// Provides means to set values used for the update command.
64     /// </summary>
65     /// <remarks>
66     /// The values only set in the object will be affected to the update command.
67     /// </remarks>
68     /// <seealso cref="PlaylistCommand.Update (int, PlaylistUpdateValues)"/>
69     public class PlaylistUpdateValues
70     {
71         /// <summary>
72         /// Gets or sets the name of the playlist for an update.
73         /// </summary>
74         /// <remarks>If the value is null, the update operation will have no effect on the field.</remarks>
75         /// <value>A string for name; the field will not be updated if null.</value>
76         public string Name { get; set; }
77
78         /// <summary>
79         /// Gets or sets the thumbnail path of the playlist for an update.
80         /// </summary>
81         /// <remarks>If the value is null, the update operation will have no effect on the field.</remarks>
82         /// <value>A string for the thumbnail path; the field will not be updated if null.</value>
83         public string ThumbnailPath { get; set; }
84     }
85
86     /// <summary>
87     /// Represents an order of a member of the playlist.
88     /// </summary>
89     public class PlayOrder
90     {
91         /// <summary>
92         /// Initializes a new instance of the <see cref="Playlist"/> class with the specified member ID and the order value.
93         /// </summary>
94         /// <param name="memberId">The ID of the member.</param>
95         /// <param name="orderValue">The order value.</param>
96         /// <exception cref="ArgumentOutOfRangeException">
97         ///     <paramref name="memberId"/> is less than or equal to zero.\n
98         ///     -or-\n
99         ///     <paramref name="orderValue"/> is less than zero.
100         /// </exception>
101         public PlayOrder(int memberId, int orderValue)
102         {
103             MemberId = memberId;
104             Value = orderValue;
105         }
106
107         private int _memberId;
108
109         /// <summary>
110         /// Gets or sets the member ID.
111         /// </summary>
112         /// <value>The member ID.</value>
113         /// <exception cref="ArgumentOutOfRangeException">
114         /// <paramref name="value"/> is less than or equal to zero.
115         /// </exception>
116         public int MemberId
117         {
118             get => _memberId;
119             set
120             {
121                 if (value <= 0)
122                 {
123                     throw new ArgumentOutOfRangeException(nameof(value), value,
124                     "Member id can't be less than or equal to zero.");
125                 }
126                 _memberId = value;
127             }
128         }
129
130         private int _value;
131
132         /// <summary>
133         /// Gets or sets the value indicating the order of the member in the playlist.
134         /// </summary>
135         /// <value>An integer value indicating the order of the member in the playlist.</value>
136         /// <exception cref="ArgumentOutOfRangeException">
137         ///     <paramref name="value"/> is less than zero.
138         /// </exception>
139         public int Value
140         {
141             get => _value;
142             set
143             {
144                 if (value < 0)
145                 {
146                     throw new ArgumentOutOfRangeException(nameof(value), value,
147                         "Order can't be less than zero.");
148                 }
149                 _value = value;
150             }
151         }
152     }
153 }