Skip to content

Commit

Permalink
fix(xgplayer): support changing UI when setting muted or playbackrate…
Browse files Browse the repository at this point in the history
… value
  • Loading branch information
zhangxin92 committed Nov 14, 2021
1 parent ed0b775 commit 0694541
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 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.

4 changes: 2 additions & 2 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.

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/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.

4 changes: 2 additions & 2 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.

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.

2 changes: 1 addition & 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.

6 changes: 3 additions & 3 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.

2 changes: 1 addition & 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.

2 changes: 1 addition & 1 deletion packages/xgplayer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xgplayer",
"version": "2.31.1",
"version": "2.31.2",
"description": "video player",
"main": "./dist/index.js",
"typings": "./types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer/src/controls/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ let volume = function () {
removeClass(root, 'xgplayer-volume-muted')
removeClass(root, 'xgplayer-volume-small')
removeClass(root, 'xgplayer-volume-large')
if (player.volume === 0) {
if (player.volume === 0 || player.muted) {
addClass(root, 'xgplayer-volume-muted')
} else if (player.volume < 0.5) {
addClass(root, 'xgplayer-volume-small')
Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Proxy {
}

this.ev = ['play', 'playing', 'pause', 'ended', 'error', 'seeking', 'seeked', 'progress',
'timeupdate', 'waiting', 'canplay', 'canplaythrough', 'durationchange', 'volumechange', 'loadedmetadata', 'loadeddata', 'loadstart'
'timeupdate', 'waiting', 'canplay', 'canplaythrough', 'durationchange', 'volumechange', 'ratechange', 'loadedmetadata', 'loadeddata', 'loadstart'
].map((item) => {
return {
[item]: `on${item.charAt(0).toUpperCase()}${item.slice(1)}`
Expand Down
6 changes: 5 additions & 1 deletion packages/xgplayer/src/skin/controls/playbackRate.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,15 @@ let s_playbackRate = function () {
player.switchPlaybackRate = function (playbackRateObj = {}) {
let liList = player.controls.querySelectorAll('.xgplayer-playbackrate ul li')
for(let i = 0; i < liList.length; i++) {
if(liList[i].getAttribute('cname') === `${playbackRateObj.playbackRate}` || i === playbackRateObj.index) {
if(!hasClass(liList[i], 'selected') && (liList[i].getAttribute('cname') === `${playbackRateObj.playbackRate}` || i === playbackRateObj.index)) {
liList[i].click()
}
}
}

player.on('ratechange', () => {
player.switchPlaybackRate({ playbackRate: player.playbackRate })
})
}

export default {
Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2.31.1"
"version": "2.31.2"
}

0 comments on commit 0694541

Please sign in to comment.