bugfix
This commit is contained in:
parent
dc4f4e86c1
commit
35ca64559a
@ -32,3 +32,41 @@ bricks.UpStreaming = class extends bricks.JsWidget {
|
|||||||
this.stream_ctlr = controller;
|
this.stream_ctlr = controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bricks.down_streaming = function(widget, response) {
|
||||||
|
const reader = response.body.getReader();
|
||||||
|
new ReadableStream({
|
||||||
|
start(controller) {
|
||||||
|
function push() {
|
||||||
|
// 读取下一个数据块
|
||||||
|
reader.read().then(({ done, value }) => {
|
||||||
|
if (done) {
|
||||||
|
// 如果读取完成,关闭流
|
||||||
|
controller.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 将数据块放入队列
|
||||||
|
controller.enqueue(value);
|
||||||
|
push();
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('Error reading data', error);
|
||||||
|
controller.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
push();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(stream => {
|
||||||
|
// 将ReadableStream转换为Blob
|
||||||
|
return new Response(stream).blob();
|
||||||
|
})
|
||||||
|
.then(blob => {
|
||||||
|
const audioSrc = widget.set_url(URL.createObjectURL(blob));
|
||||||
|
widget.bind('canplay', () => {
|
||||||
|
widget.play();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Fetching audio stream failed', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@ SOURCES=" page_data_loader.js factory.js uitypesdef.js utils.js uitype.js \
|
|||||||
floaticonbar.js miniform.js wterm.js dynamicaccordion.js \
|
floaticonbar.js miniform.js wterm.js dynamicaccordion.js \
|
||||||
binstreaming.js streaming_audio.js vadtext.js rtc.js \
|
binstreaming.js streaming_audio.js vadtext.js rtc.js \
|
||||||
llm_dialog.js llm.js websocket.js datarow.js tabular.js \
|
llm_dialog.js llm.js websocket.js datarow.js tabular.js \
|
||||||
line.js pie.js bar.js gobang.js period.js "
|
line.js pie.js bar.js gobang.js "
|
||||||
echo ${SOURCES}
|
echo ${SOURCES}
|
||||||
cat ${SOURCES} > ../dist/bricks.js
|
cat ${SOURCES} > ../dist/bricks.js
|
||||||
# uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js
|
# uglifyjs --compress --mangle -- ../dist/bricks.js > ../dist/bricks.min.js
|
||||||
|
@ -52,6 +52,10 @@ bricks.Camera = class extends bricks.Popup {
|
|||||||
this.task = schedule_once(this.show_picture.bind(this), this.task_period);
|
this.task = schedule_once(this.show_picture.bind(this), this.task_period);
|
||||||
}
|
}
|
||||||
take_picture(){
|
take_picture(){
|
||||||
|
if (this.task){
|
||||||
|
this.task.cancel();
|
||||||
|
this.task = null;
|
||||||
|
}
|
||||||
var d = this.imgw.base64();
|
var d = this.imgw.base64();
|
||||||
this.dispatch('shot', d);
|
this.dispatch('shot', d);
|
||||||
// Create a blob from the canvas data URL
|
// Create a blob from the canvas data URL
|
||||||
|
@ -366,7 +366,10 @@ bricks.UiImage =class extends bricks.VBox {
|
|||||||
"height":"90%",
|
"height":"90%",
|
||||||
"width":"90%"
|
"width":"90%"
|
||||||
});
|
});
|
||||||
camera.bind('shot', function(d){
|
camera.bring_to_top();
|
||||||
|
camera.bind('shot', this.accept_photo.bind(this));
|
||||||
|
}
|
||||||
|
accept_photo(url){
|
||||||
if (this.imgw){
|
if (this.imgw){
|
||||||
this.remove_widget(this.imgw);
|
this.remove_widget(this.imgw);
|
||||||
}
|
}
|
||||||
@ -375,7 +378,6 @@ bricks.UiImage =class extends bricks.VBox {
|
|||||||
width:'100%'
|
width:'100%'
|
||||||
});
|
});
|
||||||
this.add_widget(this.imgw);
|
this.add_widget(this.imgw);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
handleFileSelect(event){
|
handleFileSelect(event){
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
|
@ -63,6 +63,7 @@ bricks.Video = class extends bricks.Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto_play(){
|
auto_play(){
|
||||||
|
return;
|
||||||
schedule_once(this._auto_play.bind(this), 0.5);
|
schedule_once(this._auto_play.bind(this), 0.5);
|
||||||
}
|
}
|
||||||
_auto_play(){
|
_auto_play(){
|
||||||
|
Loading…
Reference in New Issue
Block a user