brightcove / player-loader

An asynchronous script loader and embed generator for the Brightcove Player.
Other
28 stars 15 forks source link

How to reload player with new videoId #69

Open 9thstudio opened 4 years ago

9thstudio commented 4 years ago

I am loading player in angular app with couple of links to load another video on same page when clicked as below code. It works fine when on first video but when user click another link the second video never load.

loadVidPlayer(vidId){
    brightcovePlayerLoader({
      refNode: this.vidFrame.nativeElement,
      accountId: 'xxxxx',
      videoId: vidId,
      playerId: 'xxxx',
      embedId: 'default',
      options: {
        aspectRatio: '16:9'
      },
      onSuccess: (success) => {
        success.ref.play();
        brightcovePlayerLoader.reset();
      },
      onFailure: (error) => {
        // Player creation failed!
      }
    });
  }

Above function is called on different links with new videoId Also I get below error on brightcovePlayerLoader.reset();

core.js:4197 ERROR TypeError: Cannot read property 'parentNode' of null
    at ye (index.min.js:1)
    at n.e [as trigger] (index.min.js:1)
    at e (index.min.js:1)
    at Object.callback (index.min.js:1)
    at i (index.min.js:1)
    at XMLHttpRequest.s [as __zone_symbol__ON_PROPERTYload] (index.min.js:1)
    at XMLHttpRequest.wrapFn (zone.js:1270)
    at ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:27425)
    at ZoneDelegate.invokeTask (zone.js:420)