Skip to content

Commit

Permalink
fix(xgplayer): fix volume decimal accuracy and rotate method
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangxin92 committed Sep 23, 2019
1 parent 217b1d0 commit 26d6be6
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 19 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/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/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xgplayer",
"version": "2.1.16",
"version": "2.1.17",
"description": "video player",
"main": "./dist/index.js",
"bin": {
Expand Down
18 changes: 4 additions & 14 deletions packages/xgplayer/src/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,31 +484,21 @@ class Player extends Proxy {
if (player.rotateDeg === 0.25 || player.rotateDeg === 0.75) {
if (player.config.rotate.innerRotate) {
if((targetWidth / targetHeight) > (height / width) ) { //旋转后纵向撑满
// console.log('纵向撑满')
let videoWidth = 0
if((targetHeight / targetWidth) > (height / width)) { //旋转前是纵向撑满
videoWidth = height * targetWidth / targetHeight
} else { //旋转前是横向撑满
videoWidth = width
}
if(videoWidth > height) { //缩小
scale = height > width ? width / height : height / width
} else { //放大
scale = height > width ? height / width : width / height
}
scale = height / videoWidth
} else { //旋转后横向撑满
// console.log('横向撑满')
let videoHeight = 0
if((targetHeight / targetWidth) > (height / width)) { //旋转前是纵向撑满
videoHeight = height
} else { //旋转前是横向撑满
videoHeight = width * targetHeight / targetWidth
}
if(videoHeight > width) { //缩小
scale = height > width ? width / height : height / width
} else { //放大
scale = height > width ? height / width : width / height
}
scale = width / videoHeight
}
} else {
if (width >= height) {
Expand Down Expand Up @@ -635,13 +625,13 @@ class Player extends Proxy {
}
if (e && e.keyCode === 40) { // 按 down
if (player.volume - 0.1 >= 0) {
player.volume -= 0.1
player.volume = parseFloat((player.volume - 0.1).toFixed(1))
} else {
player.volume = 0
}
} else if (e && e.keyCode === 38) { // 按 up
if (player.volume + 0.1 <= 1) {
player.volume += 0.1
player.volume = parseFloat((player.volume + 0.1).toFixed(1))
} else {
player.volume = 1
}
Expand Down

0 comments on commit 26d6be6

Please sign in to comment.