Skip to content

ziard/WebRTC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebRTC

An easy way to use device camera.

demo

Usage

Create a div container

<div id="WebRTC"></div>

JavaScript

basic

// init
<script src="js/WebRTC.js"></script>
var WebRTC = new WebRTC("#WebRTC");

options

var WebRTC = new WebRTC("#WebRTC",{
	resolution: "HD",
	//camera resolution
	//if device not support high resolution will throw excaption
	//QVGA:320,240
	//VGA:640,480
	//HD:1280,720
	//FullHD:1920,1080
	//fourK:4096,2160
	//eightK:7680,4320

	fixWidth: 300,
	//set div width to value
	//camera width changed too, but resolution will be keeped

	front: true,
	//default:false
	//if false,uses rear camera. vice versa. 

	audio: true
	//default:false
	//open with audio
});

method

WebRTC.WebRTC("start");
//open camera

WebRTC.WebRTC("stop");
//stop camera

WebRTC.WebRTC("switch");
//switch resource between rear and front

WebRTC.WebRTC("pause");
//pause camera

WebRTC.WebRTC("resume");
//resume camera

WebRTC.WebRTC("capture", "#canvas",{
	width:800,
	height:600
});
//capture picture to canvas element
//<canvas id="canvas"></canvas>

WebRTC.WebRTC("zoom", 2);
//zoom camera
//device must support

// WebRTC.WebRTC("zoomBar");
//comming soon

jQuery

basic

//jquery version 1.12.4 or later
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="js/jquery.WebRTC.js"></script>
var WebRTC = $('#WebRTC').WebRTC();

options

var WebRTC = $("#WebRTC").WebRTC({
      resolution: "HD",
      fixWidth: 300,
      front: true,
      audio: true
    });

method

WebRTC.start();
//open camera

WebRTC.stop();
//stop camera

WebRTC.switch();
//switch resource between rear and front

WebRTC.pause();
//pause camera

WebRTC.resume();
//resume camera

WebRTC.capture('#canvas',{
	width:800,
	height:600
});
//capture picture to canvas element
//<canvas id="canvas"></canvas>

WebRTC.zoom(2);
//zoom camera
//device must support

// WebRTC.zoomBar();
//comming soon

Browsers support

Chrome
Chrome
IE / Edge
IE / Edge
Firefox
Firefox
Safari
Safari
iOS Safari
iOS Safari
Opera
Opera
Basic 47+ Edge 12+ 33+ 11+ 11+ 30+
Zoom 66+ Edge 12+ No No No 53

License

MIT

About

An easy way to use device camera.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published