2

ブログスピーカーアプリを開発しています。

iPodアプリのようにBluetoothが無効になっているときにオーディオを一時停止したい。これを読んでプライベートAPIを使わないと無理だと思いました。 Bluetooth が有効になっているかどうかを確認しますか?

しかし、私の顧客は、Rhapsody と DI Radio アプリの両方がそれをサポートしていると私に言いました。

その後、iOS5 には Core Bluetooth フレームワークがあることがわかりました。 https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CoreBluetooth_Framework/CoreBluetooth_Framework.pdf

CBCentralManagerStatePoweredOff ステータスはそのようです。

ただし、説明によると、この API は Bluetooth 4.0 Low Energy デバイスのみをサポートしています。誰かが同じことをしようとしましたか?

現在人気のある Bluetooth ヘッドセット、または車の Bluetooth 対応ステアリング ホイールをサポートしたいと考えています。いくつかの新しい Bluetooth しかサポートしていない場合、試してみる価値があるかどうかはわかりません。

4

2 に答える 2

2

オーディオの場合、特に Bluetooth に注目するのは間違ったアプローチのように思えます。

あなたが探しているのはHandling Audio Hardware Route Changesだと思います。

次のすべてが原因で、組み込みの iPod アプリが一時停止することに気付くでしょう。

  • Bluetooth デバイスが取り外されている (Bluetooth が無効になっている可能性があります)。
  • ヘッドフォンが取り外されています。
  • デバイスがドッキング ステーションから取り外されている。

Audio Session API を使用すると、すべての正しい動作が得られます。

于 2012-06-25T22:24:21.673 に答える
1

BLE では、状態を含むマネージャーの更新を取得します。

 enum {
CBCentralManagerStateUnknown = 0, // State unknown,
update imminent.
CBCentralManagerStateResetting, // The connection with the system service was      momentarily lost,
update imminent.
CBCentralManagerStateUnsupported, // The platform doesn't support Bluetooth Low Energy.
CBCentralManagerStateUnauthorized, // The app is not authorized to use Bluetooth Low Energy.
CBCentralManagerStatePoweredOff, // Bluetooth is currently powered off.
CBCentralManagerStatePoweredOn, // Bluetooth is currently powered on and available to use.
};

たとえば、必須のコールバックを確認できます

centralManager:didUpdateState...{
if ([manager state] == CBCentralManagerStatePoweredOff)
{
[musicPlayer pause]
}
}
于 2012-06-25T21:13:49.043 に答える