6 Star 80 Fork 42

zensoft/jswebrtc

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
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.

About

JSWebrtc – 支持 SRS 的 Webrtc 播放器 expand collapse
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/kernelj/jswebrtc.git
git@gitee.com:kernelj/jswebrtc.git
kernelj
jswebrtc
jswebrtc
master

Search