@@ -13,7 +13,21 @@ function init(Survey) {
1313 return question . getType ( ) === "microphone" ;
1414 } ,
1515 htmlTemplate :
16- "<div><button type='button' title='Record'><i class='fa fa-microphone' aria-hidden='true'></i></button> <button type='button' title='Save'><i class='fa fa-cloud' aria-hidden='true'></i></button></div>" ,
16+ "<div>" +
17+ "<button type='button' title='Record'><i class='fa fa-microphone' aria-hidden='true'></i></button>" +
18+ " <button type='button' title='Save'><i class='fa fa-cloud' aria-hidden='true'></i></button>" +
19+ " <audio style='" +
20+ "position:relative; " +
21+ "top:16px; " +
22+ "left:10px; " +
23+ "height:35px;" +
24+ "-moz-box-shadow: 2px 2px 4px 0px #006773;" +
25+ "-webkit-box-shadow: 2px 2px 4px 0px #006773;" +
26+ "box-shadow: 2px 2px 4px 0px #006773;" +
27+ "' " +
28+ "controls='true' >" +
29+ "</audio>" +
30+ "</div>" ,
1731 activatedByChanged : function ( activatedBy ) {
1832 Survey . JsonObject . metaData . addClass ( "microphone" , [ ] , null , "empty" ) ;
1933 } ,
@@ -22,6 +36,7 @@ function init(Survey) {
2236 var rootWidget = this ;
2337 var buttonStartEl = el . getElementsByTagName ( "button" ) [ 0 ] ;
2438 var buttonStopEl = el . getElementsByTagName ( "button" ) [ 1 ] ;
39+ var audioEl = el . getElementsByTagName ( "audio" ) [ 0 ] ;
2540
2641////////// RecordRTC logic
2742
@@ -52,25 +67,20 @@ function init(Survey) {
5267 var processAudio = function ( audioVideoWebMURL ) {
5368 console . log ( "processAudio" ) ;
5469 var recordedBlob = question . survey . recordRTC . getBlob ( ) ;
55- console . log ( "Blob size:" + recordedBlob . size ) ;
56-
57- console . log ( "question.id : " + question . id ) ;
58- console . log ( "question.name : " + question . name ) ;
59-
6070
6171 var fileReader = new FileReader ( ) ;
6272 fileReader . onload = function ( event ) {
6373 var dataUri = event . target . result ;
6474 console . log ( "dataUri: " + dataUri ) ;
65- //question.value = (question.value || []).concat([fileReader.result])
6675 question . value = dataUri ;
67- } ;
68- fileReader . readAsDataURL ( recordedBlob ) ;
76+ audioEl . src = dataUri ;
6977
7078 console . log ( "cleaning" ) ;
7179 question . survey . recordRTC = undefined ;
7280 question . survey . mystream = undefined ;
7381 } ;
82+ fileReader . readAsDataURL ( recordedBlob ) ;
83+ } ;
7484
7585 var startRecording = function ( ) {
7686
@@ -108,8 +118,6 @@ function init(Survey) {
108118 }
109119 ) ;
110120 }
111-
112-
113121 }
114122 } ;
115123
@@ -127,6 +135,9 @@ function init(Survey) {
127135 buttonStopEl . parentNode . removeChild ( buttonStartEl ) ;
128136 }
129137
138+
139+ audioEl . src = question . value
140+
130141 var updateValueHandler = function ( ) {
131142
132143 } ;
0 commit comments