Skip to content

Commit

Permalink
Merge pull request bytedance#129 from bytedance/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
zhangxin92 authored Dec 3, 2018
2 parents 99243b0 + a260166 commit 8b92777
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/xgplayer-logger/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "xgplayer-logger",
"version": "1.1.3",
"description": "视频监控",
"version": "1.1.4-beta",
"description": "video player logger",
"main": "./dist/index.js",
"directories": {
"doc": "docs"
Expand Down
4 changes: 2 additions & 2 deletions packages/xgplayer/browser/index.js

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/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "xgplayer",
"version": "1.1.4-beta.4",
"version": "1.1.4-beta.7",
"description": "video player",
"main": "./dist/index.js",
"scripts": {
Expand Down
22 changes: 18 additions & 4 deletions packages/xgplayer/src/control/makeBullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Channel {
}, 10)
}
addBullet (bullet) {
let player = this.player
let left = this.width
let channels = this.channels
let channelHeight = this.channelHeight
Expand All @@ -91,9 +92,22 @@ class Channel {
flag = true
for (let j = i; j < i + occupy; j++) {
channel = channels[j]
if (channel.step < bullet.step || channel.surplus < 0) {
flag = false
break
let curBullet = channel.queue[0]
if (curBullet) {
if (curBullet.el.getBoundingClientRect().right > curBullet.playerPos.right) {
flag = false
break
}
let curS = curBullet.el.getBoundingClientRect().left - curBullet.playerPos.left + curBullet.el.getBoundingClientRect().width
let curV = curBullet.playerPos.width / curBullet.duration
let curT = curS / curV
if (!player.config.bOffset) {
player.config.bOffset = 0
}
if (curT + player.config.bOffset > bullet.duration) {
flag = false
break
}
}
}
if (flag) {
Expand Down Expand Up @@ -225,7 +239,7 @@ class Bullet {
let el = document.createElement('div')
el.textContent = options.txt
el.style.color = options.color
el.style.fontSize = `${options.scale}em`
el.style.fontSize = `${20 * options.scale}px`
this.el = el
this.width = options.width
this.height = options.height
Expand Down
37 changes: 22 additions & 15 deletions packages/xgplayer/src/control/rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,29 @@ const rotate = function () {
let root = player.root
root.appendChild(btn)
let rotateDeg = 0
btn.addEventListener('click', function () {
let width = player.root.offsetWidth
let height = player.root.offsetHeight
player.root.style.width = height + 'px'
player.root.style.height = width + 'px'
rotateDeg = (rotateDeg + 0.25) % 1
let scale
if (rotateDeg === 0.25 || rotateDeg === 0.75) {
scale = (width / height).toFixed(2)
} else {
scale = 1
if (!player.rotate) {
player.rotate = function () {
let width = player.root.offsetWidth
let height = player.root.offsetHeight
player.root.style.width = height + 'px'
player.root.style.height = width + 'px'
rotateDeg = (rotateDeg + 0.25) % 1
let scale
if (rotateDeg === 0.25 || rotateDeg === 0.75) {
if (width >= height) {
scale = (width / height).toFixed(2)
} else {
scale = (height / width).toFixed(2)
}
} else {
scale = 1
}
player.video.style.transform = `rotate(${rotateDeg}turn) scale(${scale})`
player.video.style.webKitTransform = `rotate(${rotateDeg}turn) scale(${scale})`
player.emit('rotate', rotateDeg * 360)
}
player.video.style.transform = `rotate(${rotateDeg}turn) scale(${scale})`
player.video.style.webKitTransform = `rotate(${rotateDeg}turn) scale(${scale})`
player.emit('rotate', rotateDeg * 360)
})
}
btn.addEventListener('click', player.rotate)
}

Player.install('rotate', rotate)
1 change: 1 addition & 0 deletions packages/xgplayer/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Proxy {
autoplay: options.autoplay,
playsinline: options.playsinline,
'webkit-playsinline': options.playsinline,
'x5-playsinline': options.playsinline,
'x5-video-player-type': options['x5-video-player-type'],
'x5-video-player-fullscreen': options['x5-video-player-fullscreen'],
'x5-video-orientation': options['x5-video-orientation'],
Expand Down

0 comments on commit 8b92777

Please sign in to comment.