当前位置: 首页 > news >正文

微信二维码制作网站学it什么培训机构好

微信二维码制作网站,学it什么培训机构好,抖音开放平台官网入口,基于wordpress学校网站目录 参考网址 效果图,暂停时显示暂停图标,播放时隐藏暂停图标 代码说明,代码传入url后,可直接复制使用 VideoPausedIcon.ts 组件 VideoCom.tsx Video.module.less 参考网址 在Video.js播放器中定制自己的组件 - acgtofe 效…

目录

参考网址

效果图,暂停时显示暂停图标,播放时隐藏暂停图标

代码说明,代码传入url后,可直接复制使用

VideoPausedIcon.ts 组件

VideoCom.tsx

Video.module.less


参考网址

 在Video.js播放器中定制自己的组件 - acgtofe

效果图,暂停时显示暂停图标,播放时隐藏暂停图标

代码说明,代码传入url后,可直接复制使用

注意:videojs升级后,不能用extend创建组件,需要按下方代码建一个组件

VideoPausedIcon.ts 组件
import videojs from "video.js";const Component: any = videojs.getComponent("Component");export class VideoPausedIcon extends Component {constructor(player: any, options: any) {super(player, options);// 监听,暂停播放,显示播放按钮player.on("pause", () => {this.visible = true;const el = this.el();el.className = "vjs-define-paused";});// 监听,开始播放,隐藏播放按钮,通过videojs自带的 vjs-hidden 类player.on("play", () => {this.visible = false;const el = this.el();el.className = "vjs-define-paused vjs-hidden";});this.on("touchstart", this.handleTouchStart);this.on("touchend", this.handleTouchEnd);// 如果需要在web端使用,必须,不兼容的话,web端点击按钮就不会暂停/播放this.on("click", (e: any) => this.handleClick(e, player));}createEl() {let pauseIcon = videojs.dom.createEl("div", {className: "vjs-define-paused",tabIndex: -1,});!this.visible && videojs.dom.appendContent(pauseIcon, "");return pauseIcon;}handleTouchStart(e: any) {// 此处必须,不然点击按钮不能播放/暂停e.stopPropagation();}handleTouchEnd(e: any) {// 此处必须,不然点击按钮不能播放/暂停e.stopPropagation();}handleClick(e: any, player: any) {e.stopPropagation();if (!player) {return;}const paused = player.paused();if (paused) {player.play();} else {player.pause();}}
}
VideoCom.tsx
import React, { useEffect } from "react";
import videojs from "video.js";
import "video.js/dist/video-js.css";
import styles from "./Video.module.less";
import { VideoPausedIcon } from "./VideoPausedIcon";interface IProps {url: string;
}const VideoCom: React.FC<IProps> = (props: any) => {const videoRef = React.useRef<any>(null);const playerRef = React.useRef<any>(null);useEffect(() => {const player: any = playerRef && playerRef.current;return () => {if (player && !player.isDisposed()) {player.dispose();playerRef.current = null;}};}, [playerRef]);useEffect(() => {if (!props.url) {return;}let options: any = {controlBar: {fullscreenToggle: true,pictureInPictureToggle: false,volumePanel: false,playToggle: false,},muted: false,controls: true, //进度条autoplay: false, //自动播放loop: false, //是否循环languages: {"zh-CN": new URL(`video.js/dist/lang/zh-CN.json`, import.meta.url).href,},language: "zh-CN",preload: "auto",nodownload: true,sources: [{ src: props.url, type: "video/mp4" }],};// Make sure Video.js player is only initialized onceif (!playerRef || !playerRef.current) {// The Video.js player needs to be _inside_ the component el for React 18 Strict Mode.const videoElement = document.createElement("video-js");videoRef &&videoRef.current &&videoRef.current.appendChild(videoElement);playerRef.current = videojs(videoElement, options, () => {console.log("player is ready");const player: any = playerRef.current;player.on("error", (err: any) => {console.log("source load fail");// message.error("视频源请求出错");});let touchStartTime = 0;let touchEndTime = 0;player.on("touchstart", (e: any) => {touchStartTime = new Date().getTime();});player.on("touchend", (e: any) => {touchEndTime = new Date().getTime();if (touchEndTime - touchStartTime < 300) {const paused = player.paused();if (paused) {player.play();} else {player.pause();}}});});createPausedIcon();} else {const player: any = playerRef.current;player.src(options.sources);}}, [props.url,playerRef,videoRef]);const createPausedIcon = () => {const player = playerRef && playerRef.current;if (!player) {return;}const Component: any = videojs.getComponent("Component");Component.registerComponent("VideoPausedIcon", VideoPausedIcon);const options = {};const properIndex = player.children().indexOf(player.getChild("BigPlayButton"));player.addChild("VideoPausedIcon", options, properIndex);};return (<div className={styles.container}><div className={styles.videoBox} ref={videoRef}></div></div>);
};export default VideoCom;
Video.module.less
.container {width: 100%;height: 100%;.videoBox {width: 100%;height: 100%;:global {.video-js {width: 100%;height: 100%;.vjs-big-play-button {display: none;}.vjs-define-paused {width: 30px;height: 28px;background: rgba(43, 63, 46, 0.7);border: 1px solid rgb(0, 255, 140);border-radius: 10px;position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);transition: all .4s;&::after {display: block;content: '';position: absolute;top: 50%;left: calc(50% + 5px);transform: translate(-50%, -50%);border-top: 5px solid;border-bottom: 5px solid;border-left: 8px solid;border-right: 8px solid;border-color: transparent;border-left-color: rgb(0, 255, 140);}}}}}}

http://www.hengruixuexiao.com/news/54234.html

相关文章:

  • 毕业设计做网站怎么做网站seo优化有哪些方面
  • 建材建设行业网站营销网络的建设怎么写
  • 企业如何建立网站好用的网站推荐
  • 网站公安备案需要几个工作日成都网站seo技术
  • 广告优化师发展前景广州关键词seo
  • 大坪网站建设seo服务外包报价
  • 哪些网站做的美剧百度搜图
  • 电子商务网站管理内容app推广怎么联系一手代理
  • 科技公司网站设计公司2021最近比较火的营销事件
  • 设计做兼职最好的网站查域名ip地址查询
  • cms网站开发毕设个人网站设计方案
  • 青岛路桥建设集团有限公司网站实时热点新闻事件
  • 做网站建设推广好做吗网站关键词快速排名工具
  • 阳江招聘网最新消息淘宝seo是什么意思啊
  • 推广做网站南充seo销售话术开场白
  • 网站建设高端定制品牌网络营销成功案例
  • 科技公司网站源码谷歌seo运营
  • 网站建设总体需求分析最近热点新闻事件
  • 单位建设网站seo流量是什么意思
  • 网站开发终止合作协议市场推广方式有哪几种
  • 精彩app应用下载网站优化设计公司
  • 做红酒闪购的网站有哪些企业官网seo
  • 惠州网站制作网站能打开各种网站的浏览器下载
  • 微分销平台登陆seo自己怎么做
  • 阿里云做网站用哪个镜像东莞网站建设
  • 湖南省交通建设质量监督站网站国际新闻直播
  • 温州微网站制作公司哪家好企业推广网络营销外包服务
  • 安卓手机app开发用什么软件seo的研究对象
  • 深圳网站建设网站刷赞抖音推广网站
  • 网站首图怎么做交易平台