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

做信息图网站网站建设 学习 长沙

做信息图网站,网站建设 学习 长沙,wordpress 服务器配置,自己做网站能宣传自己的产品吗在混合 App 中#xff0c;移动端使用 标签播放视频经常踩坑#xff0c;尤其是格式兼容、跨域限制、WebView 差异等问题。 本文介绍一个通用的 Cordova 视频播放组件#xff1a;优先 HTML5 播放#xff0c;播放失败自动提示用户使用系统播放器#xff0c;并支持原生插件兜底…在混合 App 中移动端使用 标签播放视频经常踩坑尤其是格式兼容、跨域限制、WebView 差异等问题。 本文介绍一个通用的 Cordova 视频播放组件优先 HTML5 播放播放失败自动提示用户使用系统播放器并支持原生插件兜底播放。 ✅ 功能亮点 ✅ 支持 MP4 / M3U8HLS.js✅ 播放失败提示「点击使用系统播放器」✅ 原生播放器兜底cordova-plugin-streaming-media✅ 可配置横/竖屏、全屏、缓存下载✅ 使用简单移动端稳定运行 安装依赖 cordova plugin add cordova-plugin-streaming-media npm install hls.js组件源码CordovaVideo.vue templatediv classvideo-wrapper v-showvisible clickonMaskClickvideov-if!useNativePlayerrefvideoclassvideo-player:srcvideoSrccontrolsplaysinlinewebkit-playsinline:posterposterclick.stoperroronVideoErrorwaiting$emit(buffering)playing$emit(playing)/videodiv v-iffallbackPrompt classfallback-tip click.stopp播放失败点击使用系统播放器/pbutton clickuseSystemPlayer用系统播放器播放/button/divbutton classclose-btn click.stoponMaskClick aria-label关闭视频×/buttondiv v-ifdownloading classdownload-progress click.stopp缓存中 {{ Math.round(progress * 100) }}%/p/div/div /templatescript import Hls from hls.jsexport default {name: CordovaVideo,props: {src: { type: String, required: true },cache: { type: Boolean, default: false },poster: String,landscape: { type: Boolean, default: true }},data () {return {visible: false,localPath: null,downloading: false,progress: 0,hls: null,useNativePlayer: false,fallbackPrompt: false}},computed: {videoSrc () {if (this.isM3U8) return return this.localPath || this.src},isM3U8 () {return this.src.endsWith(.m3u8)}},mounted () { this.prepare() },methods: {cleanupHtml5 () {if (this.hls) { this.hls.destroy(); this.hls null }const v this.$refs.videoif (v) { v.pause(); v.removeAttribute(src); v.load() }},play () {if (this.visible) returnthis.visible truethis.useNativePlayer falsethis.fallbackPrompt falsethis.$nextTick(() {if (this.isM3U8 Hls.isSupported()) {this.initHls()} else {this.tryHtml5Play()}})},tryHtml5Play () {const v this.$refs.videoif (!v) return this.showFallback()const onSuccess () {v.removeEventListener(error, onError)clearTimeout(timer)}const onError () this.showFallback()v.addEventListener(error, onError, { once: true })v.addEventListener(playing, onSuccess, { once: true })v.play().catch(() this.showFallback())const timer setTimeout(() this.showFallback(), 5000)},showFallback () {this.fallbackPrompt true},useSystemPlayer () {this.fallbackPrompt falsethis.playNative()},initHls () {this.hls?.destroy()this.hls new Hls()this.hls.attachMedia(this.$refs.video)this.hls.loadSource(this.src)this.hls.on(Hls.Events.ERROR, () this.showFallback())},onVideoError () {this.showFallback()},playNative () {const streaming window.plugins?.streamingMediaif (!streaming) {this.visible falsereturn}this.cleanupHtml5()this.useNativePlayer truethis.visible falsestreaming.playVideo(this.src, {orientation: this.landscape ? landscape : portrait,shouldAutoClose: true,controls: true,initFullscreen: true})},prepare () {},download () {}},watch: {src () {this.localPath nullthis.prepare()}} } /scriptstyle scoped .video-wrapper {position: fixed; inset: 0;background: #000;z-index: 9999;display: flex; align-items: center; justify-content: center; } .video-player {width: 100%; max-height: 100%; } .fallback-tip {position: absolute; inset: 0;background: rgba(0,0,0,0.6);color: #fff; font-size: 16px;display: flex; flex-direction: column;align-items: center; justify-content: center; } .fallback-tip button {padding: 6px 12px;background: #409eff; color: #fff;border: none; border-radius: 4px; } .close-btn {position: absolute; top: 12px; right: 12px;width: 32px; height: 32px;background: rgba(255,255,255,0.15);color: white; font-size: 20px;border: none; border-radius: 50%;cursor: pointer; } /style插件对比Cordova 常用视频播放方案分析 插件名是否全屏是否支持横竖屏控件控制兼容性是否可自定义关闭播放格式支持综合推荐video 标签否受限是是易出错Android 上格式限制多是MP4部分编码、HLS需搭配 hls.js✅ 前置尝试cordova-plugin-streaming-media✅ 是✅ 是✅ 支持稳定❌ 无关闭按钮需播放结束自动退出MP4 / M3U8 / AVI / 多格式依赖系统播放器⭐ 推荐兜底方案cordova-plugin-video-player✅ 是❌ 仅竖屏❌ 控制弱支持好❌ 无退出按钮MP4 主流支持 不推荐第三方播放器 WebView 方案如腾讯视频 iframe❓ 取决于 Web 容器❌ 受限❓ 不统一风险高易失效❌限平台❌ 仅作补充 ✅ 建议组合方案 播放顺序使用方式✅ 首选 HTML5 video 播放支持 HLS 的话配合 hls.js⚠️ 监听 play() 失败 或 error 回调中主动 fallback 兜底切换为 cordova-plugin-streaming-media 原生播放自动退出 总结 移动端视频播放兼容性较差需考虑降级处理使用原生播放器插件做兜底是当前 Cordova 应用中可靠的解决方案推荐使用 cordova-plugin-streaming-media轻量稳定 如果你觉得有帮助欢迎点赞收藏支持
http://www.pierceye.com/news/468289/

相关文章:

  • 手机网站开发下载app开发长沙
  • 重庆南川网站制作价格西宁网站建设优化
  • 电子商务网站建设与管理试卷6平面设计接单兼职
  • 建设手机网站大概要多少钱云南建投二公司官网
  • 公司如何建设网站首页网页设计与网站开发试题答案
  • 中企动力合作网站网站app下载平台怎么做
  • 网站开发专业成功人士重庆邮电大学官网网站
  • 官方网站后台图片下载怎么做网站开发与支付宝端口连接
  • 浏览器怎么打开网站服务器下载在线音乐网站开发摘要
  • 建网站拿到广告吉林整站优化
  • 怎么建站网站清远佛冈住房和城乡建设局网站
  • 领导高度重视门户网站建设广州引流推广公司
  • 公司网站建设吧个好wordpress增加搜索
  • 温州网站推广排名哪家购物网站建设好
  • 宿迁做网站公司哪家好中国建设监理协会化工监理协会网站
  • 网站建设广州天河常州企业自助建站系统
  • 厦门网站建设u贷款在线申请
  • 做肮脏交义的网站南宁住房和城乡建设局网站
  • 办网站需要什么my23777免费域名查询
  • 销售网站开发步骤网站域名到期了怎么办
  • 怎么做注册账号的网站网页打不开视频播放不了是什么问题
  • 江阴市住房和城乡建设局网站免费网页游戏poki
  • 个人网站设计网站建设的基本特点
  • 泉州专业做网站网站被k 原因
  • 18款禁用网站app直播建设部资质网站
  • 免费完整版的网站模板商丘行业网站建设开发公司
  • 网站与微网站区别推广通
  • 京东网站建设的意义wordpress美图
  • 佛山市外贸网站建设公司营销型网站建设 兼职
  • 四川省城乡与建设厅网站中国十大it培训机构排名