-
Notifications
You must be signed in to change notification settings - Fork 213
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
Angular Universal Intergration #653
Comments
I am having the same issue as I am using this library in my project for live streaming but as I did a angular universal build having errors as these
If there is any update, please let me know. |
I made it fixed by replacing the vgMedia.prorotype.ngOnDistroy method in my server.js file with this
Original was this:
|
This worked for me. Thanks. Should this be implemented into videogular2 by default? |
Added isPlatformBrowser for vgMedia, to avoid SSR issues. videogular#653
Description
Angular Universal build with Videogular2 fails at runtime, note:
ng serve
(as per angualr-cli) still works as expected, the error only occurs usingnpm run serve:ssr
(as per angular-universal). Using versions as follows:"@angular/animations": "^5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/platform-server": "^5.0.3", "@angular/router": "^5.0.0", "@nguniversal/module-map-ngfactory-loader": "^5.0.0-beta.5", "@types/core-js": "^0.9.43", "core-js": "^2.4.1", "rxjs": "^5.5.2", "ts-loader": "^3.1.1", "videogular2": "^5.6.3", "zone.js": "^0.8.14"
Expected Behavior
No errors at runtime
Actual Behavior
The following errors are thrown when loading the app in a browser by the Server Side Renderer:
ERROR ReferenceError: window is not defined at VgMedia.ngOnInit (C:\project_root\dist\server.js:36129:57) at checkAndUpdateDirectiveInline (C:\project_root\dist\server.js:12365:19) at checkAndUpdateNodeInline (C:\project_root\dist\server.js:13868:20) at checkAndUpdateNode (C:\project_root\dist\server.js:13811:16) at prodCheckAndUpdateNode (C:\project_root\dist\server.js:14514:5) at Object.updateDirectives (C:\project_root\dist\server.js:132564:20238) at Object.updateDirectives (C:\project_root\dist\server.js:14255:29) at checkAndUpdateView (C:\project_root\dist\server.js:13778:14) at callViewAction (C:\project_root\dist\server.js:14128:21) at execComponentViewsAction (C:\project_root\dist\server.js:14060:13) Unhandled Promise rejection: Cannot read property 'unsubscribe' of undefined ; Zone: <root> ; Task: Promise.then ; Value: { TypeError: Cannot read property 'unsubscribe' of undefined at VgMedia.ngOnDestroy (C:\project_root\dist\server.js:36464:26) at callProviderLifecycles (C:\project_root\dist\server.js:12704:18) at callElementProvidersLifecycles (C:\project_root\dist\server.js:12669:13) at callLifecycleHooksChildrenFirst (C:\project_root\dist\server.js:12653:17) at destroyView (C:\project_root\dist\server.js:13997:5) at callViewAction (C:\project_root\dist\server.js:14148:13) at execComponentViewsAction (C:\project_root\dist\server.js:14060:13) at Object.destroyView (C:\project_root\dist\server.js:13996:5) at ViewRef_.destroy (C:\project_root\dist\server.js:11616:18) at C:\project_root\dist\server.js:6151:67 __zone_symbol__currentTask: ZoneTask { _zone: Zone { _properties: {}, _parent: null, _name: '<root>', _zoneDelegate: [Object] }, runCount: 0, _zoneDelegates: null, _state: 'notScheduled', type: 'microTask', source: 'Promise.then', data: undefined, scheduleFn: undefined, cancelFn: null, callback: [Function], invoke: [Function] } } TypeError: Cannot read property 'unsubscribe' of undefined at VgMedia.ngOnDestroy (C:\project_root\dist\server.js:36464:26) at callProviderLifecycles (C:\project_root\dist\server.js:12704:18) at callElementProvidersLifecycles (C:\project_root\dist\server.js:12669:13) at callLifecycleHooksChildrenFirst (C:\project_root\dist\server.js:12653:17) at destroyView (C:\project_root\dist\server.js:13997:5) at callViewAction (C:\project_root\dist\server.js:14148:13) at execComponentViewsAction (C:\project_root\dist\server.js:14060:13) at Object.destroyView (C:\project_root\dist\server.js:13996:5) at ViewRef_.destroy (C:\project_root\dist\server.js:11616:18) at C:\project_root\dist\server.js:6151:67
Steps to Reproduce
If this is an issue, describe the steps you took to see the issue. If this is a feature, delete this block.
ng new PROJECT_ROOT
"noStrictGenericChecks": true
in tsconfig.json. #637app.component.html-
<vg-player> <video #myMedia [vgMedia]="myMedia" width="auto" controls> <source src="./assets/test-video.mp4" type="video/mp4"> </video> </vg-player>
npm run build:ssr
andnpm run serve:ssr
Attachments
n/a
The text was updated successfully, but these errors were encountered: