html5视频播放代码详解(HTML5基于flash实现播放RTMP协议视频的示例代码)
类别:Web前端 浏览量:2484
时间:2021-10-24 10:27:57 html5视频播放代码详解
HTML5基于flash实现播放RTMP协议视频的示例代码HTML5基于flash实现播放RTMP协议视频,具体代码如下所示:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Video.js 7</title> <link href="css/video-js.min.css" rel="stylesheet"> <style> body{background-color: #191919} .m{ width: 640px; height: 264px; margin-left: auto; margin-right: auto; margin-top: 100px; } </style> </head> <body> <li class="m"> <video id="rtmpVideo" class="video-js vjs-default-skin vjs-big-play-centered vjs-fluid" controls preload="auto" width="640" height="264" data-setup='{ "html5" : { "nativeTextTracks" : false } }'> </video> <script src="js/video.min.js"></script> <script src="js/videojs-flash.min.js"></script> <script type="text/javascript"> //设置中文 videojs.addLanguage('zh-CN', { "Play": "播放", "Pause": "暂停", "Current Time": "当前时间", "Duration": "时长", "Remaining Time": "剩余时间", "Stream Type": "媒体流类型", "LIVE": "直播", "Loaded": "加载完毕", "Progress": "进度", "Fullscreen": "全屏", "Non-Fullscreen": "退出全屏", "Mute": "静音", "Unmute": "取消静音", "Playback Rate": "播放速度", "Subtitles": "字幕", "subtitles off": "关闭字幕", "Captions": "内嵌字幕", "captions off": "关闭内嵌字幕", "Chapters": "节目段落", "Close Modal Dialog": "关闭弹窗", "Descriptions": "描述", "descriptions off": "关闭描述", "Audio Track": "音轨", "You aborted the media playback": "视频播放被终止", "A network error caused the media download to fail part-way.": "网络错误导致视频下载中途失败。", "The media could not be loaded, either because the server or network failed or because the format is not supported.": "视频因格式不支持或者服务器或网络的问题无法加载。", "The media playback was aborted due to a corruption problem or because the media used features your browser did not support.": "由于视频文件损坏或是该视频使用了你的浏览器不支持的功能,播放终止。", "No compatible source was found for this media.": "无法找到此视频兼容的源。", "The media is encrypted and we do not have the keys to decrypt it.": "视频已加密,无法解密。", "Play Video": "播放视频", "Close": "关闭", "Modal Window": "弹窗", "This is a modal window": "这是一个弹窗", "This modal can be closed by pressing the Escape key or activating the close button.": "可以按ESC按键或启用关闭按钮来关闭此弹窗。", ", opens captions settings dialog": ", 开启标题设置弹窗", ", opens subtitles settings dialog": ", 开启字幕设置弹窗", ", opens descriptions settings dialog": ", 开启描述设置弹窗", ", selected": ", 选择", "captions settings": "字幕设定", "Audio Player": "音频播放器", "Video Player": "视频播放器", "Replay": "重播", "Progress Bar": "进度小节", "Volume Level": "音量", "subtitles settings": "字幕设定", "descriptions settings": "描述设定", "Text": "文字", "White": "白", "Black": "黑", "Red": "红", "Green": "绿", "Blue": "蓝", "Yellow": "黄", "Magenta": "紫红", "Cyan": "青", "Background": "背景", "Window": "视窗", "Transparent": "透明", "Semi-Transparent": "半透明", "Opaque": "不透明", "Font Size": "字体尺寸", "Text Edge Style": "字体边缘样式", "None": "无", "Raised": "浮雕", "Depressed": "压低", "Uniform": "均匀", "Dropshadow": "下阴影", "Font Family": "字体库", "Proportional Sans-Serif": "比例无细体", "Monospace Sans-Serif": "单间隔无细体", "Proportional Serif": "比例细体", "Monospace Serif": "单间隔细体", "Casual": "舒适", "Script": "手写体", "Small Caps": "小型大写字体", "Reset": "重启", "restore all settings to the default values": "恢复全部设定至预设值", "Done": "完成", "Caption Settings Dialog": "字幕设定视窗", "Beginning of dialog window. Escape will cancel and close the window.": "开始对话视窗。离开会取消及关闭视窗", "End of dialog window.": "结束对话视窗" }); videojs.options.flash.swf = 'js/video-js.swf'; // 初始化视频,设为全局变量 var myPlayer = videojs('rtmpVideo', { autoplay: true, controls: true,//控制条 muted: true,// 静音 preload: "auto",// 预加载 language: "zh-CN",// 初始化语言 playbackRates: [1, 2, 3, 4, 5, 8, 10, 20],// 播放速度 'techOrder': ['flash'], sources: [{ /*rtmp://live.hkstv.hk.lxdns.com/live/hks*/ src: 'rtmp://www.uav-space.com/vod2/uspace3.mp4', //这里设置你的播放资源, type: 'rtmp/flv' }] }, function () { console.log("--------------成功初始化视频--------------"); myPlayer.one("playing", function () { // 监听播放 console.log("开始播放"); }); myPlayer.one("error", function (error) { // 监听错误 console.error("监听到异常,错误信息:%o",error); }); }); </script> </li> </body> </html>
另外,可能需要更新flash,更新完重启电脑,然后点击允许flash就可以了
!!!看到评论里有人说不执行,我特地把网盘资源下载下来又看看了,没问题的,视频没反应的,可能是因为你用的文件协议打开html的,要用http格式打开啊,自己搞的apache吧
demo网盘下载链接:
链接: https://pan.baidu.com/s/1i7ATxe78jDaLnZM4YRb3tA 提取码: uqsa
2020年8月28:补充 video class 上加上vjs-fluid 可以实现resize效果,demo上估计没有吧
到此这篇关于HTML5基于flash实现播放RTMP协议视频的示例代码的文章就介绍到这了,更多相关html5播放RTMP协议视频内容请搜索开心学习网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持开心学习网!
您可能感兴趣
- html5基本标签详解(HTML5 通过Vedio标签实现视频循环播放的示例代码)
- html为什么视频不能自动播放(html5中嵌入视频自动播放的问题解决)
- php上传图片视频代码(详解PHP素材图片上传、下载功能)
- python监控系统界面(Python远程视频监控程序的实例代码)
- 如何替换html5视频播放器(HTML5自定义视频播放器源码)
- 用python做一个表白视频(python仿抖音表白神器)
- python scrapy爬虫教程视频(详解python3 + Scrapy爬虫学习之创建项目)
- html5支持video的视频格式(解决html5中的video标签ios系统中无法播放使用的问题)
- html5炫酷代码(HTML5实现视频弹幕功能)
- 如何用python人脸识别(Python学习笔记之视频人脸检测识别实例教程)
- css3过渡技巧视频(css3过渡_动力节点Java学院整理)
- JavaScript css3实现简单视频弹幕功能(JavaScript css3实现简单视频弹幕功能)
- python获取游戏画面信息(python游戏开发之视频转彩色字符动画)
- html5播放视频的元素(HTML5在手机端实现视频全屏展示方法)
- 在网页中嵌入视频
- html5video怎么优化(HTML5 video循环播放多个视频的方法步骤)
- 少儿口才表达影响未来一生,50首经典绕口令和孩子玩出聪明大脑(少儿口才表达影响未来一生)
- 玩网游居然让人更友善 很难以让人置信(玩网游居然让人更友善)
- 学好汉语拼音,从娃娃绕口令抓起,平时还是要多练 收藏好(从娃娃绕口令抓起)
- 仙女们的私藏鲜法大PK 鲜香切块牛肉(仙女们的私藏鲜法大PK)
- 天热没胃口 这道菜开胃又下饭,2个小技巧新手一学就会(这道菜开胃又下饭)
- 指天椒紫苏爆炒牛肉(指天椒紫苏爆炒牛肉)
热门推荐
- 阿里云配置宝塔(在阿里云购买云服务器并安装宝塔面板的步骤)
- webview获取html(webView加载html图片遇到的问题解决)
- 由dem数据可以获得哪些数据(详解GaussDBDWS explain分布式执行计划的示例)
- sqlserver存储过程使用变量(浅析SQL Server的嵌套存储过程中使用同名的临时表怪像)
- rel=nofollow的作用
- thinkphp表单提交不到数据(ThinkPHP5.1表单令牌Token失效问题的解决)
- linux下如何启动phpstudy面板(详解phpstudy linux web面板小皮面板V0.2版本正式发布)
- angular引入组件库(详解Angular组件之中间人模式)
- windowsserver2012设置ftp账户(Windows Server 2012安装ftp服务器图文教程)
- jquery实现聚光灯效果
排行榜
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9