Giter Site home page Giter Site logo

jswebrtc's Introduction

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

jswebrtc's People

Contributors

kernelj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.