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

@@ -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();
};