Commit 1f68350eedb1b7260a9a939c7d1bd8ae0d7e193a

Authored by ykxie
1 parent 9b7bbdec

fix bug

src/css/recording.css
... ... @@ -413,6 +413,7 @@ button {
413 413 .recording-ctrl-bar .btn {
414 414 width: 80px;
415 415 background-size: 70%;
  416 + background: transparent;
416 417 border: none; }
417 418 .recording-ctrl-bar .recording {
418 419 background: url("../img/recording.svg") no-repeat center; }
... ... @@ -482,6 +483,17 @@ button {
482 483 left: 50%;
483 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 497 .re-tips {
486 498 position: absolute;
487 499 top: 0;
... ...
src/js/gbreplayer.js
... ... @@ -384,10 +384,12 @@ $(function(){
384 384 ,debuggers: false
385 385 ,allowSeek: false
386 386 ,playCallback: function(){
387   - playCoder();
  387 + // playCoder();
  388 + $('#play').trigger('click');
388 389 }
389 390 ,pauseCallback: function(){
390   - playCoder();
  391 + // playCoder();
  392 + $('#play').trigger('click');
391 393 }
392 394 ,seekedCallback: function(){}
393 395 ,endedCallback: function(){
... ... @@ -433,24 +435,14 @@ $(function(){
433 435 }
434 436  
435 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 439 var playstatus = $(this).data('status');
  440 +
447 441 if(document.URL.indexOf('player.html')>=0){
448 442 if(playstatus){
449 443 GBCodePlayBack.pauseData = new Date().getTime(); // 暂停的时间
450   - myAudio[0].pause();
451 444 $('#play').find('i').removeClass('icon-playcopy').addClass('icon-play').attr('data-original-title', '播放');
452 445 }else{
453   - myAudio[0].play();
454 446 $('#play').find('i').removeClass('icon-play').addClass('icon-playcopy').attr('data-original-title', '暂停');
455 447 }
456 448 }
... ... @@ -474,11 +466,13 @@ $(function(){
474 466 if (GBCodePlayBack.pauseData) {
475 467 if (tag === 1) {
476 468 GBCodePlayBack.stopIntervalTime = playbackrecord[0].intervaltime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
477   - starttime = GBCodePlayBack.stopIntervalTime
  469 + starttime = GBCodePlayBack.stopIntervalTime;
  470 + console.log('+++++++++++++++++++++++++++' + starttime);
478 471 tag++;
479 472 }else{
480 473 GBCodePlayBack.stopIntervalTime = GBCodePlayBack.stopIntervalTime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
481 474 starttime = GBCodePlayBack.stopIntervalTime;
  475 + console.log('&&&&&&&&&&&&&&&&&&&&&&&&&&' + starttime);
482 476 }
483 477 }
484 478  
... ... @@ -888,7 +882,11 @@ $(function(){
888 882 var recorddata = {
889 883 intervaltime: GBCodePlayBack.records[i].intervaltime,
890 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 892 recorddatas.push(recorddata);
... ... @@ -899,7 +897,7 @@ $(function(){
899 897  
900 898 var keepTimer = $('.recording-time').val()
901 899 replaydto.totaltime = parseInt(keepTimer);
902   -
  900 + console.log(replaydto);
903 901 if(_role == 0){
904 902 replaydto.codeRecordList = recorddatas;
905 903 $.ajax({
... ... @@ -1019,8 +1017,10 @@ $(function(){
1019 1017 GBCodePlayBack.record_pause_time = new Date().getTime(); // 暂停的时间
1020 1018  
1021 1019 Hourglass.pauseTimer(); // 暂停计时器
  1020 + console.log('-------------暂停计时器---------------');
1022 1021  
1023   - // $('#pause').data('status', '1');
  1022 + $('#pause').data('status', '1');
  1023 + $('#pause').data('pause', '0');
1024 1024 $('#pause').removeClass('hidden').addClass('show');
1025 1025 $('#start-recording').hide();
1026 1026 recorder.pause();
... ... @@ -1066,10 +1066,15 @@ $(function(){
1066 1066  
1067 1067 // 保存编译结果
1068 1068 $('#save_compile').click(function(){
1069   - Hourglass.pauseTimer();
1070   -
1071 1069 var length = GBCodePlayBack.records.length - 1;
  1070 +
1072 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 1078 console.log(GBCodePlayBack.records);
1074 1079 GBCodePlayBack.record_continue_time = new Date().getTime();
1075 1080  
... ... @@ -1079,7 +1084,6 @@ $(function(){
1079 1084  
1080 1085 // 不保存编译结果
1081 1086 $('#cancel_compile').click(function(){
1082   - Hourglass.pauseTimer();
1083 1087 contrlPause()
1084 1088 GBCodePlayBack.record_continue_time = new Date().getTime();
1085 1089 })
... ... @@ -1352,11 +1356,11 @@ $(function(){
1352 1356  
1353 1357 var pausetatus = $('#pause').data('status');
1354 1358  
1355   - console.log(pausetatus)
  1359 + console.log(pausetatus);
1356 1360  
1357 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 1365 $('#pause').data('status', '0');
1362 1366  
... ... @@ -1398,14 +1402,17 @@ $(function(){
1398 1402 record.trigger = 1; //标记已运行
1399 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 1414 console.log(record);
  1415 +
1409 1416 if(replay_type){
1410 1417 GBCodePlayBack.excercise_triggertotal += 1;
1411 1418 }else{
... ... @@ -1416,8 +1423,7 @@ $(function(){
1416 1423 var percertage = '0%',percertagenum=0;
1417 1424 if(replay_type){
1418 1425 percertagenum = Math.ceil(GBCodePlayBack.excercise_triggertotal/GBCodePlayBack.excercise_records.length*100)
1419   - percertage = percertagenum + '%';
1420   -
  1426 + percertage = percertagenum + '%';
1421 1427 }else{
1422 1428 if(!offset){
1423 1429 percertagenum = Math.ceil(GBCodePlayBack.triggertotal/GBCodePlayBack.records.length*100);
... ... @@ -1565,8 +1571,8 @@ $(function(){
1565 1571 })
1566 1572  
1567 1573 $('#re-sure').click(function(){
1568   - console.log('sdkddd')
1569 1574 initRecoding()
  1575 + $('#start-recording').trigger('click');
1570 1576 })
1571 1577  
1572 1578 $('#re-cancel').click(function(){
... ... @@ -1747,8 +1753,6 @@ $(function(){
1747 1753  
1748 1754 // 播发代码
1749 1755 function playCoder(){
1750   - GBCodePlayBack.htmlplayereditor.setValue('');
1751   - var myAudio = $('#play_audio');
1752 1756 //禁用修改
1753 1757 if(!$('#replaydone').data("readonly")){
1754 1758 $('#replaydone').trigger('click');
... ... @@ -1757,16 +1761,14 @@ $(function(){
1757 1761 $('#recordertab a:eq(1)').tab('show');
1758 1762  
1759 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 1773 if(!playstatus){
1772 1774 var playbackrecord = GBCodePlayBack.records,
... ... @@ -1783,7 +1785,7 @@ $(function(){
1783 1785 if (GBCodePlayBack.pauseData) {
1784 1786 if (tag === 1) {
1785 1787 GBCodePlayBack.stopIntervalTime = playbackrecord[0].intervaltime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
1786   - starttime = GBCodePlayBack.stopIntervalTime
  1788 + starttime = GBCodePlayBack.stopIntervalTime;
1787 1789 tag++;
1788 1790 }else{
1789 1791 GBCodePlayBack.stopIntervalTime = GBCodePlayBack.stopIntervalTime - (GBCodePlayBack.pauseData - GBCodePlayBack.playRecordStart);
... ... @@ -1918,12 +1920,16 @@ $(function(){
1918 1920  
1919 1921  
1920 1922 function contrlPause(){
  1923 +
1921 1924 $('.compile-reslut').hide();
1922 1925 $('.compile-loading').show();
1923 1926  
1924 1927 $('#pause').removeClass('show').addClass('hidden');
1925 1928 $('#start-recording').show();
1926 1929 $('.pause-shodow').removeClass('show').addClass('hidden');
  1930 +
  1931 + $('#pause').data('pause', '1');
  1932 + Hourglass.pauseTimer();
1927 1933 recorder.pause(); // 继续录制
1928 1934 }
1929 1935  
... ... @@ -1935,9 +1941,11 @@ $(function(){
1935 1941 type: "PUT",
1936 1942 url: gxb_api + "/programming/learn/chapter/" + _chapterId + "/user/" + _userId,
1937 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 6 var HZRecorder = function(stream, config) {
7 7 config = config || {};
8 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 11 var context = new(window.webkitAudioContext || window.AudioContext)();
12 12 var audioInput = context.createMediaStreamSource(stream);
... ...
src/player.html
... ... @@ -131,7 +131,6 @@
131 131 </div>
132 132  
133 133 <div class="" id="audioWrap">
134   -
135 134 <button id="full-screen">
136 135 <i class="icon iconfont icon-fangda"></i>
137 136 </button>
... ... @@ -139,7 +138,7 @@
139 138 <i class="icon iconfont icon-fangda"></i>
140 139 </button>
141 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 142 <i class="icon iconfont icon-playcopy"></i>
144 143 </button>
145 144 <!-- <div class="play-bar">
... ...
src/scss/recording.scss
... ... @@ -534,6 +534,7 @@ button{
534 534 .btn{
535 535 width: 80px;
536 536 background-size: 70%;
  537 + background: transparent;
537 538 border: none;
538 539 }
539 540 .recording{
... ... @@ -629,6 +630,20 @@ button{
629 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 647 // ti
633 648 .re-tips{
634 649 position: absolute;
... ...