Twilio视频聊天在src中返回blob:null

时间:2017-02-28 16:31:25

标签: javascript html twilio

我使用Twilio API创建视频聊天。它适用于iPad,我从笔记本电脑到我的iPad都有视频和音频,但我从iPad到我的网页(笔记本电脑)都没有看到任何内容:

<audio src="blob:null/cb84b2a9-be83-4db1-8313-61667b843865" autoplay></audio>
<video src="blob:null/492636ca-ce2f-4758-a866-2bf8ce9a08af" autoplay></video>

我的代码:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
    <script src="http://media.twiliocdn.com/sdk/js/video/v1/twilio-video.min.js"></script>
</head>
<body>
    <script type="text/javascript">
        var accessToken = "..."
        const Video = Twilio.Video;
        const client = new Video.Client(accessToken);
        const localMedia = new Video.LocalMedia();

        Video.getUserMedia().then(mediaStream => {
            localMedia.addStream(mediaStream);
        });

        client.connect({
            to: 'my-room',
            localMedia: localMedia
        }).then(room => {
            const localParticipant = room.localParticipant;                       
            room.participants.forEach(participant => {                    
                participant.on('trackAdded', track => {
                    if (track.kind === 'audio') {
                        console.log('Added an AudioTrack %s', track.id);
                    } else {
                        console.log('Added a VideoTrack %s', track.id);
                    }
                });
                participant.on('trackRemoved', track => {
                    if (track.kind === 'audio') {
                        console.log('Removed an AudioTrack %s', track.id);
                    } else {
                        console.log('Removed a VideoTrack %s', track.id);
                    }
                });    
                participant.on('trackEnabled', track => {
                    if (track.kind === 'audio') {
                        console.log('Enabled AudioTrack %s', track.id);
                    } else {
                        console.log('Enabled VideoTrack %s', track.id);
                    }
                });    
                participant.on('trackDisabled', track => {
                    if (track.kind === 'audio') {
                        console.log('Disabled AudioTrack %s', track.id);
                    } else {
                        console.log('Disabled VideoTrack %s', track.id);
                    }
                });

                const element = participant.media.attach();
                document.body.appendChild(element);

                participant.media.tracks.forEach(track => {
                    track.attach('#track-view');
                });
            });

            room.once('participantConnected', participant => {
                console.log('Participant "%s" has connected to the Room', participant.identity);
            });

            room.once('participantDisconnected', participant => {                
                console.log('Participant "%s" has disconnected from Room', participant.identity);
            });

        }, error => {
            console.error('Failed to connect to the Room', error);
        });
    </script>
</body>
</html>

我在控制台中也有错误:&#34;不允许加载本地资源:blob:null / 492636ca-ce2f-4758-a866-2bf8ce9a08af&#34;

0 个答案:

没有答案