-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathattachmediastream.mjs
More file actions
57 lines (46 loc) · 1.5 KB
/
attachmediastream.mjs
File metadata and controls
57 lines (46 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import require$$0 from 'webrtc-adapter';
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var adapter = require$$0;
var attachmediastream = function (stream, el, options) {
var item;
var element = el;
var opts = {
autoplay: true,
mirror: false,
muted: false,
audio: false,
disableContextMenu: false
};
if (options) {
for (item in options) {
opts[item] = options[item];
}
}
if (!element) {
element = document.createElement(opts.audio ? 'audio' : 'video');
} else if (element.tagName.toLowerCase() === 'audio') {
opts.audio = true;
}
if (opts.disableContextMenu) {
element.oncontextmenu = function (e) {
e.preventDefault();
};
}
if (opts.autoplay) element.autoplay = 'autoplay';
element.muted = !!opts.muted;
if (!opts.audio) {
['', 'moz', 'webkit', 'o', 'ms'].forEach(function (prefix) {
var styleName = prefix ? prefix + 'Transform' : 'transform';
element.style[styleName] = opts.mirror ? 'scaleX(-1)' : 'scaleX(1)';
});
}
if (adapter.browserDetails.browser === 'safari') {
element.setAttribute('playsinline', true);
}
element.srcObject = stream;
return element;
};
var attachmediastream$1 = /*@__PURE__*/getDefaultExportFromCjs(attachmediastream);
export { attachmediastream$1 as default };