视频-网络插件
在蚂蚁媒体服务器上查看流的插件 。 改变流的解析度也有其功能
目录
快速启动
要快速安装 videojs-webrtc-plugin 并按以下步骤在服务器上本地运行.
-
清除本地系统上的存储器.
git clone https://github.com/ant-media/videojs-webrtc-plugin.git -
复制寄存器后,运行以下命令以在当地构建和运行项目.
npm install npm run build npm run start
在项目运行后,它将运行在任何特定的端口上(例如,端口1000),这样您就可以在http://localhost:1000或http://IP-address:1000上访问,如果运行在任何云端服务器上.
插件在浏览器中运行后,将websocket URL替换为您服务器在WS流链接中的websocket URL并加载流. 检查 流星图 参考部分.
安装
为了将插件集成到您的外部工程中,请使用下面的命令来安装软件包.
npm install --save @antmedia/videojs-webrtc-plugin
使用量
要将 videojs-webrtc-plugin 包含在您的网站或网络应用程序中,请使用以下任何方法.
源对象
流星图
Ant-MediaServer 流地址格式 :
ws://[ant-address]/[app]/[streamId].webrtc?token=[token(opt)]&subscriberId=[subscriberId(opt)]&subscriberCode=[TOTP-code(opt)]
例如:
ws://12.23.322.157:5080/LiveApp/stream1.webrtc
附加参数:-
token (optional)- 为溪流生成的一次性标志(如果溪流受到一次性标志保护机制的保护)subscriberId (optional)- 订阅者 ID。 如果该流受到 TOTP 密码的保护, 则需要subscriberCode (optional)- 生成了 TOTP 密码 。 如果流被 TOTP 密码保护,则需要
冰匠们
JSON字符串格式的 Ice-servers (STUN, TURN) 阵列以建立WebRTC连接.
例如:
'[ { "urls": "stun:stun1.l.google.com:19302" } ]'
<script> 标记
这是最简单的案例。 以任何你喜欢的方式获取脚本并包含插件 之后 包含 视频.js,这样 videojs 现可提供全球服务.
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-webrtc-plugin.min.js"></script>
<div id="video_container">
<video id=my-video width=960 height=540 class="video-js vjs-default-skin" controls>
<source
src="ws://localhost:5080/LiveApp/stream1.webrtc" iceServers = '[ { "urls": "stun:stun1.l.google.com:19302" } ]'
>
</video>
</div>
<script>
var player = videojs('my-video');
</script>
浏览/共同JS
在使用浏览器时,通过 npm 安装 videojs-webrtc-plugin require 插件,如您想要其它模块.
var videojs = require('video.js');
// The actual plugin function is exported by this module, but it is also
// attached to the `Player.prototype`; so, there is no need to assign it
// to a variable.
require('videojs-webrtc-plugin');
var player = videojs('my-video');
player.src({
src: 'ws://localhost:5080/LiveApp/stream1.webrtc',
iceServers: '[ { "urls": "stun:stun1.l.google.com:19302" } ]'
});
要求JS/AMD
使用 RequestJS( 或另一个 AMD 库) 时, 以您喜欢的方式获取脚本 require 通常情况下的插件 :
require(['video.js', 'videojs-webrtc-plugin'], function(videojs) {
var player = videojs('my-video');
player.src({
src: 'ws://localhost:5080/LiveApp/stream1.webrtc',
iceServers: '[ { "urls": "stun:stun1.l.google.com:19302" } ]'
});
});
处理错误召回
Ant-MediaServer具有处理后端出错的功能. 要发现错误, 您需要订阅事件“ ant- error ” :
<script src="//path/to/video.min.js"></script>
<script src="//path/to/videojs-webrtc-plugin.min.js"></script>
<script>
var player = videojs('my-video');
player.src({
src: 'ws://localhost:5080/LiveApp/stream1.webrtc',
iceServers: '[ { "urls": "stun:stun1.l.google.com:19302" } ]'
});
player.on('ant-error', function(event, errors) {
console.log(errors);
});
</script>
许可证
MIT. 版权 (c) 蚂蚁媒体
问题
如有问题,请在 蚂蚁-媒体-服务器仓库