我正在尝试根据以下给出的文档在我们的 chime sdk singlejs 演示中集成语音焦点功能:https ://aws.github.io/amazon-chime-sdk-js/modules/amazonvoice_focus.html 。
但是,尽管尽了最大努力,isVoiceFocusSupported 仍然显示错误。代码如下所示,供您参考
(async () => {
const logger = new ChimeSDK.ConsoleLogger('MyLogger', ChimeSDK.LogLevel.INFO);
let transformer;
let isVoiceFocusSupported;
try {
const transformer = new VoiceFocusDeviceTransformer.create({}, { logger });
isVoiceFocusSupported = transformer.isSupported();
} catch (e) {
// Will only occur due to invalid input or transient errors (e.g., network).
isVoiceFocusSupported = false;
alert (isVoiceFocusSupported);
}
const deviceController = new ChimeSDK.DefaultDeviceController(logger);
const meetingResponse = {"Meeting":<?php if ($_GET ['met1']) echo $_SESSION ['met1'];else echo $_SESSION ['met']; ?>};
const attendeeResponse = {"Attendee":<?php echo json_encode($attendee) ?>};
const configuration = new ChimeSDK.MeetingSessionConfiguration(meetingResponse, attendeeResponse);
const meetingSession = new ChimeSDK.DefaultMeetingSession(configuration, logger, deviceController);
const audioInputDevices = await meetingSession.audioVideo.listAudioInputDevices();
const audioOutputDevices = await meetingSession.audioVideo.listAudioOutputDevices();
const videoInputDevices = await meetingSession.audioVideo.listVideoInputDevices();
meetingSession.audioVideo.chooseVideoInputQuality(960,540,15,1400);
await meetingSession.audioVideo.chooseVideoInputDevice(videoInputDevices[0].deviceId);
await meetingSession.audioVideo.chooseAudioInputDevice(audioInputDevices[0].deviceId);
if (audioOutputDevices[0]) {
await meetingSession.audioVideo.chooseAudioOutputDevice(audioOutputDevices[0].deviceId);
}
meetingSession.audioVideo.startVideoPreviewForVideoInput(document.getElementById('self-video'));
const audioElement = document.getElementById('audio-preview');
meetingSession.audioVideo.bindAudioElement(audioElement);
const videoElement = document.getElementById('video-prime');
const videoElement1 = document.getElementById('video-preview1');
const observer = {
audioVideoDidStart: () => {
console.log('Started');
},
videoTileDidUpdate: tileState => {
if (!tileState.boundAttendeeId || tileState.localTile || tileState.isContent) {
return;
}
//console.log('Start video');
const videoElement = document.getElementById('video-prime');
const videoElement1 = document.getElementById('video-preview1');
const videoElement2 = document.getElementById('video-preview2');
const tiles = meetingSession.audioVideo.getAllVideoTiles();
tiles.forEach(tile => {
let tileId = tile.tileState.tileId;
if (tileId=="2") { meetingSession.audioVideo.bindVideoElement(tileId, videoElement);}
if (tileId=="3") { meetingSession.audioVideo.bindVideoElement(tileId, videoElement1);}
if (tileId=="4") { meetingSession.audioVideo.bindVideoElement(tileId, videoElement1);}
if (tileId=="5") { meetingSession.audioVideo.bindVideoElement(tileId, videoElement2);}
$('#vi').html (tileId);
});
}
};
meetingSession.audioVideo.addObserver(observer);
meetingSession.audioVideo.start();
meetingSession.audioVideo.startLocalVideoTile();
}) ();
请指导我们哪里出错了。