Files
plugin-library/Assets/12.WeixinMinigame/Runtime/playable-default/unity-sdk/video.js
stary 0d6faa56f4
All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s
微信小程序编译
2026-04-19 00:16:03 +08:00

77 lines
2.5 KiB
JavaScript

import moduleHelper from './module-helper';
import { formatJsonStr, getListObject, uid } from './utils';
const videoList = {};
const getObject = getListObject(videoList, 'video');
export default {
WXCreateVideo(conf) {
const id = uid();
const params = formatJsonStr(conf);
if (params.underGameView) {
GameGlobal.enableTransparentCanvas = true;
}
videoList[id] = wx.createVideo(params);
return id;
},
WXVideoSetProperty(id, key, value) {
const obj = getObject(id);
if (!obj) {
return;
}
if (key === 'x' || key === 'y' || key === 'width' || key === 'height' || key === 'initialTime' || key === 'playbackRate') {
obj[key] = +value;
}
else if (key === 'src' || key === 'poster' || key === 'objectFit' || key === 'backgroundColor') {
obj[key] = value;
}
else if (key === 'live' || key === 'controls' || key === 'showProgress' || key === 'showProgressInControlMode'
|| key === 'autoplay' || key === 'loop' || key === 'muted' || key === 'obeyMuteSwitch'
|| key === 'enableProgressGesture' || key === 'enablePlayGesture' || key === 'showCenterPlayBtn') {
obj[key] = value === 'True';
}
},
WXVideoAddListener(id, key) {
getObject(id)?.[key]((e) => {
moduleHelper.send('OnVideoCallback', JSON.stringify({
callbackId: id,
type: key,
position: e?.position,
buffered: e?.buffered ? Number(e.buffered) : undefined,
duration: e?.duration,
errMsg: e?.errMsg,
}));
if (key === 'onError') {
GameGlobal.enableTransparentCanvas = false;
console.error(e);
}
});
},
WXVideoRemoveListener(id, key) {
getObject(id)?.[key]();
},
WXVideoDestroy(id, isLast) {
getObject(id)?.destroy();
if (isLast) {
GameGlobal.enableTransparentCanvas = false;
}
},
WXVideoPlay(id) {
getObject(id)?.play();
},
WXVideoPause(id) {
getObject(id)?.pause();
},
WXVideoStop(id) {
getObject(id)?.stop();
},
WXVideoSeek(id, time) {
getObject(id)?.seek(time);
},
WXVideoRequestFullScreen(id, direction) {
getObject(id)?.requestFullScreen(direction);
},
WXVideoExitFullScreen(id) {
getObject(id)?.exitFullScreen();
},
};