video取消控制栏属性

video标签取消画中画功能

在这里插入图片描述
nodownload: 不要下载
nofullscreen: 不要全屏
noremoteplayback: 不要远程回放

在这里插入图片描述

disablePictureInPicture= true 不要画中画

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 React 中使用 Video.js 并添加自定义控制,你可以按照以下步骤: 1. 安装 Video.js 和 React Video.js 在你的 React 项目中安装 Video.js 和 React Video.js: ``` npm install --save video.js react-videojs ``` 2. 导入 Video.js 和 React Video.js 在你的组件中导入 Video.js 和 React Video.js: ``` import videojs from 'video.js'; import 'video.js/dist/video-js.css'; import VideoJS from 'react-videojs'; ``` 3. 创建自定义控制 在 `componentDidMount` 生命周期中创建自定义控制。你可以使用 Video.js API 创建控制,例如: ``` componentDidMount() { const videoJsOptions = { controls: false, sources: [{ src: 'https://example.com/path/to/video.mp4', type: 'video/mp4' }] }; this.player = videojs(this.videoNode, videoJsOptions); const ControlBar = videojs.getComponent('ControlBar'); const CustomControlBar = videojs.extend(ControlBar, { constructor: function() { ControlBar.apply(this, arguments); this.addClass('vjs-custom-control-bar'); } }); videojs.registerComponent('CustomControlBar', CustomControlBar); const customControlBar = new CustomControlBar(this.player); this.player.addChild(customControlBar); customControlBar.addChild('playToggle'); customControlBar.addChild('currentTimeDisplay'); customControlBar.addChild('timeDivider'); customControlBar.addChild('durationDisplay'); customControlBar.addChild('progressControl'); customControlBar.addChild('volumePanel'); customControlBar.addChild('fullscreenToggle'); } ``` 在上面的代码中,我们创建了一个自定义控制,并将其添加到了 Video.js 播放器中。控制包含了常用的控制按钮和进度条。 4. 渲染 Video.js 播放器 在 `render` 方法中,渲染 Video.js 播放器: ``` render() { return ( <div data-vjs-player> <video ref={ node => this.videoNode = node } className="video-js"></video> </div> ) } ``` 这将在 DOM 中创建一个 `<video>` 元素并将其传递给 Video.js。 5. 完整代码示例 下面是一个完整的代码示例,演示如何在 React 中使用 Video.js 并添加自定义控制: ``` import React, { Component } from 'react'; import videojs from 'video.js'; import 'video.js/dist/video-js.css'; import VideoJS from 'react-videojs'; export default class VideoPlayer extends Component { componentDidMount() { const videoJsOptions = { controls: false, sources: [{ src: 'https://example.com/path/to/video.mp4', type: 'video/mp4' }] }; this.player = videojs(this.videoNode, videoJsOptions); const ControlBar = videojs.getComponent('ControlBar'); const CustomControlBar = videojs.extend(ControlBar, { constructor: function() { ControlBar.apply(this, arguments); this.addClass('vjs-custom-control-bar'); } }); videojs.registerComponent('CustomControlBar', CustomControlBar); const customControlBar = new CustomControlBar(this.player); this.player.addChild(customControlBar); customControlBar.addChild('playToggle'); customControlBar.addChild('currentTimeDisplay'); customControlBar.addChild('timeDivider'); customControlBar.addChild('durationDisplay'); customControlBar.addChild('progressControl'); customControlBar.addChild('volumePanel'); customControlBar.addChild('fullscreenToggle'); } componentWillUnmount() { if (this.player) { this.player.dispose(); } } render() { return ( <div data-vjs-player> <video ref={ node => this.videoNode = node } className="video-js"></video> </div> ) } } ``` 注意,如果你需要在组件卸载时销毁 Video.js 播放器,请确保在 `componentWillUnmount` 生命周期中调用 `this.player.dispose()`。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值