|
[BUG]
api.imageCache+TCSuperPlayer实现视频封面:安卓有问题
[复制链接]
this.data.TCSuperPlayer = api.require('TCSuperPlayer');
// 设置授权
this.data.TCSuperPlayer.setLicence({
licenceURL: 'xxx',
licenceKey: 'xxx'
})
let userAgent = navigator.userAgent
if (userAgent.includes('iPhone') || userAgent.includes('iPad')) {
console.log('苹果手机')
// 苹果先配置播放器视图再初始化
this.data.iphoneShow = true
// 配置播放器视图
this.data.TCSuperPlayer.configPlayerView({
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: 250
},
fixedOn: 'video',
fixed: true, // 必须是true,否则不能触发全屏
isShowDanmu: false, // 全屏状态下是否显示弹幕开关按钮,仅Android支持
isShowSnapshot: false, // 全屏状态下是否显示截屏按钮
isShowMoreButton: true, // 全屏状态下是否显示更多按钮
isShowPipBtn: false, // 描述:(可选项)非全屏状态下是否显示画中画按钮,仅支持iOS端
isShowWindowLayoutTop: true, // 半屏状态下是否显示播放区域顶部导航条
isShowBackBtn: true, // 半屏状态下是否显示播放区域顶部返回按钮,返回按钮在顶部导航条内的布局中
});
// 初始化
this.data.TCSuperPlayer.initPlayer();
} else if (userAgent.includes('Android')) {
console.log('安卓手机')
this.data.iphoneShow = false
// 安卓先初始化再配置播放器视图
// 初始化
this.data.TCSuperPlayer.initPlayer();
// 配置播放器视图
this.data.TCSuperPlayer.configPlayerView({
rect: {
x: 0,
y: 0,
w: api.winWidth,
h: 250
},
fixedOn: 'video',
fixed: true, // 必须是true,否则不能触发全屏
isShowDanmu: false, // 全屏状态下是否显示弹幕开关按钮,仅Android支持
isShowSnapshot: false, // 全屏状态下是否显示截屏按钮
isShowMoreButton: true, // 全屏状态下是否显示更多按钮
isShowPipBtn: false, // 描述:(可选项)非全屏状态下是否显示画中画按钮,仅支持iOS端
isShowWindowLayoutTop: true, // 半屏状态下是否显示播放区域顶部导航条
isShowBackBtn: true, // 半屏状态下是否显示播放区域顶部返回按钮,返回按钮在顶部导航条内的布局中
});
}
// 设置封面图
var url = ''
api.imageCache({
url: api.pageParam.classlist.course_play_img
}, function (ret, err) {
url = ret.url;
});
setTimeout(() => {
if (url != 'undefined' && url != undefined) {
this.data.TCSuperPlayer.setCoverImage({
coverImage: url, // 封面图本地路径
thumbnail: false
})
}
}, 500);
// 关闭小窗(浮动窗)播放模式
this.data.TCSuperPlayer.closeFenestrulePlay();
this.data.TCSuperPlayer.addFenestruleListener(function (ret) {
console.log('小窗:' + JSON.stringify(ret));
});
this.data.TCSuperPlayer.addPlayerListener(function (ret) {
console.log('播放器事件:' + JSON.stringify(ret))
if (ret.eventType == 'fullScreenChanged') {
let userAgent = navigator.userAgent
if (userAgent.includes('Android')) {
console.log('安卓手机')
this.data.is_full = !this.data.is_full;
}
console.log('是否全屏:' + JSON.stringify(this.data.is_full));
if (this.data.is_full) {
api.setScreenOrientation({ orientation: "landscape_left" }); // 设置横屏
// 设置进入全屏
api.setFullScreen({
fullScreen: true
});
this.data.video_height = api.winWidth; // 把屏幕宽度赋值给视频的高度
this.data.safe_top = 0; // 安全区域设置为0px
} else {
api.setScreenOrientation({ orientation: "portrait_up" }); //竖屏时,屏幕在home键的上面
this.data.safe_top = api.safeArea.top; // 设置区域
this.data.video_height = 250; // 设置视频高度
}
} else if (ret.eventType == 'back') { // 触发返回事件
if (this.data.winHeight == api.winHeight) {
// 竖屏,调用返回上一页函数
this.back();
}
} else if (ret.eventType == 'didStart') { // didStart:播放开始通知
console.log('播放开始通知');
if (1 == this.data.is_start_play) {
this.data.is_start_play = 0;
// 暂停播放
this.data.TCSuperPlayer.pausePlayer();
}
}
}.bind(this));
|
-
|