Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Network.Bluetooth / Tizen.Network.Bluetooth / BluetoothAvrcp.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.Network.Bluetooth
20 {
21     /// <summary>
22     /// This class is used to notify changes of the target device (For example, media player) to the control device (For example, headset).
23     /// </summary>
24     /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
25     public class BluetoothAvrcp : BluetoothProfile
26     {
27         internal BluetoothAvrcp()
28         {
29         }
30
31         /// <summary>
32         /// The TargetConnectionStateChanged event is invoked when the connection state is changed.
33         /// </summary>
34         public event EventHandler<TargetConnectionStateChangedEventArgs> TargetConnectionStateChanged
35         {
36             add
37             {
38                 BluetoothAvrcpImpl.Instance.TargetConnectionStateChanged += value;
39             }
40             remove
41             {
42                 BluetoothAvrcpImpl.Instance.TargetConnectionStateChanged -= value;
43             }
44         }
45
46         /// <summary>
47         /// The EqualizerStateChanged event is invoked when the equalizer state is changed by the remote control device.
48         /// </summary>
49         public event EventHandler<EqualizerStateChangedEventArgs> EqualizerStateChanged
50         {
51             add
52             {
53                 BluetoothAvrcpImpl.Instance.EqualizerStateChanged += value;
54             }
55             remove
56             {
57                 BluetoothAvrcpImpl.Instance.EqualizerStateChanged -= value;
58             }
59         }
60
61         /// <summary>
62         /// The RepeatModeChanged event is invoked when the repeat mode is changed by the remote control device.
63         /// </summary>
64         public event EventHandler<RepeatModeChangedEventArgs> RepeatModeChanged
65         {
66             add
67             {
68                 BluetoothAvrcpImpl.Instance.RepeatModeChanged += value;
69             }
70             remove
71             {
72                 BluetoothAvrcpImpl.Instance.RepeatModeChanged -= value;
73             }
74         }
75
76         /// <summary>
77         /// The ShuffleModeChanged event is invoked when the shuffle mode is changed by the remote control device.
78         /// </summary>
79         public event EventHandler<ShuffleModeChangedeventArgs> ShuffleModeChanged
80         {
81             add
82             {
83                 BluetoothAvrcpImpl.Instance.ShuffleModeChanged += value;
84             }
85             remove
86             {
87                 BluetoothAvrcpImpl.Instance.ShuffleModeChanged -= value;
88             }
89         }
90
91         /// <summary>
92         /// The ScanModeChanged event is invoked when the scan mode is changed by the remote control device.
93         /// </summary>
94         public event EventHandler<ScanModeChangedEventArgs> ScanModeChanged
95         {
96             add
97             {
98                 BluetoothAvrcpImpl.Instance.ScanModeChanged += value;
99             }
100             remove
101             {
102                 BluetoothAvrcpImpl.Instance.ScanModeChanged -= value;
103             }
104         }
105
106         /// <summary>
107         /// Notifies the equalize state to the remote device.
108         /// </summary>
109         /// <remarks>
110         /// The remote device must be connected.
111         /// </remarks>
112         /// <param name="state">The equalizer state.</param>
113         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
114         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
115         /// or when notifying the equalizer state to the remote device fails.</exception>
116         public void NotifyEqualizerState(EqualizerState state)
117         {
118             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
119             {
120                 BluetoothAvrcpImpl.Instance.NotifyEqualizeState(state);
121             }
122             else
123             {
124                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
125             }
126         }
127
128         /// <summary>
129         /// Notifies the repeat mode to the remote device.
130         /// </summary>
131         /// <remarks>
132         /// The remote device must be connected.
133         /// </remarks>
134         /// <param name="mode">The repeat mode.</param>
135         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
136         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
137         /// or when notifying the repeat mode state to the remote device fails.</exception>
138         /// </exception>
139         public void NotifyRepeatMode(RepeatMode mode)
140         {
141             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
142             {
143                 BluetoothAvrcpImpl.Instance.NotifyRepeatMode(mode);
144             }
145             else
146             {
147                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
148             }
149         }
150
151         /// <summary>
152         /// Notifies the shuffle mode to the remote device.
153         /// </summary>
154         /// <remarks>
155         /// The remote device must be connected.
156         /// </remarks>
157         /// <param name="mode">The shuffle mode.</param>
158         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
159         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
160         /// or when notifying the shuffle mode state to the remote device fails.</exception>
161         public void NotifyShuffleMode(ShuffleMode mode)
162         {
163             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
164             {
165                 BluetoothAvrcpImpl.Instance.NotifyShuffleMode(mode);
166             }
167             else
168             {
169                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
170             }
171         }
172
173         /// <summary>
174         /// Notifies the scan mode to the remote device.
175         /// </summary>
176         /// <remarks>
177         /// The remote device must be connected.
178         /// </remarks>
179         /// <param name="mode">The scan mode.</param>
180         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
181         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
182         /// or when notifying the scan mode state to the remote device fails.</exception>
183         public void NotifyScanMode(ScanMode mode)
184         {
185             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
186             {
187                 BluetoothAvrcpImpl.Instance.NotifyScanMode(mode);
188             }
189             else
190             {
191                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
192             }
193         }
194
195         /// <summary>
196         /// Notifies the player state to the remote device.
197         /// </summary>
198         /// <remarks>
199         /// The remote device must be connected.
200         /// </remarks>
201         /// <param name="state">The player state.</param>
202         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
203         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
204         /// or when notifying the player state to the remote device fails.</exception>
205         public void NotifyPlayerState(PlayerState state)
206         {
207             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
208             {
209                 BluetoothAvrcpImpl.Instance.NotifyPlayerState(state);
210             }
211             else
212             {
213                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
214             }
215         }
216
217         /// <summary>
218         /// Notifies the current position of the song to the remote device.
219         /// </summary>
220         /// <remarks>
221         /// The remote device must be connected.
222         /// </remarks>
223         /// <param name="position">The current position in milliseconds.</param>
224         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
225         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
226         /// or when notifying the current position state to the remote device fails.</exception>
227         public void NotifyCurrentPosition(uint position)
228         {
229             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
230             {
231                 BluetoothAvrcpImpl.Instance.NotifyCurrentPosition(position);
232             }
233             else
234             {
235                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
236             }
237         }
238
239         /// <summary>
240         /// Notifies the track to the remote device.
241         /// </summary>
242         /// <remarks>
243         /// The remote device must be connected.
244         /// </remarks>
245         /// <param name="trackData">The data of the track.</param>
246         /// <exception cref="System.NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
247         /// <exception cref="System.InvalidOperationException">Thrown when the Bluetooth is not enabled
248         /// or when notifying the shuffle track state to the remote device fails.</exception>
249         public void NotifyTrack(Track trackData)
250         {
251             if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
252             {
253                 BluetoothAvrcpImpl.Instance.NotifyTrack(trackData);
254             }
255             else
256             {
257                 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
258             }
259         }
260     }
261 }
262