2 * Copyright (c) 2016 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.
19 namespace Tizen.Network.Bluetooth
22 /// This class is used to notify changes of the target device (For example, media player) to the control device (For example, headset).
24 /// <privilege> http://tizen.org/privilege/bluetooth </privilege>
25 public class BluetoothAvrcp : BluetoothProfile
27 internal BluetoothAvrcp()
32 /// The TargetConnectionStateChanged event is invoked when the connection state is changed.
34 public event EventHandler<TargetConnectionStateChangedEventArgs> TargetConnectionStateChanged
38 BluetoothAvrcpImpl.Instance.TargetConnectionStateChanged += value;
42 BluetoothAvrcpImpl.Instance.TargetConnectionStateChanged -= value;
47 /// The EqualizerStateChanged event is invoked when the equalizer state is changed by the remote control device.
49 public event EventHandler<EqualizerStateChangedEventArgs> EqualizerStateChanged
53 BluetoothAvrcpImpl.Instance.EqualizerStateChanged += value;
57 BluetoothAvrcpImpl.Instance.EqualizerStateChanged -= value;
62 /// The RepeatModeChanged event is invoked when the repeat mode is changed by the remote control device.
64 public event EventHandler<RepeatModeChangedEventArgs> RepeatModeChanged
68 BluetoothAvrcpImpl.Instance.RepeatModeChanged += value;
72 BluetoothAvrcpImpl.Instance.RepeatModeChanged -= value;
77 /// The ShuffleModeChanged event is invoked when the shuffle mode is changed by the remote control device.
79 public event EventHandler<ShuffleModeChangedeventArgs> ShuffleModeChanged
83 BluetoothAvrcpImpl.Instance.ShuffleModeChanged += value;
87 BluetoothAvrcpImpl.Instance.ShuffleModeChanged -= value;
92 /// The ScanModeChanged event is invoked when the scan mode is changed by the remote control device.
94 public event EventHandler<ScanModeChangedEventArgs> ScanModeChanged
98 BluetoothAvrcpImpl.Instance.ScanModeChanged += value;
102 BluetoothAvrcpImpl.Instance.ScanModeChanged -= value;
107 /// Notifies the equalize state to the remote device.
110 /// The remote device must be connected.
112 /// <param name="state">The equalizer state.</param>
113 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
114 /// <exception cref="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)
118 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
120 BluetoothAvrcpImpl.Instance.NotifyEqualizeState(state);
124 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
129 /// Notifies the repeat mode to the remote device.
132 /// The remote device must be connected.
134 /// <param name="mode">The repeat mode.</param>
135 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
136 /// <exception cref="InvalidOperationException">Thrown when the Bluetooth is not enabled
137 /// or when notifying the repeat mode state to the remote device fails.
139 public void NotifyRepeatMode(RepeatMode mode)
141 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
143 BluetoothAvrcpImpl.Instance.NotifyRepeatMode(mode);
147 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
152 /// Notifies the shuffle mode to the remote device.
155 /// The remote device must be connected.
157 /// <param name="mode">The shuffle mode.</param>
158 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
159 /// <exception cref="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)
163 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
165 BluetoothAvrcpImpl.Instance.NotifyShuffleMode(mode);
169 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
174 /// Notifies the scan mode to the remote device.
177 /// The remote device must be connected.
179 /// <param name="mode">The scan mode.</param>
180 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
181 /// <exception cref="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)
185 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
187 BluetoothAvrcpImpl.Instance.NotifyScanMode(mode);
191 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
196 /// Notifies the player state to the remote device.
199 /// The remote device must be connected.
201 /// <param name="state">The player state.</param>
202 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
203 /// <exception cref="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)
207 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
209 BluetoothAvrcpImpl.Instance.NotifyPlayerState(state);
213 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
218 /// Notifies the current position of the song to the remote device.
221 /// The remote device must be connected.
223 /// <param name="position">The current position in milliseconds.</param>
224 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
225 /// <exception cref="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)
229 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
231 BluetoothAvrcpImpl.Instance.NotifyCurrentPosition(position);
235 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);
240 /// Notifies the track to the remote device.
243 /// The remote device must be connected.
245 /// <param name="trackData">The data of the track.</param>
246 /// <exception cref="NotSupportedException">Thrown when the Bluetooth is not supported.</exception>
247 /// <exception cref="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)
251 if (BluetoothAdapter.IsBluetoothEnabled && Globals.IsInitialize)
253 BluetoothAvrcpImpl.Instance.NotifyTrack(trackData);
257 BluetoothErrorFactory.ThrowBluetoothException((int)BluetoothError.NotEnabled);