1.0.3 • Published 3 years ago
react-jswebrtc v1.0.3
react-jswebrtc
Base on JSWebrtc, Now react-jswebrtc supports import from React.js applications.
Author: Derek Chan
Original Repo: https://github.com/kernelj/jswebrtc
Repo: https://github.com/zezhuyu/jswebrtc
Usage
Install:
npm i react-jswebrtcUse in React.js:
<video id="webrtc_player"></video>import JSWebrtc from "react-jswebrtc"
if(JSWebrtc.isSupported()){
var video = document.getElementById('webrtc_player');
const player = new JSWebrtc.Player(url, {video: video});
player.play()
}Use in DPlayer:
import JSWebrtc from "react-jswebrtc"
const dp = new DPlayer({
container: document.getElementById('dplayer'),
video: {
type: 'webrtc',
customType: {
'webrtc': function (video, player) {
if(JSWebrtc.isSupported()){
new JSWebrtc.Player(url, {video: video});
}
}
},
},
})url: must start with webrtc://.
options parameters support:
video– for customized the html video element.api– for customized api url. by default it connects tohttp://ip:1985/rtc/v1/play/.autoplay- this will automatically mute and play the video after the player loads.falseby default.onPlay(player)– callback function when video is played.onPause(player)– callback function when video is paused.
JSWebrtc.Player API
JSWebrtc.Player instance support following operations:
.play()– start..pause()– pause..stop()– stop..destroy()– stop playing the video and free the resources..paused– check if it is paused.
Build
npm i
npm run build