Skip to content

Commit

Permalink
fix(xgplayer): android definition set currentTime
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxin92 committed Feb 9, 2021
1 parent b20c0cd commit 8394f60
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/xgplayer/browser/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/browser/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/browser/simple_player.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/browser/simple_player.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/dist/simple_player.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/dist/simple_player.js.map

Large diffs are not rendered by default.

18 changes: 15 additions & 3 deletions packages/xgplayer/src/skin/controls/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ let s_definition = function () {
}
player.on('resourceReady', onResourceReady)

function onCanplayChangeDefinition () {
function onPlayingChangeDefinition () {
player.currentTime = player.curTime
if (!paused) {
let playPromise = player.play()
Expand All @@ -101,6 +101,9 @@ let s_definition = function () {
}
}
};
function onTimeupdateChangeDefinition () {
player.once('timeupdate', onPlayingChangeDefinition)
};
['touchend', 'click'].forEach(item => {
container.addEventListener(item, function (e) {
e.preventDefault()
Expand Down Expand Up @@ -163,7 +166,11 @@ let s_definition = function () {
player.curTime = player.currentTime, paused = player.paused
if (!player.ended) {
player.src = a.href
player.once('canplay', onCanplayChangeDefinition)
if(navigator.userAgent.toLowerCase().indexOf('android') > -1) {
player.once('timeupdate', onTimeupdateChangeDefinition)
} else {
player.once('playing', onPlayingChangeDefinition)
}
}
}
}
Expand Down Expand Up @@ -197,7 +204,12 @@ let s_definition = function () {
function onDestroy () {
player.off('resourceReady', onResourceReady)
player.off('canplay', onCanplayResourceReady)
player.off('canplay', onCanplayChangeDefinition)
if(navigator.userAgent.toLowerCase().indexOf('android') > -1) {
player.off('timeupdate', onTimeupdateChangeDefinition)
player.off('timeupdate', onPlayingChangeDefinition)
} else {
player.off('playing', onPlayingChangeDefinition)
}
player.off('blur', onBlur)
player.off('destroy', onDestroy)
}
Expand Down

0 comments on commit 8394f60

Please sign in to comment.