未验证 提交 df248dfa 编写于 作者: O openharmony_ci 提交者: Gitee

!12008 示例代码修改

Merge pull request !12008 from 一杯丞丞汁儿/master
...@@ -2452,10 +2452,18 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCall ...@@ -2452,10 +2452,18 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors, callback: AsyncCall
**示例:** **示例:**
```js ```js
let inputAudioDeviceDescriptor = [{ let inputAudioDeviceDescriptor = [{
deviceRole : audio.DeviceRole.INPUT_DEVICE, deviceRole : audio.DeviceRole.INPUT_DEVICE,
networkId : audio.LOCAL_NETWORK_ID, deviceType : audio.DeviceType.EARPIECE,
interruptGroupId : 1, id : 1,
volumeGroupId : 1 }]; name : "",
address : "",
sampleRates : [44100],
channelCounts : [2],
channelMasks : [0],
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
}];
async function selectInputDevice(){ async function selectInputDevice(){
audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => { audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor, (err) => {
...@@ -2492,11 +2500,19 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void&gt ...@@ -2492,11 +2500,19 @@ selectInputDevice(inputAudioDevices: AudioDeviceDescriptors): Promise<void&gt
**示例:** **示例:**
```js ```js
let inputAudioDeviceDescriptor =[{ let inputAudioDeviceDescriptor = [{
deviceRole : audio.DeviceRole.INPUT_DEVICE, deviceRole : audio.DeviceRole.INPUT_DEVICE,
networkId : audio.LOCAL_NETWORK_ID, deviceType : audio.DeviceType.EARPIECE,
interruptGroupId : 1, id : 1,
volumeGroupId : 1 }]; name : "",
address : "",
sampleRates : [44100],
channelCounts : [2],
channelMasks : [0],
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
}];
async function getRoutingManager(){ async function getRoutingManager(){
audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => { audioRoutingManager.selectInputDevice(inputAudioDeviceDescriptor).then(() => {
...@@ -2639,10 +2655,19 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCa ...@@ -2639,10 +2655,19 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors, callback: AsyncCa
**示例:** **示例:**
```js ```js
let outputAudioDeviceDescriptor = [{ let outputAudioDeviceDescriptor = [{
deviceRole : audio.DeviceRole.OUTPUT_DEVICE, deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
networkId : audio.LOCAL_NETWORK_ID, deviceType : audio.DeviceType.SPEAKER,
interruptGroupId : 1, id : 1,
volumeGroupId : 1 }]; name : "",
address : "",
sampleRates : [44100],
channelCounts : [2],
channelMasks : [0],
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
}];
async function selectOutputDevice(){ async function selectOutputDevice(){
audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => { audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor, (err) => {
if (err) { if (err) {
...@@ -2678,11 +2703,19 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void& ...@@ -2678,11 +2703,19 @@ selectOutputDevice(outputAudioDevices: AudioDeviceDescriptors): Promise<void&
**示例:** **示例:**
```js ```js
let outputAudioDeviceDescriptor =[{ let outputAudioDeviceDescriptor = [{
deviceRole : audio.DeviceRole.OUTPUT_DEVICE, deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
networkId : audio.LOCAL_NETWORK_ID, deviceType : audio.DeviceType.SPEAKER,
interruptGroupId : 1, id : 1,
volumeGroupId : 1 }]; name : "",
address : "",
sampleRates : [44100],
channelCounts : [2],
channelMasks : [0],
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
}];
async function selectOutputDevice(){ async function selectOutputDevice(){
audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => { audioRoutingManager.selectOutputDevice(outputAudioDeviceDescriptor).then(() => {
...@@ -2720,11 +2753,20 @@ let outputAudioRendererFilter = { ...@@ -2720,11 +2753,20 @@ let outputAudioRendererFilter = {
streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA, streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags : 0 }, rendererFlags : 0 },
rendererId : 0 }; rendererId : 0 };
let outputAudioDeviceDescriptor = [{ let outputAudioDeviceDescriptor = [{
deviceRole : audio.DeviceRole.OUTPUT_DEVICE, deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
networkId : audio.LOCAL_NETWORK_ID, deviceType : audio.DeviceType.SPEAKER,
interruptGroupId : 1, id : 1,
volumeGroupId : 1 }]; name : "",
address : "",
sampleRates : [44100],
channelCounts : [2],
channelMasks : [0],
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
}];
async function selectOutputDeviceByFilter(){ async function selectOutputDeviceByFilter(){
audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => { audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor, (err) => {
...@@ -2769,11 +2811,20 @@ let outputAudioRendererFilter = { ...@@ -2769,11 +2811,20 @@ let outputAudioRendererFilter = {
streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA, streamUsage : audio.StreamUsage.STREAM_USAGE_MEDIA,
rendererFlags : 0 }, rendererFlags : 0 },
rendererId : 0 }; rendererId : 0 };
let outputAudioDeviceDescriptor = [{ let outputAudioDeviceDescriptor = [{
deviceRole : audio.DeviceRole.OUTPUT_DEVICE, deviceRole : audio.DeviceRole.OUTPUT_DEVICE,
networkId : audio.LOCAL_NETWORK_ID, deviceType : audio.DeviceType.SPEAKER,
interruptGroupId : 1, id : 1,
volumeGroupId : 1 }]; name : "",
address : "",
sampleRates : [44100],
channelCounts : [2],
channelMasks : [0],
networkId : audio.LOCAL_NETWORK_ID,
interruptGroupId : 1,
volumeGroupId : 1,
}];
async function selectOutputDeviceByFilter(){ async function selectOutputDeviceByFilter(){
audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => { audioRoutingManager.selectOutputDeviceByFilter(outputAudioRendererFilter, outputAudioDeviceDescriptor).then(() => {
...@@ -2806,6 +2857,10 @@ async function selectOutputDeviceByFilter(){ ...@@ -2806,6 +2857,10 @@ async function selectOutputDeviceByFilter(){
**示例:** **示例:**
```js ```js
import audio from '@ohos.multimedia.audio';
const audioManager = audio.getAudioManager();
let audioStreamManager; let audioStreamManager;
let resultFlag = false; let resultFlag = false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册