Merge branch 'dev-yxl' of gitee.com:zongzhige/shopxo-uniapp into dev
commit
076c44b395
|
|
@ -339,18 +339,8 @@
|
|||
// 尝试自动播放视频
|
||||
attemptAutoPlay(videoElement, isMuted) {
|
||||
const playPromise = videoElement.play();
|
||||
uni.showToast({
|
||||
title: '开始尝试播放' + playPromise,
|
||||
icon: 'success',
|
||||
mask: true
|
||||
})
|
||||
if (playPromise !== undefined) {
|
||||
playPromise.then(() => {
|
||||
uni.showToast({
|
||||
title: '播放成功' + videoElement.muted,
|
||||
icon: 'success',
|
||||
mask: true
|
||||
})
|
||||
// 自动播放成功
|
||||
this.autoplayRejected = false;
|
||||
// 通知父组件静音播放成功
|
||||
|
|
@ -360,11 +350,6 @@
|
|||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
uni.showToast({
|
||||
title: '播放失败' + videoElement.muted,
|
||||
icon: 'error',
|
||||
mask: true
|
||||
})
|
||||
// 自动播放被拒绝
|
||||
this.autoplayRejected = true;
|
||||
// 通知父组件静音播放成功
|
||||
|
|
@ -650,10 +635,6 @@
|
|||
this.videoEl.controls = controls
|
||||
this.videoEl.muted = muted
|
||||
this.videoEl.playbackRate = playbackRate
|
||||
uni.showToast({
|
||||
title: this.autoplayRejected && autoplay ? '自动播放失败,请手动播放' : '自动播放成功',
|
||||
icon: 'none'
|
||||
});
|
||||
// 如果更改了静音状态且之前自动播放被拒绝,重新尝试播放
|
||||
if (this.autoplayRejected && autoplay) {
|
||||
this.attemptAutoPlay(this.videoEl, muted);
|
||||
|
|
|
|||
|
|
@ -153,13 +153,9 @@
|
|||
*/
|
||||
// 网页有的时候直接访问会报错,所以这里需要判断一下,如果报错则静音播放,静音播放成功添加提示,用户操作之后改为非静音播放
|
||||
// 静音自动播放成功, 触发事件, 添加提示弹出框,用户操作之后改为非静音播放
|
||||
auto_play_success(e) {
|
||||
uni.showToast({
|
||||
title: this.muted ? '静音播放成功' : '非静音播放成功',
|
||||
icon: 'none'
|
||||
});
|
||||
auto_play_success() {
|
||||
// 静音播放成功时,触发事件,提示用户需要修改点击修改播放状态
|
||||
if (e) {
|
||||
if (this.muted) {
|
||||
this.$emit('mutedAutoPlaySuccess', this.muted);
|
||||
}
|
||||
},
|
||||
|
|
@ -170,20 +166,12 @@
|
|||
* @param {Boolean} e - 是否自动播放失败
|
||||
*/
|
||||
// 自动播放失败, 静音播放
|
||||
auto_play_error(e) {
|
||||
// 播放失败,并且是非静音状态,则静音播放尝试是否成功
|
||||
if (!e) {
|
||||
console.log(this.muted);
|
||||
uni.showToast({
|
||||
title: this.muted ? '静音播放失败' : '非静音播放失败',
|
||||
icon: 'none'
|
||||
});
|
||||
// 如果是静音播放了,但是还是播放失败
|
||||
if (this.muted) {
|
||||
this.$emit('mutedAutoPlayError');
|
||||
} else {
|
||||
this.muted = true;
|
||||
}
|
||||
auto_play_error() {
|
||||
// 如果是静音播放了,但是还是播放失败
|
||||
if (this.muted) {
|
||||
this.$emit('mutedAutoPlayError');
|
||||
} else {
|
||||
this.muted = true;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -65,19 +65,11 @@
|
|||
},
|
||||
methods: {
|
||||
muted_auto_play_success(is_muted) {
|
||||
uni.showToast({
|
||||
title: this.is_muted ? '静音播放成功' : '222225',
|
||||
icon: 'none'
|
||||
});
|
||||
if (is_muted) {
|
||||
this.is_muted_auto_play_success = true;
|
||||
}
|
||||
},
|
||||
muted_auto_play_error() {
|
||||
uni.showToast({
|
||||
title: '显示图标提示',
|
||||
icon: 'none'
|
||||
});
|
||||
this.is_muted_auto_play_error = true;
|
||||
},
|
||||
// 静音提示点击
|
||||
|
|
|
|||
Loading…
Reference in New Issue