bugfix
This commit is contained in:
parent
1937541daf
commit
517b8f0d4d
@ -1,5 +1,5 @@
|
||||
var bricks = window.bricks || {};
|
||||
bricks.Accordion = class oops extends bricks.VBox {
|
||||
bricks.Accordion = class extends bricks.VBox {
|
||||
/*
|
||||
{
|
||||
item_size:
|
||||
|
@ -1,5 +1,5 @@
|
||||
var bricks = window.bricks || {};
|
||||
bricks.AG_Grid = class oops extends bricks.JsWidget {
|
||||
bricks.AG_Grid = class extends bricks.JsWidget {
|
||||
/*
|
||||
{
|
||||
dataurl:
|
||||
|
@ -12,7 +12,7 @@ var formatMs=function(ms,all){
|
||||
return t;
|
||||
};
|
||||
|
||||
bricks.AudioPlayer = class oops extends bricks.JsWidget {
|
||||
bricks.AudioPlayer = class extends bricks.JsWidget {
|
||||
/*
|
||||
{
|
||||
url:
|
||||
@ -54,13 +54,18 @@ bricks.AudioPlayer = class oops extends bricks.JsWidget {
|
||||
}
|
||||
|
||||
|
||||
bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||
bricks.AudioRecorder = class extends bricks.HBox {
|
||||
/*
|
||||
{
|
||||
"upload_url":
|
||||
"icon_rate":
|
||||
"upload_resp":"text", or "json", or "bin"
|
||||
}
|
||||
we need this module:
|
||||
https://gitee.com/xiangyuecn/Recorder
|
||||
events:
|
||||
record_started
|
||||
record_finished wavdata
|
||||
record_ended
|
||||
realtime record wave show need a another package
|
||||
we only use the wav file format
|
||||
*/
|
||||
@ -68,7 +73,7 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||
super(opts);
|
||||
this.start_icon = opts.start_icon || bricks_resource('imgs/start_recording.png');
|
||||
this.stop_icon = opts.stop_icon || bricks_resource('imgs/stop_recording.png');
|
||||
this.rec_btn = new bricks.Icon({url:this.start_icon });
|
||||
this.rec_btn = new bricks.Icon({url:this.start_icon, rate:this.icon_rate });
|
||||
// this.player = new bricks.AudioPlayer({url:"",width:'80px'});
|
||||
this.rec_time = new bricks.Text({text:" record time", i18n:false, wrap:false, width:'120px'});
|
||||
this.upload_url = opts.upload_url;
|
||||
@ -79,9 +84,8 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||
this.mic_opened = false;
|
||||
this.add_widget(this.rec_btn);
|
||||
this.add_widget(this.rec_time);
|
||||
// this.add_widget(this.player);
|
||||
this.recordData = null;
|
||||
this.bind('record_finished', this.upload.bind(this));
|
||||
this.bind('record_ended', this.upload.bind(this));
|
||||
}
|
||||
rec_btn_pressed(){
|
||||
bricks.debug(this.rec_btn.url, ':url:', this.start_icon, this.stop_icon);
|
||||
@ -161,7 +165,6 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||
bricks.debug("5JuL::未打开录音");
|
||||
return;
|
||||
};
|
||||
// this.pause_recording();
|
||||
this.rec.stop(function(blob,duration){
|
||||
var localURL = this.URL.createObjectURL(blob);
|
||||
var d = {
|
||||
@ -170,14 +173,12 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||
duration:duration
|
||||
}
|
||||
this.recordData = d;
|
||||
// this.player.set_source(this.recordData.url);
|
||||
this.dispatch('record_finished', d);
|
||||
this.dispatch('record_ended', d);
|
||||
|
||||
}.bind(this),function(msg){
|
||||
bricks.debug("kGZO::录音失败:");
|
||||
});
|
||||
this.recClose();
|
||||
this.dispatch('record_ended');
|
||||
}
|
||||
upload = async function(){
|
||||
if(!this.recordData){
|
||||
@ -196,7 +197,18 @@ bricks.AudioRecorder = class oops extends bricks.HBox {
|
||||
params:form
|
||||
});
|
||||
bricks.debug('ret=', ret);
|
||||
this.dispatch('uploaded', ret)
|
||||
if (!this.upload_resp){
|
||||
this.upload_resp = 'text';
|
||||
}
|
||||
data = null;
|
||||
if (this.upload_resp == 'text'){
|
||||
data = await ret.text();
|
||||
} else if (this.upload_resp == 'json'){
|
||||
data = await ret.json();
|
||||
} else if (this.upload_resp == 'bin'){
|
||||
data = await ret.bin();
|
||||
}
|
||||
this.dispatch('uploaded', data)
|
||||
}
|
||||
download(){
|
||||
if(!this.recordData){
|
||||
|
@ -1,5 +1,5 @@
|
||||
var bricks = window.bricks || {};
|
||||
bricks.Image = class oops extends bricks.JsWidget {
|
||||
bricks.Image = class extends bricks.JsWidget {
|
||||
/*
|
||||
{
|
||||
url:
|
||||
@ -49,7 +49,7 @@ bricks.Icon = class extends bricks.Image {
|
||||
}
|
||||
}
|
||||
|
||||
bricks.BlankIcon = class oops extends bricks.JsWidget {
|
||||
bricks.BlankIcon = class extends bricks.JsWidget {
|
||||
constructor(opts){
|
||||
super(opts);
|
||||
this.rate = opts.rate || 1;
|
||||
|
Loading…
Reference in New Issue
Block a user