videogular / videogular2

The HTML5 video player for Angular 2
https://videogular.github.io/videogular2-showroom/#/
MIT License
670 stars 211 forks source link

TypeError: Cannot read property 'unsubscribe' of undefined #888

Open g-hamilton opened 4 years ago

g-hamilton commented 4 years ago

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

  1. As listed here: https://github.com/videogular/videogular2/issues/653

Attachments

Follow steps above to see error.

leojkwan commented 3 years ago

same issue

leojkwan commented 3 years ago

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