在模擬器上測試藍牙音訊
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在 Wear OS 模擬器中,搭載 Wear OS 4 以上版本的系統映像檔包括
支援模擬藍牙您可以利用這項支援功能,測試與藍牙音訊相關的多種用途。
與模擬的手機配對
透過模擬器的藍牙支援功能,您可以與模擬的手機配對,方法是使用指令列啟用設定精靈:
-append-userspace-opt androidboot.setupwizard_mode=REQUIRED
透過模擬的輸出裝置播放音訊
透過模擬器的藍牙支援功能,您也可以透過模擬的藍牙輸出裝置播放音訊。如要在模擬器中測試音訊輸出的切換情形,請使用開放原始碼的 Bumble 專案連線至模擬的藍牙輸出裝置。
準備環境
如要準備用來使用 Bumble 的開發機器,請完成下列步驟:
擷取 Bumble 原始碼:
git clone https://github.com/google/bumble
前往 bumble
目錄,建構並安裝 Bumble 模組:
cd bumble && python3 -m pip install "."
啟動模擬的藍牙喇叭
如要啟動模擬的喇叭,請完成下列步驟:
啟動支援 Wear OS 4 以上版本的模擬器。
注意:如果您使用的是模擬器版本
如果是低於 33.1.10,則使用指令列從指令列啟動模擬器
-packet-streamer-endpoint default
參數。
如要偵測模擬的喇叭並進行連線,請在 bumble
目錄中執行下列指令:
python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \
android-netsim stdout | ffplay -i
系統會透過電腦的喇叭播放音訊輸出內容。
您也可以將輸出內容重新導向至特定檔案:
python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \
android-netsim output.sbc
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Test Bluetooth audio on emulators\n\nOn the Wear OS emulator, system images that run Wear OS 4 or higher include\nsupport for emulated Bluetooth. This support lets you test several use cases\nrelated to Bluetooth audio.\n\nPair with an emulated phone\n---------------------------\n\nUsing the emulator's Bluetooth support, you can pair with an emulated phone. To\ndo so, enable the setup wizard from the command line: \n\n -append-userspace-opt androidboot.setupwizard_mode=REQUIRED\n\nPlay audio through an emulated output device\n--------------------------------------------\n\nUsing the emulator's Bluetooth support, you can also play audio through an\nemulated Bluetooth output device. To test audio output switching in the\nemulator, connect to an emulated Bluetooth output device using the open source\n[Bumble project](https://www.github.com/google/bumble).\n\n### Prepare your environment\n\nTo prepare your development machine for using Bumble, complete the following\nsteps:\n\n1. Fetch the Bumble source code:\n\n ```\n git clone https://github.com/google/bumble\n ```\n2. Navigate to the `bumble` directory, then build and install\n Bumble modules:\n\n ```\n cd bumble && python3 -m pip install \".\"\n ```\n\n### Launch emulated Bluetooth speaker\n\nTo launch the emulated speaker, complete the following steps:\n\n1. Launch a version of the emulator that supports Wear OS 4 or higher.\n\n **Note:** If you're using an emulator version\n lower than 33.1.10, launch the emulator from the command line using the\n `-packet-streamer-endpoint default` parameter.\n2. To discover and connect to the emulated speaker, run the following\n command in the `bumble` directory:\n\n ```\n python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \\\n android-netsim stdout | ffplay -i\n ```\n\n The audio output is played through your computer's speakers.\n\n You can also redirect output to a file: \n\n ```\n python3 examples/run_a2dp_sink.py examples/a2dp_sink1.json \\\n android-netsim output.sbc\n ```"]]