Skip to content

Commit

Permalink
增加 pauseMedia 的 api,可用于暂停媒体播放 #317
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-yufeng committed Jan 25, 2022
1 parent 530f219 commit 1f2268a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/miniprogram/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ Component({
})
},

/**
* @description 暂停播放媒体
*/
pauseMedia () {
for (let i = (this._videos || []).length; i--;) {
this._videos[i].pause()
}
},

/**
* @description 设置富文本内容
* @param {string} content 要渲染的 html 字符串
Expand Down
18 changes: 18 additions & 0 deletions src/uni-app/components/mp-html/mp-html.vue
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ export default {
})
},
/**
* @description 暂停播放媒体
*/
pauseMedia () {
for (let i = (this._videos || []).length; i--;) {
this._videos[i].pause()
}
// #ifdef APP-PLUS
const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].pause()'
// #ifndef APP-PLUS-NVUE
this.$mp.page.$getAppWebview().evalJS(command)
// #endif
// #ifdef APP-PLUS-NVUE
this.$refs.web.evalJs(command)
// #endif
// #endif
},
/**
* @description 设置内容
* @param {String} content html 内容
Expand Down

0 comments on commit 1f2268a

Please sign in to comment.