Skip to content
This repository was archived by the owner on Nov 4, 2023. It is now read-only.

Commit 7bbeb3c

Browse files
difeliceadifelice-godaddy
andauthoredNov 24, 2020
fix(CAMERA_STREAM): support non-HLS-capable devices (#537)
Co-authored-by: Alessandro Di Felice <alessandro@uniregistry.com>
1 parent f764d29 commit 7bbeb3c

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed
 

‎scripts/directives.js

+21-13
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,30 @@ App.directive('cameraStream', function (Api) {
227227
el.style.height = '100%';
228228
el.muted = 'muted';
229229

230-
const len = $scope.item.bufferLength || 5;
230+
if (Hls.isSupported()) {
231+
const len = $scope.item.bufferLength || 5;
231232

232-
const config = {
233-
maxBufferLength: len,
234-
maxMaxBufferLength: len,
235-
};
233+
const config = {
234+
maxBufferLength: len,
235+
maxMaxBufferLength: len,
236+
};
236237

237-
if (hls) {
238-
hls.destroy();
238+
if (hls) {
239+
hls.destroy();
240+
}
241+
hls = new Hls(config);
242+
hls.loadSource(url);
243+
hls.attachMedia(el);
244+
hls.on(Hls.Events.MANIFEST_PARSED, function () {
245+
el.play();
246+
});
247+
} else {
248+
el.src = url;
249+
el.setAttribute('playsinline', 'playsinline');
250+
el.addEventListener('loadedmetadata', function () {
251+
el.play();
252+
});
239253
}
240-
hls = new Hls(config);
241-
hls.loadSource(url);
242-
hls.attachMedia(el);
243-
hls.on(Hls.Events.MANIFEST_PARSED, function () {
244-
el.play();
245-
});
246254

247255
if (current) {
248256
$el[0].removeChild(current);

0 commit comments

Comments
 (0)