@alifd/meet-react
Version:
Fusion Mobile React UI System Component
45 lines (44 loc) • 1.28 kB
JavaScript
;
exports.__esModule = true;
exports.convertStyle = convertStyle;
exports.getVideoContext = getVideoContext;
exports.getWXVideoContext = getWXVideoContext;
var _utils = require("../utils");
function toCamelCase(name) {
return name.replace(/-(\w)/g, function (all, letter) {
return letter.toUpperCase();
});
}
function convertStyle(styleStr) {
if (!styleStr) {
return null;
}
var ret = {};
var attrs = styleStr.split(';');
for (var i = 0; i < attrs.length; i++) {
var entry = attrs[i].split(':');
ret[toCamelCase(entry.splice(0, 1)[0])] = entry.join(':');
}
return ret;
}
function getWXVideoContext(id) {
if (typeof wx !== 'undefined') {
var _internal;
if (document && document.getElementById && document.getElementById(id)) {
_internal = document.getElementById(id)._internal;
}
return wx.createVideoContext(id, _internal);
}
return null;
}
function getVideoContext(id) {
var node = null;
if (_utils.isStrictMiniApp && typeof my !== 'undefined') {
node = my.createVideoContext(id);
} else if (_utils.isStrictByteDanceMicroApp && typeof tt !== 'undefined') {
node = tt.createVideoContext(id);
} else if (_utils.isStrictWechatMiniProgram) {
node = getWXVideoContext(id);
}
return node;
}