Skip to content

Commit

Permalink
fix: pause video on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
WoodNeck committed Oct 18, 2021
1 parent 6cc4d7f commit e2f0ee3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"prepush": "npm run lint",
"commitmsg": "node config/validate-commit-msg.js",
"changelog": "node config/changelog.js"
"changelog": "node config/changelog.js",
"packages": "npm run packages:update && npm run packages:build && npm run packages:publish",
"packages:update": "pvu --update=react-view360,ngx-view360/projects/ngx-view360,vue-view360",
"packages:build": "pvu --build=react-view360,ngx-view360,vue-view360",
"packages:publish": "pvu --publish=react-view360,ngx-view360/dist/ngx-view360,vue-view360"
},
"repository": {
"type": "git",
Expand Down
9 changes: 8 additions & 1 deletion src/PanoViewer/PanoViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,14 @@ class PanoViewer extends Component<PanoViewerEvent> {
}

if (image) {
this._deactivate();

this._image = image as HTMLImageElement;
this._isVideo = isVideo;
this._projectionType = param.projectionType || PROJECTION_TYPE.EQUIRECTANGULAR;
this._cubemapConfig = cubemapConfig;
this._stereoFormat = stereoFormat;

this._deactivate();
this._initRenderer(this._yaw, this._pitch, this._fov, this._projectionType, this._cubemapConfig);
}

Expand Down Expand Up @@ -990,6 +991,12 @@ class PanoViewer extends Component<PanoViewerEvent> {
* Destroy webgl context and block user interaction and stop rendering
*/
private _deactivate() {
// Turn off the video if it has one
const video = this.getVideo();
if (video) {
video.pause();
}

if (this._isReady) {
this._photoSphereRenderer!.stopRender();
this._yawPitchControl!.disable();
Expand Down

0 comments on commit e2f0ee3

Please sign in to comment.