Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP:fix:yuv-canvas v1.2.9 webgl 坐标计算错误 #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Player extends BaseClass {
autoPlay = true
duration = 0
tsNumber = 0
useWebGl = false
/**
* @property {string} sourceURL - The url of the video to play
* @property {string} source - The url of the video to play
Expand All @@ -85,6 +86,7 @@ class Player extends BaseClass {
* @property {AlertError} alertError - The alert info when error happens
* @property {Worker} httpWorker - set User's web worker
* @property {Function} afterLoadPlaylist - To handle operations after playlist is loaded
* @property {Boolean} useWebGl - If use yuv-canvas webGl to drawFrame
*/
constructor (el, options = {}) {
super()
Expand All @@ -106,6 +108,7 @@ class Player extends BaseClass {
this.startTime = options.startTime === undefined ? this.startTime : options.startTime
this.originStartTime = this.startTime
this.playbackRate = options.playbackRate === undefined ? this.playbackRate : options.playbackRate
this.useWebGl = options.useWebGl === undefined ? this.useWebGl : options.useWebGl
}
setAlertError () {
this.options.alertError = this.alertError = AlertError.getInstance({
Expand Down
7 changes: 4 additions & 3 deletions src/imageplayer/Screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,21 @@ export default class Screen extends BaseClass {
}

setRender(canvas) {
this.render = yuvCanvas.attach(canvas || this.canvas)
const realCanvas = canvas || this.canvas
this.render = yuvCanvas.attach(realCanvas, { webGL: realCanvas.useWebGl })
}

clear() {
this.render.clear()
}
drawFrame(data) {
let st = Date.now()
let { buf_y, buf_u, buf_v, width, height, stride_y, stride_u, stride_v} = data
let { buf_y, buf_u, buf_v, width, height, stride_y, stride_u, stride_v } = data
let y, u, v, format, frameDisplay
let width_y = width
let height_y = height
let width_u = width_y / 2
let height_u = height_y /2
let height_u = height_y / 2
y = {
bytes: buf_y,
stride: stride_y
Expand Down
1 change: 1 addition & 0 deletions src/utils/PlayerUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class PlayerUtil {
$ele.classList.add(cssName.screenCanvas)
$ele.width = player.options.screenWidth || player.screenWidth
$ele.height = player.options.screenHeight || player.screenHeight
$ele.useWebGl = player.options.useWebGl || player.useWebGl
return $ele
}

Expand Down