【问题标题】:In react-player, how can I disable the FullScreen button?在 react-player 中,如何禁用全屏按钮?
【发布时间】:2020-02-18 07:55:51
【问题描述】:

这是我当前用于渲染 react-player 视频的代码

<div className="player">
                    <ReactPlayer url={result.url}
                                 playing={false}
                                 width={275}
                                 height={150}
                                 onPlay={playVideo}
                                 onEnded={stopVideo}
                                 onPause={pauseVideo}
                                 controls={true}
                    />
                </div>

【问题讨论】:

    标签: reactjs react-player


    【解决方案1】:

    您可以尝试将controls 属性设置为false,但它可能会隐藏一些您不想隐藏的控件。

    如果您的网址是例如 Vimeo 网址,您可以尝试执行以下操作:

    <ReactPlayer
       url='http://vimeo.com/...'
       vimeoConfig={{ iframeParams: { fullscreen: 0 } }}
    />
    

    如果是 youtube 网址试试这个:

    <ReactPlayer
        url='https://www.youtube.com/watch?v=mFJZ0HaYYB8'
        config={{
            youtube: {
                 playerVars: { modestbranding: 1 }
            }
        }}
    />
    

    查看this 页面,它可能也会有所帮助,或者查看 Config prop 部分下的official component page :)

    【讨论】:

    • 我尝试将控件设置为False,但现在它带来了一个“Youtube”水印,可以点击并发生标签更改!
    • 但是非常感谢官方组件页面正是我想要的。这是'fs'标签
    【解决方案2】:
    <ReactPlayer
          width={"100%"}
          height={"100%"}
          url="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4"
          muted={true}
          playing={true}
          controls
          config={{
            file: {
              attributes: {
                controlsList: "nofullscreen",
              },
            },
          }}
        />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-14
      • 2021-06-01
      • 2013-01-27
      • 2015-10-05
      • 1970-01-01
      • 2020-08-29
      • 1970-01-01
      相关资源
      最近更新 更多