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

广元建设公司网站1688外贸网站

广元建设公司网站,1688外贸网站,wordpress文章代码,高中做信息技术题网站目录 参考网址 效果图#xff0c;暂停时显示暂停图标#xff0c;播放时隐藏暂停图标 代码说明#xff0c;代码传入url后#xff0c;可直接复制使用 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.FCIProps (props: any) {const videoRef React.useRefany(null);const playerRef React.useRefany(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.hkea.cn/news/14389233/

相关文章:

  • 怎么找需要做网站的客户兰州建设网站的网站
  • 阿里去可以做几个网站开发微信小程序商城
  • 模块网站和定制网站区别应用公园app在线平台
  • 网站平台方案设计建设银行手机外汇网站
  • 网站开发有什么技术要求专业的徐州网站开发
  • 创建网站的向导和模板石家庄哪里有做网站
  • 网站呢建设随州网站建设有限公司
  • opencart网站wordpress 输入 摘要
  • 网站更改空间品牌型网站建设特点
  • 广州市手机网站建设品牌江南网盟-专注中小企业网站建设服务
  • 正规网站建设推荐可以看电视剧的网站
  • 网站做长尾词好还是单个词好网站去哪备案
  • dede网站暂时关闭调兵山网站建设
  • 给网站做广告苏州建设有限公司
  • 泰安企业建站公司排行手机网站设计规格
  • 哪些公司用.cc做网站设计网站都有什么作用
  • 如何网站建设有利于网络营销东莞网页开发
  • 可以做公众号背景图的网站无锡seo公司哪家好
  • 网站排名怎样做有效wordpress多账号权限
  • 网站做外链的具体步骤内蒙古建设部网站官网
  • mysql做镜像网站网站建站公司排行
  • 江门网站推广多少钱运城网站建设求职简历
  • 哪些行业做网站推广的多在哪个网站找装修公司
  • 深圳网站维护页面设计小程序开发费用是多少
  • 北京网站建设上北京九五至尊网络滨州网站建设hskj360
  • 广州部队网站建设费用电子商务网站建设与管理课后答案
  • 建设银行官方网站手机版下载安装wordpress盈利
  • 网站建设的结构乡村建设网站
  • 为什么一个人做网站有难度帝国cms网站公告怎么做
  • 深圳福田网站建设福步外贸app下载