提交 f835b095 编写于 作者: J jiao_yanlin

Sample code error modification

Signed-off-by: Njiao_yanlin <jiaoyanlin@huawei.com>
上级 92ae69f9
...@@ -774,12 +774,15 @@ getRoutingManager(): Promise&lt;AudioRoutingManager&gt; ...@@ -774,12 +774,15 @@ getRoutingManager(): Promise&lt;AudioRoutingManager&gt;
**示例:** **示例:**
```js ```js
await audioManager.getRoutingManager().then((value) => { var audioManager = audio.getAudioManager();
var routingManager = value; async function getRoutingManager(){
console.info('getRoutingManager Promise SUCCESS.'); await audioManager.getRoutingManager().then((value) => {
}).catch((err) => { var routingManager = value;
console.error(`Result ERROR: ${err}`); console.info('getRoutingManager Promise SUCCESS.');
}); }).catch((err) => {
console.error(`Result ERROR: ${err}`);
});
}
``` ```
### setVolume ### setVolume
...@@ -4246,7 +4249,10 @@ audioRenderer.getBufferSize().then((data)=> { ...@@ -4246,7 +4249,10 @@ audioRenderer.getBufferSize().then((data)=> {
}); });
console.info(`Buffer size: ${bufferSize}`); console.info(`Buffer size: ${bufferSize}`);
var context = featureAbility.getContext(); var context = featureAbility.getContext();
var path = await context.getCacheDir(); var path;
async function getCacheDir(){
path = await context.getCacheDir();
}
var filePath = path + '/StarWars10s-2C-48000-4SW.wav'; var filePath = path + '/StarWars10s-2C-48000-4SW.wav';
let ss = fileio.createStreamSync(filePath, 'r'); let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
...@@ -4314,7 +4320,9 @@ audioRenderer.getBufferSize().then((data) => { ...@@ -4314,7 +4320,9 @@ audioRenderer.getBufferSize().then((data) => {
}); });
console.info(`BufferSize: ${bufferSize}`); console.info(`BufferSize: ${bufferSize}`);
var context = featureAbility.getContext(); var context = featureAbility.getContext();
var path = await context.getCacheDir(); async function getCacheDir(){
path = await context.getCacheDir();
}
var filePath = 'data/StarWars10s-2C-48000-4SW.wav'; var filePath = 'data/StarWars10s-2C-48000-4SW.wav';
let ss = fileio.createStreamSync(filePath, 'r'); let ss = fileio.createStreamSync(filePath, 'r');
let buf = new ArrayBuffer(bufferSize); let buf = new ArrayBuffer(bufferSize);
...@@ -4593,7 +4601,11 @@ var audioRendererOptions = { ...@@ -4593,7 +4601,11 @@ var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
let audioRenderer = await audio.createAudioRenderer(audioRendererOptions); let audioRenderer;
async function createAudioRenderer(){
audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
}
let mode = 0; let mode = 0;
audioRenderer.setInterruptMode(mode).then(data=>{ audioRenderer.setInterruptMode(mode).then(data=>{
console.info('setInterruptMode Success!'); console.info('setInterruptMode Success!');
...@@ -4634,7 +4646,12 @@ var audioRendererOptions = { ...@@ -4634,7 +4646,12 @@ var audioRendererOptions = {
streamInfo: audioStreamInfo, streamInfo: audioStreamInfo,
rendererInfo: audioRendererInfo rendererInfo: audioRendererInfo
} }
let audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
let audioRenderer;
async function createAudioRenderer(){
audioRenderer = await audio.createAudioRenderer(audioRendererOptions);
}
let mode = 1; let mode = 1;
audioRenderer.setInterruptMode(mode, (err, data)=>{ audioRenderer.setInterruptMode(mode, (err, data)=>{
if(err){ if(err){
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册