Giter Site home page Giter Site logo

castv2-player's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

castv2-player's Issues

Crash when there is an error

Whenever there is an error from the _icyConnection it tries to close the connection and failing to be able to call _closeIcyConnection on line 80 of mediaInfo.js, it crashes.

Duplicate Events

I'm using event listeners on MediaPlayer for playerStatus and clientStatus and I am getting duplicate events on these listeners.

From what I can tell, the _playerStatus event listener in persistentPlayer is being invoked twice for each status event. Usually this is due to the event listener being registered more than once but I am having a hard time tracking down where it is happening.

Dean

PersistentClient reconnect should subscribe to 'inner client' 'close' event

It seems that sometimes a Chromecast device will disconnect from a client connected with this module.

There is a section of code in PersistentClient that looks like it is designed to cater for such events here:

https://github.com/angelnu/castv2-player/blob/523fd5a8317656a5038b7a7b3ca9d1de4e89f1a7/lib/persistentClient.js#L252

Ie. looks like PersistentClient is supposed to catch any close events and reconnect.

However, the 'client' in this case is not actually a direct 'client' but the a sender class (PlatformSender), which does not actually emit 'close' events and therefore PersistentClient fails to reconnect as I assume it is designed to do.

This manifests itself as issues such as iobroker-community-adapters/ioBroker.chromecast#36

As noted there, a fix is discussed here: thibauts/node-castv2-client#58 (comment), and indeed changing the line referenced above to use the 'inner client' works for me. Ie. change...

            //If connection closes afterwards then re-open it again
            that._client.once("close", function(){
              that._close();
              that._connectClient();
            });

...should be changed to...

            //If connection closes afterwards then re-open it again
            that._client.client.once("close", function(){
              that._close();
              that._connectClient();
            });

Node crashes on ECONNRESET

I get the following crash in my application:

25 Jan 23:10:29 - [info] [google-cast:Central] Central speaker - Detached player
26 Jan 02:42:51 - [warn] [google-cast:Central] Central speaker - Client error: Error: Device timeout
    at fn.ontimeout (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/senders/platform.js:56:26)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:106:13)
    at fn.emit (events.js:208:7)
    at Timeout.ontimeout [as _onTimeout] (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/controllers/heartbeat.js:44:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)
26 Jan 02:42:51 - [info] [google-cast:Central] Central speaker - client disconnected
26 Jan 02:42:51 - [warn] [google-cast:Central] Central speaker - Client error: Error: Device timeout
    at fn.ontimeout (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/senders/platform.js:56:26)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:106:13)
    at fn.emit (events.js:208:7)
    at Timeout.ontimeout [as _onTimeout] (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/controllers/heartbeat.js:44:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)
26 Jan 02:42:51 - [warn] [google-cast:Central] Central speaker - Client error: Error: Device timeout
    at fn.ontimeout (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/senders/platform.js:56:26)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:106:13)
    at fn.emit (events.js:208:7)
    at Timeout.ontimeout [as _onTimeout] (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/controllers/heartbeat.js:44:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)
26 Jan 02:42:51 - [warn] [google-cast:Central] Central speaker - Client error: Error: Device timeout
    at fn.ontimeout (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/senders/platform.js:56:26)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:106:13)
    at fn.emit (events.js:208:7)
    at Timeout.ontimeout [as _onTimeout] (/data/data/projects/node-red/node-red-contrib-google-cast/node_modules/castv2-client/lib/controllers/heartbeat.js:44:10)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)
26 Jan 02:42:58 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:58 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:58 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:58 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:59 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:59 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:59 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:42:59 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:43:01 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:43:01 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:43:01 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:43:01 - [warn] [google-cast:Central] Central speaker - Client error: Error: connect ECONNREFUSED 192.168.1.15:8009
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
26 Jan 02:43:02 - [red] Uncaught Exception:
26 Jan 02:43:02 - Error: read ECONNRESET
    at _errnoException (util.js:1022:11)
    at TLSWrap.onread (net.js:615:25)

It looks like the exception is slipping through the cracks in _connectClient in persistentClient.js

Pause/resume already playing media

Is there a way to play/pause currently playing media from Spotify for example? :) I've tried the following code, but it throws an error:

ScannerPromise()(/* Name */).then(device => {
    const mediaPlayer = new MediaPlayerClass(device);
    mediaPlayer.pausePromise()
})

Sound only?

When running the example code, I only get sound.

"use strict"
let playerName = ".."; //Change to "catstv2-player to execute outside this folder
var ScannerPromise = require(playerName).ScannerPromise();
var MediaPlayer = require(playerName).MediaPlayer();

let mediaPlayer;

//Find device
return ScannerPromise(/* device name - empty-> take first device found*/)
//Create mediaPlayer
.then (function (device) {
mediaPlayer = new MediaPlayer(device);
return Promise.resolve();
})
//Stop player
.then (function () {
return mediaPlayer.stopClientPromise();
})
//Start playing
.then (function () {
return mediaPlayer.playUrlPromise("http://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/dash/BigBuckBunnyAudio.mp4")
})
//Wait for the player to start playing
.then( function() {
return new Promise(function (resolve, reject) {
mediaPlayer.once(mediaPlayer.EVENT_PLAYER_PLAYING, function(contentId){
console.log("PLAYING: %s", contentId);
resolve();
process.exit(0);
});
});
});

Output:
Scanner - found device Stua2 (Chromecast) at 192.168.1.71:8009
MediaPlayer - New device Stua2 at 192.168.1.71:8009
PersistentClient - Stua2 - Waiting up to 10000 seconds for connection to chromecast
PersistentClient - Stua2 - Connected client
PersistentClient - Stua2 - Connected client
PersistentPlayer - Stua2 - Try to join player
PersistentClient - Stua2 - Trying to stop client
PersistentPlayer - Stua2 - Connected player
PersistentPlayer - Stua2 - Player joint
PersistentClient - Stua2 - stopped client
PersistentPlayer - Stua2 - client disconnected
PersistentPlayer - Stua2 - Detached player
PersistentPlayer - Stua2 - Try to play url - http://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/dash/BigBuckBunnyAudio.mp4
PersistentPlayer - Stua2 - Try to launch default player
PersistentClient - Stua2 - Waiting up to 10000 seconds for connection to chromecast
PersistentClient - Stua2 - Connected client
PersistentClient - Stua2 - Connected client
PersistentPlayer - Stua2 - Try to join player
PersistentPlayer - Stua2 - Connected player
PersistentPlayer - Stua2 - Player joint
PersistentPlayer - Stua2 - Connected player
PersistentPlayer - Stua2 - Default player lauched
PersistentPlayer - Stua2 - Try to play playlist with 1 items
PersistentPlayer - Stua2 - Started playing - http://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/dash/BigBuckBunnyAudio.mp4
PersistentPlayer - Stua2 - Playing playlist with 1 items
PLAYING: http://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/dash/BigBuckBunnyAudio.mp4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.