Panorama video viewer (copied from viewer)#57
Conversation
| _initCameraControls() { | ||
| const canvas = this.canvasElement; | ||
| const DRAG_SENS = 0.003; | ||
|
|
There was a problem hiding this comment.
Since this method wires itself into the permanent root window, we need to clean this up properly. Nothing calls back into the YUVCanvas/YUV360Canvas to detach its listeners
Store the bound handler refs to an array so they can be easily destroyed later:
this._domListeners = [];
const add = (target, type, handler, options) => {
target.addEventListener(type, handler, options);
this._domListeners.push({ target, type, handler, options });
};
then below we can use add() instead of addEventListener() for each instance:
e.g.
add(canvas, 'mousedown', (e) => onDragStart(e.clientX, e.clientY));
add(window, 'mousemove', (e) => onDragMove(e.clientX, e.clientY));
add(window, 'mouseup', onDragEnd);
| canvas.addEventListener('touchend', () => { lastPinchDist = null; }); | ||
| canvas.addEventListener('touchcancel', () => { lastPinchDist = null; }); | ||
| } | ||
|
|
There was a problem hiding this comment.
Add a dispose() method to be called in FFMPEG360View:
dispose() {
if (this._domListeners) {
for (const { target, type, handler, options } of this._domListeners) {
target.removeEventListener(type, handler, options);
}
this._domListeners = [];
}
const gl = this.contextGL;
if (gl) {
gl.getExtension('WEBGL_lose_context')?.loseContext();
this.contextGL = null;
}
}
| if (this.yuvCanvas) this.canvas360.setProjection(projection); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Add destroy() override so the existing VideoView.destroy() -> FFMPEGView.destroy() teardown chain reaches the 360canvas:
destroy() {
this.canvas360?.dispose();
super.destroy();
}
|
|
||
| createVideoView(compression) { | ||
| if(compression === 'jpeg') { | ||
| if (this.props360 != null) { |
There was a problem hiding this comment.
since we dont have a view that handles 360 mjpeg maybe the handling here should read:
--> if (this.props360 != null && compression !== 'jpeg') {
this.videoView = new FFMPEG360View({
...this.properties,
codec: compression,
layers: []
});
} else if(compression === 'jpeg') {
--> if (this.props360 != null) {
console.warn('VideoView: 360 display is not supported for MJPEG streams; falling back to standard MjpegView.');
}
// create MJPEG View
this.videoView = new MjpegView({
...this.properties,
layers: []
});
Cardy2
left a comment
There was a problem hiding this comment.
Looks good. Mostly small fixes and need to add some cleanup detaching the event listeners in 360Canvas
Same changes from OSH-Viewer: Botts-Innovative-Research/osh-viewer#284