【问题标题】:video.play() occurred unhandled rejection (notallowederror) on IOSvideo.play() 在 IOS 上发生未处理的拒绝(notallowederror)
【发布时间】:2022-01-21 05:04:40
【问题描述】:

在 React APP 上使用 peer.js 流视频

  addVideoStream(video: HTMLVideoElement, stream: MediaStream) {
    video.srcObject = stream

    video?.addEventListener('loadedmetadata', () => {
      video.play()
    })
    if (this.videoGrid) this.videoGrid.append(video)
  }

在 'video.play()' 得到这个错误

the request is not allowed by the user agent or the platform in the current context

我已经允许 IOS 上的音频和视频。

此代码适用于除 IOS 以外的其他平台。

我不知道。

如果我部署,那么我只会在 IOS 上出现黑屏。

我该如何解决这个问题?

提前致谢

【问题讨论】:

    标签: javascript html reactjs stream webrtc


    【解决方案1】:

    问题是视频标签如何在带有 WebRTC 的 IOS 中工作。

    使用 HTTPS 环境(生产)然后添加这些属性

    if (isMobile && isSafari) {
          this.myVideo.playsInline = true
          this.myVideo.autoplay = true
        }
    

    然后就可以了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-17
      • 1970-01-01
      • 2019-03-15
      • 2016-07-21
      • 2021-12-30
      • 1970-01-01
      相关资源
      最近更新 更多