Skip to content

Commit

Permalink
fix ios trigger twice seeking event
Browse files Browse the repository at this point in the history
  • Loading branch information
刘立国 committed Mar 30, 2022
1 parent e1ba340 commit 1e25f5a
Show file tree
Hide file tree
Showing 30 changed files with 27,171 additions and 17,025 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"cz": "git cz",
"precz": "lint-staged",
"remove": "lerna run clean",
"clean": "lerna clean"
"clean": "lerna clean",
"build:player": "lerna run build --scope=xgplayer --stream",
"watch:player": "lerna run watch --scope=xgplayer --stream"
},
"repository": {
"type": "git",
Expand Down
12,881 changes: 12,879 additions & 2 deletions packages/xgplayer-flv.js/browser/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/xgplayer-flv.js/browser/index.js.map

Large diffs are not rendered by default.

20,949 changes: 10,583 additions & 10,366 deletions packages/xgplayer-flv.js/dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer-flv.js/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const client = {
library: 'FlvJsPlayer',
libraryTarget: 'window'
},
devtool: 'inline-source-map',
devtool: 'source-map',
module: {
rules: [{
test: /\.js$/,
Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer-mp4/browser/index.js

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion packages/xgplayer-shaka/browser/index.js

Large diffs are not rendered by default.

6,640 changes: 25 additions & 6,615 deletions packages/xgplayer-shaka/dist/index.js

Large diffs are not rendered by default.

190 changes: 189 additions & 1 deletion packages/xgplayer/browser/core_player.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

702 changes: 697 additions & 5 deletions 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.

322 changes: 321 additions & 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.

190 changes: 189 additions & 1 deletion packages/xgplayer/dist/core_player.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

702 changes: 697 additions & 5 deletions 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.

322 changes: 321 additions & 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.

190 changes: 189 additions & 1 deletion packages/xgplayer/es/core_player.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/xgplayer/es/core_player.js.map

Large diffs are not rendered by default.

702 changes: 697 additions & 5 deletions packages/xgplayer/es/index.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

322 changes: 321 additions & 1 deletion packages/xgplayer/es/simple_player.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/xgplayer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"release:stable": "npm version patch && npm publish --registry=https://registry.npmjs.org",
"release:alpha": "npm version prerelease --preid=alpha && npm publish --tag xgplayer-2-alpha --registry=https://registry.npmjs.org",
"release:alpha-test": "npm publish --tag alpha-test-2x --registry=https://registry.npmjs.org"

},
"keywords": [
"video",
Expand Down
5 changes: 4 additions & 1 deletion packages/xgplayer/src/controls/memoryPlay.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
let memoryPlay = function () {
let player = this
player.on('memoryPlayStart', (lastPlayTime) => {
player.currentTime = lastPlayTime
setTimeout(() => {
console.log('memoryPlayStart', lastPlayTime, player.readyState, 11)
player.currentTime = lastPlayTime
},)
})
}

Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer/src/skin/controls/memoryPlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let s_memoryPlay = function () {
}, lastPlayTimeHideDelay * 1000)
}
}
player.once('play', handlePlay)
player.once('playing', handlePlay)
player.once('ended', removeFunc)
}

Expand Down
23 changes: 17 additions & 6 deletions packages/xgplayer/src/skin/controls/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ let s_progress = function () {
player.config.enableSwipeHandler.call(player);
});
};

['touchstart', 'mousedown'].forEach(item => {
let events = ['touchstart', 'mousedown'];
if (sniffer.device === 'mobile') {
// 解决在移动端触发多次seeking问题
events.pop()
}
events.forEach(item => {
container.addEventListener(item, function (e) {
if (player.config.disableProgress) return;
// e.preventDefault()
Expand Down Expand Up @@ -205,6 +209,7 @@ let s_progress = function () {
progress.style.width = `${w * 100 / containerWidth}%`

if (player.videoConfig.mediaType === 'video' && !player.dash && !player.config.closeMoveSeek) {
console.log('trigger touchmove')
player.currentTime = Number(now).toFixed(1)
} else {
let time = findDom(player.controls, '.xgplayer-time')
Expand All @@ -230,6 +235,7 @@ let s_progress = function () {
player.emit('focus')
}
let up = function (e) {
console.log('up event', e)
// e.preventDefault()
e.stopPropagation()
event(e)
Expand All @@ -250,6 +256,7 @@ let s_progress = function () {
if(player.config.allowSeekPlayed && (Number(now).toFixed(1) > player.maxPlayedTime)) {}
else {
progress.style.width = `${w * 100 / containerWidth}%`
console.warn('trigger touchup')
player.currentTime = Number(now).toFixed(1)
}
}
Expand All @@ -259,10 +266,14 @@ let s_progress = function () {
player.emit('focus')
player.isProgressMoving = false
}
window.addEventListener('mousemove', move)
window.addEventListener('touchmove', move, { passive: false })
window.addEventListener('mouseup', up)
window.addEventListener('touchend', up)
// if (item === 'touchstart') {
window.addEventListener('touchmove', move, { passive: false })
window.addEventListener('touchend', up)
// } else {
window.addEventListener('mousemove', move)
// console.warn('add envent mouseup')
window.addEventListener('mouseup', up)
// }
return true
})
})
Expand Down

0 comments on commit 1e25f5a

Please sign in to comment.