@alifd/meet-react
Version:
Fusion Mobile React UI System Component
39 lines • 1.18 kB
JavaScript
import { isStrictMiniApp, isStrictWechatMiniProgram, isStrictByteDanceMicroApp } from '../utils';
function toCamelCase(name) {
return name.replace(/-(\w)/g, function (all, letter) {
return letter.toUpperCase();
});
}
export 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;
}
export 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;
}
export function getVideoContext(id) {
var node = null;
if (isStrictMiniApp && typeof my !== 'undefined') {
node = my.createVideoContext(id);
} else if (isStrictByteDanceMicroApp && typeof tt !== 'undefined') {
node = tt.createVideoContext(id);
} else if (isStrictWechatMiniProgram) {
node = getWXVideoContext(id);
}
return node;
}