videogular2
videogular2 copied to clipboard
TypeError: Cannot read property 'unsubscribe' of undefined
Description
I'm getting the error: "TypeError: Cannot read property 'unsubscribe' of undefined" when I refresh a page containing the video player. I'm using Angular 8 Universal (with SSR). I found what I think is a related issue (#653), and that's marked as solved but I'm still getting the error. I've done a workaround using the platform type check and only show the player on the browser, but I'd like search engine bots to be able to index the video if possible.
Expected Behavior
Page should load and refresh with no error.
Actual Behavior
Page loads fine. Video plays fine. If user hits refresh on their browser while on a page containing a video player, the error occurs.
Steps to Reproduce
- As listed here: https://github.com/videogular/videogular2/issues/653
Attachments
Follow steps above to see error.
same issue
workaround is to wrap video player in isPlatformBrowserCheck
:
<div *ngIf="isPlatformBrowser">
<vg-player>
<video [vgMedia]="media" #media id="singleVideo" preload="auto" controls>
<source src="http://static.videogular.com/assets/videos/videogular.mp4" type="video/mp4">
</video>
</vg-player>
</div>
isPlatformBrowser
is a boolean property you store on the component. https://angular.io/api/common/isPlatformBrowser