mafintosh / chromecasts

Query your local network for Chromecasts and have them play media
MIT License
1.45k stars 68 forks source link

TypeError: cannot read property mediaSessionId of null #23

Closed roccomuso closed 8 years ago

roccomuso commented 8 years ago

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
Ivshti commented 8 years ago

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

Ivshti commented 8 years ago

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