-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(FEC-8046): 360 Support #1
Conversation
src/vr.js
Outdated
*/ | ||
_addBindings(): void { | ||
this.eventManager.listen(this.player, this.player.Event.SOURCE_SELECTED, () => { | ||
if (this.player.is360()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be source attribute, not player
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do it as player we should abstract it more and get change name to VR as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrenMe what do u mean 'abstract it more'?
src/vr.js
Outdated
this.eventManager.listen( | ||
this.player, | ||
this.player.Event.FIRST_PLAY, | ||
this._initComponents.bind(this) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use () => ...
as the eventManager saves reference internally to callbacks and we call destroy
on event manager which clears them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
_appendCanvasOverlayAction(): void { | ||
this._canvasOverlayAction = document.createElement('div'); | ||
this._canvasOverlayAction.id = CANVAS_360_OVERLAY_ID; | ||
this.player.getView().appendChild(this._canvasOverlayAction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use playkit-js utils for DOM manipulation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all of above actions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't we say this will be abstracted away form the plugin and managed as an API? with the controller interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
this._renderer = new THREE.WebGLRenderer(); | ||
this._canvas = this._renderer.domElement; | ||
Utils.Dom.addClassName(this._canvas, CANVAS_360_CLASS); | ||
this.player.getView().insertBefore(this._canvas, videoElement.nextSibling); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use playkit-js utils for DOM manipulation, add method if missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
this._scene = new THREE.Scene(); | ||
this._scene.add(sphere); | ||
|
||
// this.effect = new THREE.StereoEffect(this._renderer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
* @returns {void} | ||
*/ | ||
destroy(): void { | ||
this.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit strange that on destroy
we call reset
which in turn calls _initMembers
and _addBindings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yairans please comment to this.
on destroy you don't want to re-register the source selected event
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
* @returns {void} | ||
*/ | ||
reset(): void { | ||
this.player.getView().removeChild(this._canvas); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use playkit-js utils removeChild
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
*/ | ||
reset(): void { | ||
this.player.getView().removeChild(this._canvas); | ||
this._canvasOverlayAction.parentNode.removeChild(this._canvasOverlayAction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here on removeChild
src/vr.js
Outdated
}); | ||
this.eventManager.listen(window, 'mouseup', this._onDocumentPointerUp.bind(this)); | ||
this.eventManager.listen(window, 'touchend', this._onDocumentPointerUp.bind(this)); | ||
this.eventManager.listen(window, 'devicemotion', this._onDeviceMotion.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check for support before registering window.DeviceMotionEvent
Ref: https://developers.google.com/web/fundamentals/native-hardware/device-orientation/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
this.eventManager.listen(window, 'mouseup', this._onDocumentPointerUp.bind(this)); | ||
this.eventManager.listen(window, 'touchend', this._onDocumentPointerUp.bind(this)); | ||
this.eventManager.listen(window, 'devicemotion', this._onDeviceMotion.bind(this)); | ||
this.eventManager.listen(window, 'deviceorientation', this._onMobileOrientation.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can check for support before registering window.DeviceOrientationEvent
Ref: https://developers.google.com/web/fundamentals/native-hardware/device-orientation/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this method even exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
src/index.js
Outdated
declare var __VERSION__: string; | ||
declare var __NAME__: string; | ||
|
||
export default Vr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz use our new conventions
- No default exports
- Export plugin class as Plugin
export {Vr as Plugin}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/style.css
Outdated
height: 100%; | ||
} | ||
|
||
.indicator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add playkit-
prefix to all classes to avoid collisions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
irrelevant
src/vr.js
Outdated
* Your class description. | ||
* @classdesc | ||
*/ | ||
export default class Vr extends BasePlugin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use new conventions without default export
class Vr { .. }
export {Vr};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please follow @dan-ziv 's comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
if (this.player.is360()) { | ||
this.logger.debug('360 entry has detected'); | ||
this._appendCanvasOverlayAction(); | ||
this.eventManager.listen(this.player, this.player.Event.FIRST_PLAY, this._initComponents.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use arrow function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
webpack.config.js
Outdated
output: { | ||
path: __dirname + '/dist', | ||
filename: '[name].js', | ||
library: ['playkit', 'vr'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
library: ['playkit', 'plugins', 'vr'],
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
if (this.player.env.browser.name === 'IE') { | ||
// a workaround for ie11 texture issue | ||
// see https://github.com/mrdoob/three.js/issues/7560 | ||
const ctx2d = document.createElement('canvas').getContext('2d'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use playkit utils for DOM manipulation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, you don't seem to destroy/remove it anywhere
and give it an id...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OrenMe this element not attached to the dom but used by THREE.Texture
src/vr.js
Outdated
* Your class description. | ||
* @classdesc | ||
*/ | ||
export default class Vr extends BasePlugin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please follow @dan-ziv 's comment
clearColor: 0xffffff, | ||
antialias: true | ||
}); | ||
const canvas = this._renderer.domElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't see this gets removed from DOM on cleanup anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, now I see you do....
src/vr.js
Outdated
* @returns {boolean} - Whether the plugin is valid. | ||
*/ | ||
static isValid(): boolean { | ||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this always valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
src/vr.js
Outdated
* @returns {void} | ||
*/ | ||
destroy(): void { | ||
this.reset(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yairans please comment to this.
on destroy you don't want to re-register the source selected event
src/vr.js
Outdated
} | ||
} | ||
|
||
_getCanvasDimensions(): Object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe define the dimensions
object?
type dimensions = {
width: number,
height: number
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
this._texture.render(videoElement); | ||
} | ||
} | ||
this._requestId = requestAnimationFrame(this._render.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use some abbreviation - it is usually referred to as RAF so you can change to rafId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
} | ||
|
||
_onPlay(): void { | ||
if (!this._requestId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this condition is not clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a comment has been added
src/vr.js
Outdated
|
||
toggleStereoMode(): void { | ||
this._stereoMode = !this._stereoMode; | ||
this._updateCanvasSize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if this will be externlized as API need to add protection if plugin is active and able to go to stereo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_updateCanvasSize
is already protected
} | ||
|
||
_updateCanvasSize(): void { | ||
if (this._renderer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any way the renderer can be not defined when calling this?
The only place I see this happening is when calling toggleStereoMode
and there is where you need to add protection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flow
requires this protection
src/vr.js
Outdated
this.eventManager.listen(this.player, this.player.Event.ENDED, this._cancelAnimationFrame.bind(this)); | ||
this.eventManager.listen(this.player, this.player.Event.PLAY, this._onPlay.bind(this)); | ||
this.eventManager.listen(this.player, this.player.Event.PLAYING, this._onPlaying.bind(this)); | ||
this.eventManager.listen(window, 'resize', () => this._updateCanvasSize()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't you need to add fullscreen event listener as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullscreen fires resize
src/vr.js
Outdated
* @returns {void} | ||
*/ | ||
_initComponents(): void { | ||
this.logger.debug('Init 360 components'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init VR components :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
* @type {string} | ||
* @const | ||
*/ | ||
const CANVAS_360_CLASS: string = 'playkit-360-canvas'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CANVAS_VR_CLASS, playkit-vr-canvas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/vr.js
Outdated
import './style.css'; | ||
|
||
/** | ||
* The 360 canvas class. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VR
dependes on:
kaltura/playkit-js-providers#55
kaltura/kaltura-player-js#130
kaltura/playkit-js#239
kaltura/playkit-js-ui#242