Skip to content

Commit

Permalink
fix: Controls audio when page is switching (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
yenshih authored Jan 7, 2019
1 parent eb1b1a9 commit 5426ff1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mip-audio/mip-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ define(function (require) {
'volume'
];

var CUSTOM_EVENT_SHOW_PAGE = 'show-page'
var CUSTOM_EVENT_HIDE_PAGE = 'hide-page'

customElement.prototype.firstInviewCallback = function () {
var ele = this.element;
// 防止重复渲染
Expand Down Expand Up @@ -110,6 +113,9 @@ define(function (require) {
this.container.appendChild(this.customControls);
}

window.addEventListener(CUSTOM_EVENT_SHOW_PAGE, this.audioElement.load.bind(this.audioElement))
window.addEventListener(CUSTOM_EVENT_HIDE_PAGE, this._playOrPause.bind(this, 'pause'))

// 事件绑定:获取总播放时长,更新DOM
// FIXME: 由于ios10手机百度不执行loadedmetadata函数,
// 魅族自带浏览器在播放前获取总播放时长为0.需要修改
Expand Down

0 comments on commit 5426ff1

Please sign in to comment.