mafintosh/chromecasts

TypeError: cannot read property mediaSessionId of null

Closed this issue · 2 comments

Running this code:

var chromecasts = require('chromecasts')()

var file_url = 'http://......';

chromecasts.on('update', function (player) {
  console.log('all players: ', chromecasts.players)
  player.play(file_url, {title: 'my video', type: 'video/mp4'})
  // pause if after 5 seconds.
  setTimeout(function(){player.pause();}, 5000);
})

Raises a TypeError:

/node_modules/castv2-client/lib/controllers/media.js:88
  data.mediaSessionId = this.currentSession.mediaSessionId;
                                           ^

TypeError: Cannot read property 'mediaSessionId' of null

This happens when the chromecast socket times out, I've dug deep into this:
thibauts/node-castv2-client#44

I think the best approach is to close this issue and move the discussion to node-castv2-client