Skip to content

Commit

Permalink
Fix Mobile Safari issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Gheorghe committed Nov 12, 2018
1 parent f651e8f commit 7ce0f55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<title>ascii camera</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="css/main.css"/>
<meta name="mobile-web-app-capable" content="yes">
</head>
<body>
<h1 id="info">Please allow this page to access your camera.</h1>
Expand Down
9 changes: 6 additions & 3 deletions script/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@ var camera = (function() {
video = document.createElement("video");
video.setAttribute('width', options.width);
video.setAttribute('height', options.height);
video.setAttribute('playsinline', 'true');
video.setAttribute('webkit-playsinline', 'true');

navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia;
window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;

if (navigator.getUserMedia) {
navigator.getUserMedia({
video: true
video: true,
audio: false,
}, function(stream) {
options.onSuccess();

if (video.mozSrcObject !== undefined) { // hack for Firefox < 19
video.mozSrcObject = stream;
} else {
video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
video.srcObject = stream;
}

initCanvas();
Expand Down Expand Up @@ -71,7 +74,7 @@ var camera = (function() {
if (video.mozSrcObject !== undefined) {
video.mozSrcObject = null;
} else {
video.src = "";
video.srcObject = null;
}
}

Expand Down

0 comments on commit 7ce0f55

Please sign in to comment.