This commit is contained in:
yumoqing 2024-02-21 10:48:07 +08:00
parent cfab1946ba
commit d68536e330

View File

@ -280,3 +280,24 @@ var objcopy = function(obj){
} }
return o; return o;
} }
var bricks.playResponseAudio = async function(response, target){
var widget = null;
if (response.status != 200){
console.log('playResponseAudio(): response.status != 200', response.status);
return;
}
if (typeof target == typeof ''){
widget = bricks.getWidgetById(target);
} else {
widget = bricks.widgetBuild(target);
}
if (! widget){
console.log('playResponseAudio():', target, 'can not found or build a widget');
return;
}
const blob = await response.blob();
const url = URL.createObjectURL(blob);
widget.set_url(url);
widget.play();
}