@alifd/meet-react
Version:
Fusion Mobile React UI System Component
49 lines (48 loc) • 1.28 kB
JavaScript
;
exports.__esModule = true;
exports.getContexts = getContexts;
exports.getMiniappVideoContext = getMiniappVideoContext;
exports.getWXVideoContext = getWXVideoContext;
exports.pauseAll = pauseAll;
exports.play = play;
var _utils = require("../utils");
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 getMiniappVideoContext(id) {
if (typeof my !== 'undefined') {
return my.createVideoContext(id);
}
return null;
}
function getContexts(refs, sliderPrefixId) {
return refs.map(function (ref, index) {
var id = sliderPrefixId + "-" + index;
var node = ref;
if (_utils.isStrictMiniApp) {
node = getMiniappVideoContext(id);
} else if (_utils.isStrictWechatMiniProgram) {
node = getWXVideoContext(id);
}
return node;
});
}
function pauseAll(contexts) {
contexts.forEach(function (ctx) {
if (ctx.pause) {
ctx.pause();
}
});
}
function play(contexts, index) {
if (contexts && contexts[index] && contexts[index].play) {
contexts[index].play();
}
}