Commit 1f68350eedb1b7260a9a939c7d1bd8ae0d7e193a

Authored by ykxie
1 parent 9b7bbdec

fix bug

src/css/recording.css
@@ -413,6 +413,7 @@ button { @@ -413,6 +413,7 @@ button {
413 .recording-ctrl-bar .btn { 413 .recording-ctrl-bar .btn {
414 width: 80px; 414 width: 80px;
415 background-size: 70%; 415 background-size: 70%;
  416 + background: transparent;
416 border: none; } 417 border: none; }
417 .recording-ctrl-bar .recording { 418 .recording-ctrl-bar .recording {
418 background: url("../img/recording.svg") no-repeat center; } 419 background: url("../img/recording.svg") no-repeat center; }
@@ -482,6 +483,17 @@ button { @@ -482,6 +483,17 @@ button {
482 left: 50%; 483 left: 50%;
483 transform: translate(-50%, -50%); } 484 transform: translate(-50%, -50%); }
484 485
  486 +.re-tips .btn-success, .pause-shodow .btn-success {
  487 + background-color: #1FB6FF;
  488 + border: none;
  489 + box-shadow: 0 1px 5px; }
  490 +
  491 +.re-tips .btn-danger, .pause-shodow .btn-danger {
  492 + background-color: #FFFFFF;
  493 + color: #6E787F;
  494 + border: none;
  495 + box-shadow: 0 1px 5px; }
  496 +
485 .re-tips { 497 .re-tips {
486 position: absolute; 498 position: absolute;
487 top: 0; 499 top: 0;
src/js/gbreplayer.js
@@ -384,10 +384,12 @@ $(function(){ @@ -384,10 +384,12 @@ $(function(){
384 ,debuggers: false 384 ,debuggers: false
385 ,allowSeek: false 385 ,allowSeek: false
386 ,playCallback: function(){ 386 ,playCallback: function(){
387 - playCoder(); 387 + // playCoder();
  388 + $('#play').trigger('click');
388 } 389 }
389 ,pauseCallback: function(){ 390 ,pauseCallback: function(){
390 - playCoder(); 391 + // playCoder();
  392 + $('#play').trigger('click');
391 } 393 }
392 ,seekedCallback: function(){} 394 ,seekedCallback: function(){}
393 ,endedCallback: function(){ 395 ,endedCallback: function(){
@@ -433,24 +435,14 @@ $(function(){ @@ -433,24 +435,14 @@ $(function(){
433 } 435 }
434 436
435 $('#recordertab a:eq(1)').tab('show'); 437 $('#recordertab a:eq(1)').tab('show');
436 -  
437 - // 播放时初始化运行结果  
438 - var initcompile = {  
439 - cmpinfo: '',  
440 - output: '',  
441 - result: 1,  
442 - stderr: ''  
443 - }  
444 - compileResult(initcompile);  
445 438
446 var playstatus = $(this).data('status'); 439 var playstatus = $(this).data('status');
  440 +
447 if(document.URL.indexOf('player.html')>=0){ 441 if(document.URL.indexOf('player.html')>=0){
448 if(playstatus){ 442 if(playstatus){
449 GBCodePlayBack.pauseData = new Date().getTime(); // 暂停的时间 443 GBCodePlayBack.pauseData = new Date().getTime(); // 暂停的时间
450 - myAudio[0].pause();  
451 $('#play').find('i').removeClass('icon-playcopy').addClass('icon-play').attr('data-original-title', '播放'); 444 $('#play').find('i').removeClass('icon-playcopy').addClass('icon-play').attr('data-original-title', '播放');
452 }else{ 445 }else{
453 - myAudio[0].play();  
454 $('#play').find('i').removeClass('icon-play').addClass('icon-playcopy').attr('data-original-title', '暂停'); 446 $('#play').find('i').removeClass('icon-play').addClass('icon-playcopy').attr('data-original-title', '暂停');
455 } 447 }
456 } 448 }
@@ -474,11 +466,13 @@ $(function(){ @@ -474,11 +466,13 @@ $(function(){
474 if (GBCodePlayBack.pauseData) { 466 if (GBCodePlayBack.pauseData) {
475 if (tag === 1) { 467 if (tag === 1) {
476 GBCodePlayBack.stopIntervalTime = playbackrecord[0].intervaltime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart); 468 GBCodePlayBack.stopIntervalTime = playbackrecord[0].intervaltime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
477 - starttime = GBCodePlayBack.stopIntervalTime 469 + starttime = GBCodePlayBack.stopIntervalTime;
  470 + console.log('+++++++++++++++++++++++++++' + starttime);
478 tag++; 471 tag++;
479 }else{ 472 }else{
480 GBCodePlayBack.stopIntervalTime = GBCodePlayBack.stopIntervalTime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart); 473 GBCodePlayBack.stopIntervalTime = GBCodePlayBack.stopIntervalTime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
481 starttime = GBCodePlayBack.stopIntervalTime; 474 starttime = GBCodePlayBack.stopIntervalTime;
  475 + console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&' + starttime);
482 } 476 }
483 } 477 }
484 478
@@ -888,7 +882,11 @@ $(function(){ @@ -888,7 +882,11 @@ $(function(){
888 var recorddata = { 882 var recorddata = {
889 intervaltime: GBCodePlayBack.records[i].intervaltime, 883 intervaltime: GBCodePlayBack.records[i].intervaltime,
890 editor: GBCodePlayBack.records[i].editor, 884 editor: GBCodePlayBack.records[i].editor,
891 - changeobj: JSON.stringify(GBCodePlayBack.records[i].changeobj) 885 + changeobj: JSON.stringify(GBCodePlayBack.records[i].changeobj),
  886 + cmpinfo: GBCodePlayBack.records[i].cmpinfo,
  887 + output: GBCodePlayBack.records[i].output,
  888 + result: GBCodePlayBack.records[i].result,
  889 + stderr: GBCodePlayBack.records[i].stderr
892 } 890 }
893 891
894 recorddatas.push(recorddata); 892 recorddatas.push(recorddata);
@@ -899,7 +897,7 @@ $(function(){ @@ -899,7 +897,7 @@ $(function(){
899 897
900 var keepTimer = $('.recording-time').val() 898 var keepTimer = $('.recording-time').val()
901 replaydto.totaltime = parseInt(keepTimer); 899 replaydto.totaltime = parseInt(keepTimer);
902 - 900 + console.log(replaydto);
903 if(_role == 0){ 901 if(_role == 0){
904 replaydto.codeRecordList = recorddatas; 902 replaydto.codeRecordList = recorddatas;
905 $.ajax({ 903 $.ajax({
@@ -1019,8 +1017,10 @@ $(function(){ @@ -1019,8 +1017,10 @@ $(function(){
1019 GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间 1017 GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间
1020 1018
1021 Hourglass.pauseTimer(); // 暂停计时器 1019 Hourglass.pauseTimer(); // 暂停计时器
  1020 + console.log('-------------暂停计时器---------------');
1022 1021
1023 - // $('#pause').data('status', '1'); 1022 + $('#pause').data('status', '1');
  1023 + $('#pause').data('pause', '0');
1024 $('#pause').removeClass('hidden').addClass('show'); 1024 $('#pause').removeClass('hidden').addClass('show');
1025 $('#start-recording').hide(); 1025 $('#start-recording').hide();
1026 recorder.pause(); 1026 recorder.pause();
@@ -1066,10 +1066,15 @@ $(function(){ @@ -1066,10 +1066,15 @@ $(function(){
1066 1066
1067 // 保存编译结果 1067 // 保存编译结果
1068 $('#save_compile').click(function(){ 1068 $('#save_compile').click(function(){
1069 - Hourglass.pauseTimer();  
1070 -  
1071 var length = GBCodePlayBack.records.length - 1; 1069 var length = GBCodePlayBack.records.length - 1;
  1070 +
1072 GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData; 1071 GBCodePlayBack.records[length].compile = GBCodePlayBack.compileResultData;
  1072 +
  1073 + GBCodePlayBack.records[length].output = GBCodePlayBack.compileResultData.output;
  1074 + GBCodePlayBack.records[length].stderr = GBCodePlayBack.compileResultData.stderr;
  1075 + GBCodePlayBack.records[length].cmpinfo = GBCodePlayBack.compileResultData.cmpinfo;
  1076 + GBCodePlayBack.records[length].result = GBCodePlayBack.compileResultData.result;
  1077 +
1073 console.log(GBCodePlayBack.records); 1078 console.log(GBCodePlayBack.records);
1074 GBCodePlayBack.record_continue_time = new Date().getTime(); 1079 GBCodePlayBack.record_continue_time = new Date().getTime();
1075 1080
@@ -1079,7 +1084,6 @@ $(function(){ @@ -1079,7 +1084,6 @@ $(function(){
1079 1084
1080 // 不保存编译结果 1085 // 不保存编译结果
1081 $('#cancel_compile').click(function(){ 1086 $('#cancel_compile').click(function(){
1082 - Hourglass.pauseTimer();  
1083 contrlPause() 1087 contrlPause()
1084 GBCodePlayBack.record_continue_time = new Date().getTime(); 1088 GBCodePlayBack.record_continue_time = new Date().getTime();
1085 }) 1089 })
@@ -1352,11 +1356,11 @@ $(function(){ @@ -1352,11 +1356,11 @@ $(function(){
1352 1356
1353 var pausetatus = $('#pause').data('status'); 1357 var pausetatus = $('#pause').data('status');
1354 1358
1355 - console.log(pausetatus) 1359 + console.log(pausetatus);
1356 1360
1357 if(_role == 0 && pausetatus == 1){ 1361 if(_role == 0 && pausetatus == 1){
1358 1362
1359 - intervaltime = (currenttime - GBCodePlayBack.record_continue_time) + (GBCodePlayBack.record_pause_time - GBCodePlayBack.record_startime) 1363 + intervaltime = (currenttime - GBCodePlayBack.record_continue_time) + (GBCodePlayBack.record_pause_time - GBCodePlayBack.record_startime);
1360 1364
1361 $('#pause').data('status', '0'); 1365 $('#pause').data('status', '0');
1362 1366
@@ -1398,14 +1402,17 @@ $(function(){ @@ -1398,14 +1402,17 @@ $(function(){
1398 record.trigger = 1; //标记已运行 1402 record.trigger = 1; //标记已运行
1399 record.playTime = new Date().getTime(); // 播放开始时间 1403 record.playTime = new Date().getTime(); // 播放开始时间
1400 1404
1401 - if (record.compile) {  
1402 - console.log(record.compile)  
1403 - console.log('***************************************************')  
1404 - var resultData = record.compile  
1405 - compileResult(resultData) 1405 +
  1406 + var resultData = {
  1407 + output: record.output || '',
  1408 + stderr: record.stderr || '',
  1409 + cmpinfo: record.cmpinfo || '',
  1410 + result: record.result || 1
1406 } 1411 }
1407 1412
  1413 + compileResult(resultData);
1408 console.log(record); 1414 console.log(record);
  1415 +
1409 if(replay_type){ 1416 if(replay_type){
1410 GBCodePlayBack.excercise_triggertotal += 1; 1417 GBCodePlayBack.excercise_triggertotal += 1;
1411 }else{ 1418 }else{
@@ -1416,8 +1423,7 @@ $(function(){ @@ -1416,8 +1423,7 @@ $(function(){
1416 var percertage = '0%',percertagenum=0; 1423 var percertage = '0%',percertagenum=0;
1417 if(replay_type){ 1424 if(replay_type){
1418 percertagenum = Math.ceil(GBCodePlayBack.excercise_triggertotal/GBCodePlayBack.excercise_records.length*100) 1425 percertagenum = Math.ceil(GBCodePlayBack.excercise_triggertotal/GBCodePlayBack.excercise_records.length*100)
1419 - percertage = percertagenum + '%';  
1420 - 1426 + percertage = percertagenum + '%';
1421 }else{ 1427 }else{
1422 if(!offset){ 1428 if(!offset){
1423 percertagenum = Math.ceil(GBCodePlayBack.triggertotal/GBCodePlayBack.records.length*100); 1429 percertagenum = Math.ceil(GBCodePlayBack.triggertotal/GBCodePlayBack.records.length*100);
@@ -1565,8 +1571,8 @@ $(function(){ @@ -1565,8 +1571,8 @@ $(function(){
1565 }) 1571 })
1566 1572
1567 $('#re-sure').click(function(){ 1573 $('#re-sure').click(function(){
1568 - console.log('sdkddd')  
1569 initRecoding() 1574 initRecoding()
  1575 + $('#start-recording').trigger('click');
1570 }) 1576 })
1571 1577
1572 $('#re-cancel').click(function(){ 1578 $('#re-cancel').click(function(){
@@ -1747,8 +1753,6 @@ $(function(){ @@ -1747,8 +1753,6 @@ $(function(){
1747 1753
1748 // 播发代码 1754 // 播发代码
1749 function playCoder(){ 1755 function playCoder(){
1750 - GBCodePlayBack.htmlplayereditor.setValue('');  
1751 - var myAudio = $('#play_audio');  
1752 //禁用修改 1756 //禁用修改
1753 if(!$('#replaydone').data("readonly")){ 1757 if(!$('#replaydone').data("readonly")){
1754 $('#replaydone').trigger('click'); 1758 $('#replaydone').trigger('click');
@@ -1757,16 +1761,14 @@ $(function(){ @@ -1757,16 +1761,14 @@ $(function(){
1757 $('#recordertab a:eq(1)').tab('show'); 1761 $('#recordertab a:eq(1)').tab('show');
1758 1762
1759 var playstatus = $('#play').data('status'); 1763 var playstatus = $('#play').data('status');
1760 - // if(document.URL.indexOf('player.html')>=0){  
1761 - // if(playstatus){  
1762 - // GBCodePlayBack.pauseData = new Date().getTime(); // 暂停的时间  
1763 - // myAudio[0].pause();  
1764 - // $('#play').find('i').removeClass('icon-playcopy').addClass('icon-play').attr('data-original-title', '播放');  
1765 - // }else{  
1766 - // myAudio[0].play();  
1767 - // $('#play').find('i').removeClass('icon-play').addClass('icon-playcopy').attr('data-original-title', '暂停');  
1768 - // }  
1769 - // } 1764 +
  1765 + if(document.URL.indexOf('player.html')>=0){
  1766 + if(playstatus){
  1767 + GBCodePlayBack.pauseData = new Date().getTime(); // 暂停的时间
  1768 + }else{
  1769 + GBCodePlayBack.htmlplayereditor.setValue('');
  1770 + }
  1771 + }
1770 1772
1771 if(!playstatus){ 1773 if(!playstatus){
1772 var playbackrecord = GBCodePlayBack.records, 1774 var playbackrecord = GBCodePlayBack.records,
@@ -1783,7 +1785,7 @@ $(function(){ @@ -1783,7 +1785,7 @@ $(function(){
1783 if (GBCodePlayBack.pauseData) { 1785 if (GBCodePlayBack.pauseData) {
1784 if (tag === 1) { 1786 if (tag === 1) {
1785 GBCodePlayBack.stopIntervalTime = playbackrecord[0].intervaltime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart); 1787 GBCodePlayBack.stopIntervalTime = playbackrecord[0].intervaltime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
1786 - starttime = GBCodePlayBack.stopIntervalTime 1788 + starttime = GBCodePlayBack.stopIntervalTime;
1787 tag++; 1789 tag++;
1788 }else{ 1790 }else{
1789 GBCodePlayBack.stopIntervalTime = GBCodePlayBack.stopIntervalTime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart); 1791 GBCodePlayBack.stopIntervalTime = GBCodePlayBack.stopIntervalTime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
@@ -1918,12 +1920,16 @@ $(function(){ @@ -1918,12 +1920,16 @@ $(function(){
1918 1920
1919 1921
1920 function contrlPause(){ 1922 function contrlPause(){
  1923 +
1921 $('.compile-reslut').hide(); 1924 $('.compile-reslut').hide();
1922 $('.compile-loading').show(); 1925 $('.compile-loading').show();
1923 1926
1924 $('#pause').removeClass('show').addClass('hidden'); 1927 $('#pause').removeClass('show').addClass('hidden');
1925 $('#start-recording').show(); 1928 $('#start-recording').show();
1926 $('.pause-shodow').removeClass('show').addClass('hidden'); 1929 $('.pause-shodow').removeClass('show').addClass('hidden');
  1930 +
  1931 + $('#pause').data('pause', '1');
  1932 + Hourglass.pauseTimer();
1927 recorder.pause(); // 继续录制 1933 recorder.pause(); // 继续录制
1928 } 1934 }
1929 1935
@@ -1935,9 +1941,11 @@ $(function(){ @@ -1935,9 +1941,11 @@ $(function(){
1935 type: "PUT", 1941 type: "PUT",
1936 url: gxb_api + "/programming/learn/chapter/" + _chapterId + "/user/" + _userId, 1942 url: gxb_api + "/programming/learn/chapter/" + _chapterId + "/user/" + _userId,
1937 success: function(data){ 1943 success: function(data){
  1944 + console.log(data);
1938 }, 1945 },
1939 - error: function(){  
1940 - console.log('') 1946 + error: function(data){
  1947 + console.log('播放结束错误');
  1948 + console.log(data);
1941 } 1949 }
1942 }); 1950 });
1943 } 1951 }
src/js/recorder/Myna.js
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 var HZRecorder = function(stream, config) { 6 var HZRecorder = function(stream, config) {
7 config = config || {}; 7 config = config || {};
8 config.sampleBits = config.sampleBits || 8; //采样数位 8, 16 8 config.sampleBits = config.sampleBits || 8; //采样数位 8, 16
9 - config.sampleRate = config.sampleRate || 44100; //采样率(1/6 44100) 9 + config.sampleRate = config.sampleRate || 11025; //采样率(1/6 44100)
10 10
11 var context = new(window.webkitAudioContext || window.AudioContext)(); 11 var context = new(window.webkitAudioContext || window.AudioContext)();
12 var audioInput = context.createMediaStreamSource(stream); 12 var audioInput = context.createMediaStreamSource(stream);
src/player.html
@@ -131,7 +131,6 @@ @@ -131,7 +131,6 @@
131 </div> 131 </div>
132 132
133 <div class="" id="audioWrap"> 133 <div class="" id="audioWrap">
134 -  
135 <button id="full-screen"> 134 <button id="full-screen">
136 <i class="icon iconfont icon-fangda"></i> 135 <i class="icon iconfont icon-fangda"></i>
137 </button> 136 </button>
@@ -139,7 +138,7 @@ @@ -139,7 +138,7 @@
139 <i class="icon iconfont icon-fangda"></i> 138 <i class="icon iconfont icon-fangda"></i>
140 </button> 139 </button>
141 </div> 140 </div>
142 - <button id="play" class="" style="display: none;" data-status='0' title="暂停"> 141 + <button id="play" class="hidden" data-status='0' title="暂停">
143 <i class="icon iconfont icon-playcopy"></i> 142 <i class="icon iconfont icon-playcopy"></i>
144 </button> 143 </button>
145 <!-- <div class="play-bar"> 144 <!-- <div class="play-bar">
src/scss/recording.scss
@@ -534,6 +534,7 @@ button{ @@ -534,6 +534,7 @@ button{
534 .btn{ 534 .btn{
535 width: 80px; 535 width: 80px;
536 background-size: 70%; 536 background-size: 70%;
  537 + background: transparent;
537 border: none; 538 border: none;
538 } 539 }
539 .recording{ 540 .recording{
@@ -629,6 +630,20 @@ button{ @@ -629,6 +630,20 @@ button{
629 transform: translate(-50%, -50%); 630 transform: translate(-50%, -50%);
630 } 631 }
631 } 632 }
  633 +.re-tips, .pause-shodow{
  634 + .btn-success{
  635 + background-color: #1FB6FF;
  636 + border: none;
  637 + box-shadow: 0 1px 5px;
  638 + }
  639 + .btn-danger{
  640 + background-color: #FFFFFF;
  641 + color: #6E787F;
  642 + border: none;
  643 + box-shadow: 0 1px 5px;
  644 + }
  645 +}
  646 +
632 // ti 647 // ti
633 .re-tips{ 648 .re-tips{
634 position: absolute; 649 position: absolute;