移动端视频播放TCPlayer

腾讯云 Web 超级播放器 TCPlayerLite官网链接

Web 端超级播放器基于 video.js 框架开发,采用以 HTML5 <video>为主 Flash 为辅的播放方式,在浏览器不支持HTML5 <video> 的情况下采用 Flash 播放。播放器界面由 HTML CSS 实现,可以通过 CSS 定制界面。

根据官网api设置配置参数;一些特殊兼容总结如下:

  1. IOS和Android可以通过js判断,加不同属性
  2. 防止视频初始化封面和播放时闪动,可以初始化的时候给外层封面的宽高时,动态计算video的宽高来赋值给
    function getParams(name) {
    	var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    	var r = window.location.search.substr(1).match(reg);
    	if (r != null) {
    			return decodeURIComponent(r[2]);
    		}
    		return null;
    	}
    	var height = getParams('height');
    
        options:{
             mp4:'',
             width :  Width,//视频的显示宽度,请尽量使用视频分辨率宽度
             height : height || '320',
             autoplay: false,
             x5_player:true,
             x5_type: 'h5',
    		 x5_fullscreen:"false",
    		 x5_orientation:"portraint",
             controls: 'default' //default||'' 显示默认控件,none 不显示控件,system 移动端显示系统控件
                                            
          }
    

     

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个使用 Vue 3 实现移动端滑动播放视频的示例代码: ```html <template> <div ref="videoContainer" class="video-container"> <video ref="video" class="video" src="your-video-url"></video> </div> </template> <script> import { ref } from 'vue'; export default { setup() { const videoContainer = ref(null); const video = ref(null); let startPlayTime = null; function handleTouchStart(event) { startPlayTime = video.value.currentTime; } function handleTouchMove(event) { const containerRect = videoContainer.value.getBoundingClientRect(); const touchX = event.touches[0].clientX - containerRect.left; const progress = touchX / containerRect.width; const duration = video.value.duration; const currentTime = startPlayTime + progress * duration; video.value.currentTime = currentTime; } return { videoContainer, video, handleTouchStart, handleTouchMove, }; }, mounted() { this.$refs.videoContainer.addEventListener('touchstart', this.handleTouchStart); this.$refs.videoContainer.addEventListener('touchmove', this.handleTouchMove); }, unmounted() { this.$refs.videoContainer.removeEventListener('touchstart', this.handleTouchStart); this.$refs.videoContainer.removeEventListener('touchmove', this.handleTouchMove); }, }; </script> <style scoped> .video-container { position: relative; width: 100%; height: 0; padding-bottom: 56.25%; } .video { position: absolute; width: 100%; height: 100%; object-fit: contain; } </style> ``` 该示例中,使用了 Vue 3 的 Composition API,通过 ref 函数创建了 videoContainer 和 video 两个响应式变量,在 setup 函数中定义了 handleTouchStart 和 handleTouchMove 两个事件处理函数,并将它们绑定到 videoContainer 元素上。在 handleTouchMove 函数中,通过计算触摸点相对于视频容器的偏移量,以及视频的总时长,计算出当前视频播放位置,并设置为视频的当前时间。需要注意的是,在组件销毁时需要将事件处理函数从元素上解绑,以避免内存泄漏的问题。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值