fixes in audio

This commit is contained in:
tamat
2020-03-25 13:13:58 +01:00
parent 6c98476cd5
commit e8eda9d30f
6 changed files with 648 additions and 609 deletions

View File

@@ -165,7 +165,8 @@
get: function(v) {
return this._shape;
},
enumerable: true
enumerable: true,
configurable: true
});
//warnings
@@ -7539,7 +7540,7 @@ LGraphNode.prototype.executeAction = function(action)
}
if (!low_quality) {
ctx.font = this.title_text_font;
var title = node.getTitle();
var title = String(node.getTitle());
if (title) {
if (selected) {
ctx.fillStyle = "white";
@@ -7549,11 +7550,11 @@ LGraphNode.prototype.executeAction = function(action)
this.node_title_color;
}
if (node.flags.collapsed) {
ctx.textAlign = "center";
ctx.textAlign = "left";
var measure = ctx.measureText(title);
ctx.fillText(
title,
title_height + measure.width * 0.5,
title.substr(0,20), //avoid urls too long
title_height,// + measure.width * 0.5,
LiteGraph.NODE_TITLE_TEXT_Y - title_height
);
ctx.textAlign = "left";
@@ -8308,6 +8309,11 @@ LGraphNode.prototype.executeAction = function(action)
ctx.rect( margin, posY, width - margin * 2, H );
ctx.fill();
if (show_text) {
ctx.save();
ctx.beginPath();
ctx.rect(margin, posY, width - margin * 2, H);
ctx.clip();
ctx.stroke();
ctx.fillStyle = secondary_text_color;
if (w.name != null) {
@@ -8316,6 +8322,8 @@ LGraphNode.prototype.executeAction = function(action)
ctx.fillStyle = text_color;
ctx.textAlign = "right";
ctx.fillText(w.value, width - margin * 2, y + H * 0.7);
ctx.restore();
}
break;
default:
@@ -10290,11 +10298,12 @@ LGraphNode.prototype.executeAction = function(action)
}
}
if (
options.event &&
options.event.constructor !== MouseEvent &&
options.event.constructor !== CustomEvent &&
options.event.constructor !== PointerEvent
var eventClass = null;
if(options.event) //use strings because comparing classes between windows doesnt work
eventClass = options.event.constructor.name;
if ( eventClass !== "MouseEvent" &&
eventClass !== "CustomEvent" &&
eventClass !== "PointerEvent"
) {
console.error(
"Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it."
@@ -15646,9 +15655,7 @@ if (typeof exports != "undefined") {
if (callback) {
callback(this);
}
that.trace(
"Image loaded, size: " + that.img.width + "x" + that.img.height
);
console.log( "Image loaded, size: " + that.img.width + "x" + that.img.height );
this.dirty = true;
that.boxcolor = "#9F9";
that.setDirtyCanvas(true);
@@ -15930,7 +15937,7 @@ if (typeof exports != "undefined") {
if (name == "scale") {
this.properties[name] = parseFloat(value);
if (this.properties[name] == 0) {
this.trace("Error in scale");
console.error("Error in scale");
this.properties[name] = 1.0;
}
} else {
@@ -16100,10 +16107,23 @@ if (typeof exports != "undefined") {
ImageVideo.prototype.loadVideo = function(url) {
this._video_url = url;
var pos = url.substr(0,10).indexOf(":");
var protocol = "";
if(pos != -1)
protocol = url.substr(0,pos);
var host = "";
if(protocol)
{
host = url.substr(0,url.indexOf("/",protocol.length + 3));
host = host.substr(protocol.length+3);
}
if (
this.properties.use_proxy &&
url.substr(0, 4) == "http" &&
LiteGraph.proxy
protocol &&
LiteGraph.proxy &&
host != location.host
) {
url = LiteGraph.proxy + url.substr(url.indexOf(":") + 3);
}
@@ -16118,41 +16138,38 @@ if (typeof exports != "undefined") {
var that = this;
this._video.addEventListener("loadedmetadata", function(e) {
//onload
that.trace("Duration: " + this.duration + " seconds");
that.trace("Size: " + this.videoWidth + "," + this.videoHeight);
console.log("Duration: " + this.duration + " seconds");
console.log("Size: " + this.videoWidth + "," + this.videoHeight);
that.setDirtyCanvas(true);
this.width = this.videoWidth;
this.height = this.videoHeight;
});
this._video.addEventListener("progress", function(e) {
//onload
//that.trace("loading...");
console.log("video loading...");
});
this._video.addEventListener("error", function(e) {
console.log("Error loading video: " + this.src);
that.trace("Error loading video: " + this.src);
console.error("Error loading video: " + this.src);
if (this.error) {
switch (this.error.code) {
case this.error.MEDIA_ERR_ABORTED:
that.trace("You stopped the video.");
console.error("You stopped the video.");
break;
case this.error.MEDIA_ERR_NETWORK:
that.trace("Network error - please try again later.");
console.error("Network error - please try again later.");
break;
case this.error.MEDIA_ERR_DECODE:
that.trace("Video is broken..");
console.error("Video is broken..");
break;
case this.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
that.trace(
"Sorry, your browser can't play this video."
);
console.error("Sorry, your browser can't play this video.");
break;
}
}
});
this._video.addEventListener("ended", function(e) {
that.trace("Ended.");
console.log("Video Ended.");
this.play(); //loop
});
@@ -16169,7 +16186,7 @@ if (typeof exports != "undefined") {
};
ImageVideo.prototype.play = function() {
if (this._video) {
if (this._video && this._video.videoWidth ) { //is loaded
this._video.play();
}
};
@@ -16197,7 +16214,7 @@ if (typeof exports != "undefined") {
if (!this._video) {
return;
}
this.trace("Video paused");
console.log("Video paused");
this._video.pause();
};
@@ -26088,8 +26105,10 @@ function LGraphGeometryDisplace() {
if (v === undefined) {
continue;
}
if (input.name == "gain") {
if (input.name == "gain")
this.audionode.gain.value = v;
else if (input.name == "src") {
this.setProperty("src",v);
} else if (input.name == "playbackRate") {
this.properties.playbackRate = v;
for (var j = 0; j < this._audionodes.length; ++j) {
@@ -26201,6 +26220,7 @@ function LGraphGeometryDisplace() {
LGAudioSource.prototype.onGetInputs = function() {
return [
["playbackRate", "number"],
["src","string"],
["Play", LiteGraph.ACTION],
["Stop", LiteGraph.ACTION]
];

1092
build/litegraph.min.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "litegraph.js",
"version": "0.7.3",
"version": "0.7.4",
"description": "A graph node editor similar to PD or UDK Blueprints, it works in a HTML5 Canvas and allow to exported graphs to be included in applications.",
"main": "build/litegraph.js",
"types": "src/litegraph.d.ts",
@@ -35,7 +35,7 @@
"devDependencies": {
"express": "^4.17.1",
"google-closure-compiler": "^20171112.0.0",
"grunt": "^1.0.4",
"grunt": "^1.1.0",
"grunt-cli": "^1.2.0",
"grunt-closure-tools": "^1.0.0",
"grunt-contrib-concat": "^1.0.1",

View File

@@ -7538,7 +7538,7 @@ LGraphNode.prototype.executeAction = function(action)
}
if (!low_quality) {
ctx.font = this.title_text_font;
var title = node.getTitle();
var title = String(node.getTitle());
if (title) {
if (selected) {
ctx.fillStyle = "white";
@@ -7548,11 +7548,11 @@ LGraphNode.prototype.executeAction = function(action)
this.node_title_color;
}
if (node.flags.collapsed) {
ctx.textAlign = "center";
ctx.textAlign = "left";
var measure = ctx.measureText(title);
ctx.fillText(
title,
title_height + measure.width * 0.5,
title.substr(0,20), //avoid urls too long
title_height,// + measure.width * 0.5,
LiteGraph.NODE_TITLE_TEXT_Y - title_height
);
ctx.textAlign = "left";
@@ -8307,6 +8307,11 @@ LGraphNode.prototype.executeAction = function(action)
ctx.rect( margin, posY, width - margin * 2, H );
ctx.fill();
if (show_text) {
ctx.save();
ctx.beginPath();
ctx.rect(margin, posY, width - margin * 2, H);
ctx.clip();
ctx.stroke();
ctx.fillStyle = secondary_text_color;
if (w.name != null) {
@@ -8315,6 +8320,8 @@ LGraphNode.prototype.executeAction = function(action)
ctx.fillStyle = text_color;
ctx.textAlign = "right";
ctx.fillText(w.value, width - margin * 2, y + H * 0.7);
ctx.restore();
}
break;
default:
@@ -10289,11 +10296,12 @@ LGraphNode.prototype.executeAction = function(action)
}
}
if (
options.event &&
options.event.constructor !== MouseEvent &&
options.event.constructor !== CustomEvent &&
options.event.constructor !== PointerEvent
var eventClass = null;
if(options.event) //use strings because comparing classes between windows doesnt work
eventClass = options.event.constructor.name;
if ( eventClass !== "MouseEvent" &&
eventClass !== "CustomEvent" &&
eventClass !== "PointerEvent"
) {
console.error(
"Event passed to ContextMenu is not of type MouseEvent or CustomEvent. Ignoring it."

View File

@@ -345,8 +345,10 @@
if (v === undefined) {
continue;
}
if (input.name == "gain") {
if (input.name == "gain")
this.audionode.gain.value = v;
else if (input.name == "src") {
this.setProperty("src",v);
} else if (input.name == "playbackRate") {
this.properties.playbackRate = v;
for (var j = 0; j < this._audionodes.length; ++j) {
@@ -458,6 +460,7 @@
LGAudioSource.prototype.onGetInputs = function() {
return [
["playbackRate", "number"],
["src","string"],
["Play", LiteGraph.ACTION],
["Stop", LiteGraph.ACTION]
];

View File

@@ -143,9 +143,7 @@
if (callback) {
callback(this);
}
that.trace(
"Image loaded, size: " + that.img.width + "x" + that.img.height
);
console.log( "Image loaded, size: " + that.img.width + "x" + that.img.height );
this.dirty = true;
that.boxcolor = "#9F9";
that.setDirtyCanvas(true);
@@ -427,7 +425,7 @@
if (name == "scale") {
this.properties[name] = parseFloat(value);
if (this.properties[name] == 0) {
this.trace("Error in scale");
console.error("Error in scale");
this.properties[name] = 1.0;
}
} else {
@@ -597,10 +595,23 @@
ImageVideo.prototype.loadVideo = function(url) {
this._video_url = url;
var pos = url.substr(0,10).indexOf(":");
var protocol = "";
if(pos != -1)
protocol = url.substr(0,pos);
var host = "";
if(protocol)
{
host = url.substr(0,url.indexOf("/",protocol.length + 3));
host = host.substr(protocol.length+3);
}
if (
this.properties.use_proxy &&
url.substr(0, 4) == "http" &&
LiteGraph.proxy
protocol &&
LiteGraph.proxy &&
host != location.host
) {
url = LiteGraph.proxy + url.substr(url.indexOf(":") + 3);
}
@@ -615,41 +626,38 @@
var that = this;
this._video.addEventListener("loadedmetadata", function(e) {
//onload
that.trace("Duration: " + this.duration + " seconds");
that.trace("Size: " + this.videoWidth + "," + this.videoHeight);
console.log("Duration: " + this.duration + " seconds");
console.log("Size: " + this.videoWidth + "," + this.videoHeight);
that.setDirtyCanvas(true);
this.width = this.videoWidth;
this.height = this.videoHeight;
});
this._video.addEventListener("progress", function(e) {
//onload
//that.trace("loading...");
console.log("video loading...");
});
this._video.addEventListener("error", function(e) {
console.log("Error loading video: " + this.src);
that.trace("Error loading video: " + this.src);
console.error("Error loading video: " + this.src);
if (this.error) {
switch (this.error.code) {
case this.error.MEDIA_ERR_ABORTED:
that.trace("You stopped the video.");
console.error("You stopped the video.");
break;
case this.error.MEDIA_ERR_NETWORK:
that.trace("Network error - please try again later.");
console.error("Network error - please try again later.");
break;
case this.error.MEDIA_ERR_DECODE:
that.trace("Video is broken..");
console.error("Video is broken..");
break;
case this.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
that.trace(
"Sorry, your browser can't play this video."
);
console.error("Sorry, your browser can't play this video.");
break;
}
}
});
this._video.addEventListener("ended", function(e) {
that.trace("Ended.");
console.log("Video Ended.");
this.play(); //loop
});
@@ -666,7 +674,7 @@
};
ImageVideo.prototype.play = function() {
if (this._video) {
if (this._video && this._video.videoWidth ) { //is loaded
this._video.play();
}
};
@@ -694,7 +702,7 @@
if (!this._video) {
return;
}
this.trace("Video paused");
console.log("Video paused");
this._video.pause();
};