iobroker.chromecast
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -5,3 +5,3 @@ { | ||
"title": "Chromecast Adapter", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "authors": ["Vegetto <iobroker@angelnu.com>"], |
@@ -68,3 +68,3 @@ /* | ||
//Need to be called when the address/port change | ||
this.updateAddress = function (n_address, n_port) { | ||
that.updateAddress = function (n_address, n_port) { | ||
@@ -754,3 +754,3 @@ adapter.log.info(name + " - Updating address: " + n_address + ":" + n_port); | ||
var contentId = (media.contentId ? media.contentId : "Unknown"); | ||
var cachedContentId = (media.contentId ? media.contentId : "Unknown"); | ||
var cachedContentId = (cachedMedia.contentId ? media.contentId : "Unknown"); | ||
setStateIfChanged(states.contentId.name, | ||
@@ -907,3 +907,4 @@ {val: contentId, ack: true}, | ||
if (err) { | ||
adapter.log.error(name + ' - media loaded err=%s', err); | ||
adapter.log.error(name + ' - media loadMedia err: ' + err.toString()); | ||
adapter.log.error(JSON.stringify(media)); | ||
detachPlayer(); | ||
@@ -910,0 +911,0 @@ } else { |
@@ -19,6 +19,7 @@ /* | ||
var Connection = function (url2play, org_url2play, streamType, callback) { | ||
EventEmitter.call(this); | ||
this._url2play = url2play; | ||
this._callback = callback; | ||
this._media = { | ||
that = this; | ||
EventEmitter.call(that); | ||
that._url2play = url2play; | ||
that._callback = callback; | ||
that._media = { | ||
// Here you can plug an URL to any mp4, webm, mp3 or jpg file with the proper contentType. | ||
@@ -38,15 +39,15 @@ contentId: url2play, | ||
if (!DISCOVER_ICY_METADATA) { | ||
callback(this._media); | ||
callback(that._media); | ||
return; | ||
} | ||
this._pipeOn = false; | ||
that._pipeOn = false; | ||
try { | ||
this._requestObject = icy.get(url2play, this._connected.bind(this)); | ||
this._requestObject.on('error', function (e) { | ||
console.log("MediaInformation - ICY connection error for " + this._url2play + ": " + e); | ||
that._requestObject = icy.get(url2play, that._connected.bind(that)); | ||
that._requestObject.on('error', function (e) { | ||
console.log("MediaInformation - ICY connection error for " + that._url2play + ": " + e); | ||
}); | ||
} catch (e) { | ||
console.log("MediaInformation - Cannot connect to " + this._url2play + ": " + e); | ||
console.log("MediaInformation - Cannot connect to " + that._url2play + ": " + e); | ||
} | ||
@@ -58,8 +59,8 @@ }; | ||
Connection.prototype.getMedia = function () { | ||
return this._media; | ||
return that._media; | ||
}; | ||
Connection.prototype.close = function () { | ||
if (this._requestObject) { | ||
this._requestObject.abort(); | ||
if (that._requestObject) { | ||
that._requestObject.abort(); | ||
} | ||
@@ -70,3 +71,3 @@ }; | ||
Connection.prototype._connected = function (res) { | ||
console.log("MediaInformation - Connected to " + this._url2play); | ||
console.log("MediaInformation - Connected to " + that._url2play); | ||
/* | ||
@@ -101,4 +102,5 @@ * Example from http://edge.live.mp3.mdn.newmedia.nacamar.net/ps-dieneue_rock/livestream_hi.mp3 | ||
(res.headers["content-type"].indexOf("video") >= 0))) | ||
this._media.contentType = res.headers["content-type"]; | ||
//console.log(this._media); | ||
that._media.contentType = res.headers["content-type"]; | ||
//console.log(that._media); | ||
that._media.debugHeaderDump = res.headers; | ||
@@ -108,11 +110,11 @@ if ("icy-name" in res.headers) { | ||
//first metadata in less than 1 second | ||
this._timeoutHandler = setTimeout(function () { | ||
this._callback(this._media); | ||
that._timeoutHandler = setTimeout(function () { | ||
that._callback(that._media); | ||
}, 1000); | ||
// log any "metadata" events that happen | ||
res.on('metadata', this._gotMetadata.bind(this, res)); | ||
res.on('metadata', that._gotMetadata.bind(that, res)); | ||
} else { | ||
//Not ICY -> call callback already | ||
this._callback(this._media); | ||
that._callback(that._media); | ||
} | ||
@@ -133,15 +135,15 @@ | ||
//Get title | ||
this._media.metadata.title = parsed.StreamTitle; | ||
that._media.metadata.title = parsed.StreamTitle; | ||
//If we got media info then call callback already | ||
if (this._timeoutHandler) { | ||
clearTimeout(this._timeoutHandler); | ||
this._timeoutHandler = undefined; | ||
this._callback(this._media); | ||
if (that._timeoutHandler) { | ||
clearTimeout(that._timeoutHandler); | ||
that._timeoutHandler = undefined; | ||
that._callback(that._media); | ||
} | ||
//Notify that media has been updated | ||
this.emit("media", this._media); | ||
that.emit("media", that._media); | ||
if (!this._pipeOn) { | ||
if (!that._pipeOn) { | ||
//We need to keep reading in order to receive additional metadata | ||
@@ -151,3 +153,3 @@ //We do it here to avoid reading data for sources that do not send | ||
res.pipe(devnull()); | ||
this._pipeOn = true; | ||
that._pipeOn = true; | ||
} | ||
@@ -154,0 +156,0 @@ }; |
{ | ||
"name": "iobroker.chromecast", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "ioBroker chromecast Adapter", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -53,2 +53,3 @@ ![Logo](admin/chromecast.png) | ||
* Note: this does not work with SSDP -> disable by default in adapter settings | ||
* Play again last played stream: just set _chromecast.0.`<your device>`.status.playing_ to _true_ | ||
@@ -66,2 +67,6 @@ What is missing? | ||
--------- | ||
### 1.0.9 | ||
* (Vegetto) Do not use this in callbacks. Replaced with _that_ | ||
* (Vegetto) Fix contentId not being updated. This was breaking the _play last stream_ feature | ||
### 1.0.8 | ||
@@ -68,0 +73,0 @@ * (Vegetto) Do not try to stop if not playing |
/* | ||
ioBroker.chromecast Widget-Set | ||
version: "1.0.8" | ||
version: "1.0.9" | ||
@@ -145,3 +145,3 @@ Copyright 10.2015-2016 Vegetto<iobroker@angelnu.com> | ||
vis.binds.chromecast = { | ||
version: "1.0.8", | ||
version: "1.0.9", | ||
showVersion: function () { | ||
@@ -148,0 +148,0 @@ if (vis.binds.chromecast.version) { |
Sorry, the diff of this file is not supported yet
105659
1591
149