浏览代码

[react demo] - iOS 订阅流兼容性处理

kevin.song 5 年之前
父节点
当前提交
12cd5b55eb
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      examples/react/src/components/MediaPlayer/index.jsx

+ 10 - 2
examples/react/src/components/MediaPlayer/index.jsx

@@ -161,16 +161,24 @@ export default class MediaPlayer extends Component {
   }
 
   renderVideoMask = () => {
-    if (this.isIOS && this.videoElem.current && this.videoElem.current.muted) {
+    const { stream } = this.props;
+    if (!stream || stream.type !== 'subscribe') {
+      return null;
+    }
+    if (!this.isIOS) {
+      return null;
+    }
+    if (this.videoElem.current && this.videoElem.current.muted) {
       return (
         <div className="muted-mask">
           <div className="mask-content">
-            <div className="hint">由于iOS系统限制,视频自动播放时需要静音,需要您点击下面按钮来取消静音</div>
+            <div className="hint">由于iOS系统限制,视频自动播放时需要静音,需要您点击下面按钮来取消静音</div>
             <button onClick={this.handleUnmute}>取消静音</button>
           </div>
         </div>
       )
     }
+    return null;
   }
 
   render() {