Cannot read property 'getRemotePlayer' of undefined
Opened this issue · 3 comments
ChromecastTech.js?ed59:48 Uncaught TypeError: Cannot read property 'getRemotePlayer' of undefined
at new constructor (ChromecastTech.js?ed59:48)
at Player.loadTech_ (video.es.js?f0e2:21766)
at Player.src_ (video.es.js?f0e2:24078)
at eval (video.es.js?f0e2:24025)
at setSourceHelper (video.es.js?f0e2:9744)
at eval (video.es.js?f0e2:9739)
at Object.setSource (videojs-contrib-ads.es.js?f9ad:748)
at setSourceHelper (video.es.js?f0e2:9728)
at setSourceHelper (video.es.js?f0e2:9746)
at Player.eval (video.es.js?f0e2:9485)
@anhminh10a2hoa Did you manage to fix this ?
I am having the same issue.
Did you manage to fix it? I'm having the same problem when changing the video in a single page app.
the code failing is this._remotePlayer = this._chromecastSessionManager.getRemotePlayer();
and it's caused because of a dispose of the player necessary to change the video and at the point this code is executed _chromecastSessionManager is undefined
Here is workaround that works for me:
player.on('dispose', () => {
const castSession = player.chromecastSessionManager?.getCastContext()?.getCurrentSession();
if (castSession) castSession.endSession(true);
})