影片标记不会在Firefox中自动播放,DOMException

时间:2019-07-16 17:26:28

标签: javascript firefox video stream webrtc

我在平板电脑上使用Firefox 62.0.3,它可在其中一台平板电脑上运行,而不能在另一台平板电脑上运行。 在一个平板电脑上,我收到一条错误消息,说 DOMException: "The fetching process for the media resource was aborted by the user agent at the user's request." 我完全不确定这是什么告诉我,我的视频是否需要放在clickhandler中?我以为自动播放为真,静音为真,我很好吗? 再次适用于具有相同firefox版本的其他平板电脑。

<video id="asd" class="asd" oncreate={(el) => stream.start(el)}> Sorry, your browser doesn't support embedded videos.</video>

然后我做

this.peerConnection.ontrack = (event) => {
        const mediaStream = event.streams[0];
        let remoteVideoElement = document.getElementById('stream');
        remoteVideoElement.autoplay = "true";
        remoteVideoElement.defaultMuted = "true";
        remoteVideoElement.muted = "muted";
        remoteVideoElement.playsinline = "true";

        if ('srcObject' in remoteVideoElement) {
            remoteVideoElement.srcObject = mediaStream;
        } else {
            // Avoid using this in new browsers, as it is going away.
            remoteVideoElement.src = URL.createObjectURL(mediaStream);
        }
        let playPromise = remoteVideoElement.play();

        if (playPromise !== undefined) {
            playPromise.then((_) => {
                // will play video
            }).catch((err) => {
                console.error("playPromise error: ", err);
            })
        } else {
            console.error("playPromise is undefined: ", playPromise);
            remoteVideoElement.load();
        }
    }

它可以工作,但是当我尝试解决playPromise时会出现DOMException错误,而load()在出现问题的平板电脑上也无法工作。

0 个答案:

没有答案