0

我正在尝试获取AWS Chime SDK 的基本教程以在我们的应用程序中工作,并且meetingSession.audioVideo.listVideoInputDevices()始终返回空/空。

我在最新的 chrome 上运行它,我的操作系统是 Windows 10 工作区实例。我插入了耳机;但这不应该有所作为。

我的预期结果是为视频返回至少一台设备。这是记录器的输出。

2020-08-26T15:29:19.127Z [INFO] MyLogger - attempting to trigger media device labels since they are hidden
chime-bundle.js:1 2020-08-26T15:29:19.133Z [INFO] MyLogger - unable to get media device labels
chime-bundle.js:1 2020-08-26T15:29:19.134Z [INFO] MyLogger - API/DefaultDeviceController/listVideoInputDevices null -> []
chime-bundle.js:1 Uncaught (in promise) TypeError: Cannot read property 'deviceId' of undefined

*笔记。视频和音频元素没有隐藏。

我已经尝试了各种演示中的代码片段。这些都只是 AWS 演练的副本。所以几乎是零信息。我研究了音频设备如何在 html5 中工作,并查看了 sdk-js 中提供的文件,我更加困惑。有人可以指出我正确的方向吗?

这是基本代码,您可以获取它,以及上面链接中的描述。

var fetchResult = await window.fetch(
            window.encodeURI("<our endpoint for backend (running c# instead of node)>",
            {
                method: 'POST'
            }
        );
        let result = await fetchResult.json();

        
        console.log("Result from Chime API:", result);

        const logger = new ConsoleLogger('MyLogger', LogLevel.INFO);
        const deviceController = new DefaultDeviceController(logger);

        const meetingResponse = result.JoinInfo.Meeting;
        const attendeeResponse = result.JoinInfo.Attendee;
        const configuration = new MeetingSessionConfiguration(meetingResponse, attendeeResponse);

        // In the usage examples below, you will use this meetingSession object.
        const meetingSession = new DefaultMeetingSession(
            configuration,
            logger,
            deviceController
        );
        console.log("MEETING SESSION", meetingSession);

        //SETUP AUDIO
        const audioElement = document.getElementById('notary-audio');
        meetingSession.audioVideo.bindAudioElement(audioElement);

        
        const videoElement = document.getElementById('notary-video');

        // Make sure you have chosen your camera. In this use case, you will choose the first device.
        const videoInputDevices = await meetingSession.audioVideo.listVideoInputDevices();

        // The camera LED light will turn on indicating that it is now capturing.
        // See the "Device" section for details.
        await meetingSession.audioVideo.chooseVideoInputDevice(videoInputDevices[0].deviceId);

        const observer = {
            audioVideoDidStart: () => {
                console.log('Started');
            },
            audioVideoDidStop: sessionStatus => {
                // See the "Stopping a session" section for details.
                console.log('Stopped with a session status code: ', sessionStatus.statusCode());
            },
            audioVideoDidStartConnecting: reconnecting => {
                if (reconnecting) {
                    // e.g. the WiFi connection is dropped.
                    console.log('Attempting to reconnect');
                }
            },

            // videoTileDidUpdate is called whenever a new tile is created or tileState changes.
            videoTileDidUpdate: tileState => {
                // Ignore a tile without attendee ID and other attendee's tile.
                if (!tileState.boundAttendeeId || !tileState.localTile) {
                    return;
                }

                // videoTileDidUpdate is also invoked when you call startLocalVideoTile or tileState changes.
                console.log(`If you called stopLocalVideoTile, ${tileState.active} is false.`);
                meetingSession.audioVideo.bindVideoElement(tileState.tileId, videoElement);
                localTileId = tileState.tileId;
            },
            videoTileWasRemoved: tileId => {
                if (localTileId === tileId) {
                    console.log(`You called removeLocalVideoTile. videoElement can be bound to another tile.`);
                    localTileId = null;
                }
            }
        };

        meetingSession.audioVideo.addObserver(observer);
        meetingSession.audioVideo.start();
4

0 回答 0