我的代码如下:
private _adatpterWXPlatform() {
if(sys.platform == sys.Platform.WECHAT_GAME) {
let impl = this._videoPlayer["_impl"];
const self = this; // 保存外部this的引用
impl.createVideoPlayer = function (url) {
//@ts-ignore
if (!wx.createVideo) {
console.warn('VideoPlayer not supported');
return;
}
if (!this._video) {
//@ts-ignore
this._video = wx.createVideo({
underGameView: true,
zIndex:-9999,
});
this._video.showCenterPlayBtn = false;
this._video.controls = false;
this._duration = 0;
// this.
this._currentTime = 0;
this._loaded = false;
this.setVisible(this._visible);
this._bindEvent();
this._forceUpdate = true;
const screenSize = view.getVisibleSize();
this.height = screenSize.height;
// 使用工具函数设置视频尺寸,这里可以根据需要调整宽高值
// 视频的原始尺寸就是1080*1920固定的
// console.log("视频加载中")
// const screenSize = view.getVisibleSize();
// self._setVideoSize(this._video, 1080/1920*screenSize.height, screenSize.height);
}
this.setURL(url);
this._forceUpdate = true;
// setTimeout(() => {
// makeNodeFillScreen(this.node);
// }, 30);
}
}
}
目前看来,视频的放大比例偏高,在Y方向上撑不满屏幕。
我想要的效果是,视频在Y方向上撑满屏幕。