1 Star 0 Fork 39

a/jswebrtc

forked from zensoft/jswebrtc 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

JSWebrtc – 支持 SRS 的 Webrtc 播放器

JSWebrtc 对浏览器的 Webrtc 做了简单的封装,支持 SRS 的 RTC 流的播放.

快速上手:

<script src="dist/jswebrtc.min.js"></script>
<div class="jswebrtc" data-url="webrtc://osiii.com/live/livestream"></div>

具体示例: examples

用法

JSWebrtc 播放器可以通过 HTML 创建,只需给指定元素添加 CSS 样式 jswebrtc 即可:

<div class="jswebrtc" data-url="<url>"></div>

也可以通过在 JavaScript 中调用 JSWebrtc.Player() 构造方法来创建:

var player = new JSWebrtc.Player(url [, options]);

参数 url 是一个 webrtc 开头的地址 (webrtc://...).

参数 options 支持下列的配置项:

  • video – 用于播放视频的 HTML Video 元素.
  • autoplay - 是否自动播放. 默认 false.
  • onPlay(player) – 播放后回调
  • onPause(player) – 暂停后回调

JSWebrtc.Player API

实例 JSWebrtc.Player 支持以下方法和属性:

  • .play() – 开始
  • .pause() – 暂停
  • .stop() – 停止
  • .destroy() – 停止播放并清理相关的播放资源.
  • .paused – 只读, 是否暂停播放

构建

如何构建 min 文件:

npm install
./build.sh
The MIT License (MIT) Copyright (c) 2020 Derek Chan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

JSWebrtc – 支持 SRS 的 Webrtc 播放器 展开 收起
JavaScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ak500/jswebrtc.git
git@gitee.com:ak500/jswebrtc.git
ak500
jswebrtc
jswebrtc
master

搜索帮助

Cb406eda 1850385 E526c682 1850385