Commit 8f8a761dc3b5e506f1738a13baaaf176ec6f201e
1 parent
f94f0a7a
播放暂停
Showing
1 changed file
with
11 additions
and
36 deletions
src/js/gbreplayer.js
| @@ -390,6 +390,8 @@ $(function(){ | @@ -390,6 +390,8 @@ $(function(){ | ||
| 390 | playCode(); | 390 | playCode(); |
| 391 | } | 391 | } |
| 392 | ,pauseCallback: function(){ // 暂停 | 392 | ,pauseCallback: function(){ // 暂停 |
| 393 | + GBCodePlayBack.audioTime = parseInt(player.elements.audioDom.currentTime*1000) | ||
| 394 | + console.log(parseInt(player.elements.audioDom.currentTime*1000)); | ||
| 393 | pauseCode(); | 395 | pauseCode(); |
| 394 | GBCodePlayBack.firstPlay = 0; | 396 | GBCodePlayBack.firstPlay = 0; |
| 395 | GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue(); | 397 | GBCodePlayBack.pauseValue = GBCodePlayBack.htmlplayereditor.getValue(); |
| @@ -901,6 +903,7 @@ $(function(){ | @@ -901,6 +903,7 @@ $(function(){ | ||
| 901 | 903 | ||
| 902 | var keepTimer = $('.recording-time').val() | 904 | var keepTimer = $('.recording-time').val() |
| 903 | replaydto.totaltime = parseInt(keepTimer); | 905 | replaydto.totaltime = parseInt(keepTimer); |
| 906 | + console.log(JSON.stringify(replaydto)); | ||
| 904 | if(_role == 0){ | 907 | if(_role == 0){ |
| 905 | replaydto.codeRecordList = recorddatas; | 908 | replaydto.codeRecordList = recorddatas; |
| 906 | $.ajax({ | 909 | $.ajax({ |
| @@ -1279,6 +1282,7 @@ $(function(){ | @@ -1279,6 +1282,7 @@ $(function(){ | ||
| 1279 | if($('#play').data('status')==1){ | 1282 | if($('#play').data('status')==1){ |
| 1280 | $('#play').trigger('click'); | 1283 | $('#play').trigger('click'); |
| 1281 | } | 1284 | } |
| 1285 | + player.pauseCallback(); | ||
| 1282 | } | 1286 | } |
| 1283 | } | 1287 | } |
| 1284 | // set the initial state | 1288 | // set the initial state |
| @@ -1511,7 +1515,7 @@ $(function(){ | @@ -1511,7 +1515,7 @@ $(function(){ | ||
| 1511 | 1515 | ||
| 1512 | // 开始录制 | 1516 | // 开始录制 |
| 1513 | $('#start-recording').click(function(){ | 1517 | $('#start-recording').click(function(){ |
| 1514 | - // 编译状态 | 1518 | + // 编译状态 |
| 1515 | var data = $(this).attr('data'); | 1519 | var data = $(this).attr('data'); |
| 1516 | var seconds = 0; | 1520 | var seconds = 0; |
| 1517 | $("#countdown").show(); | 1521 | $("#countdown").show(); |
| @@ -1798,7 +1802,6 @@ $(function(){ | @@ -1798,7 +1802,6 @@ $(function(){ | ||
| 1798 | } | 1802 | } |
| 1799 | 1803 | ||
| 1800 | function playCode(){ | 1804 | function playCode(){ |
| 1801 | - // GBCodePlayBack.htmlplayereditor.setValue('') | ||
| 1802 | if (GBCodePlayBack.firstPlay == 0) { | 1805 | if (GBCodePlayBack.firstPlay == 0) { |
| 1803 | $('#readonly').trigger('click'); | 1806 | $('#readonly').trigger('click'); |
| 1804 | GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue) | 1807 | GBCodePlayBack.htmlplayereditor.setValue(GBCodePlayBack.pauseValue) |
| @@ -1815,38 +1818,18 @@ $(function(){ | @@ -1815,38 +1818,18 @@ $(function(){ | ||
| 1815 | 1818 | ||
| 1816 | var playbackrecord = GBCodePlayBack.records; | 1819 | var playbackrecord = GBCodePlayBack.records; |
| 1817 | var starttime = 0; | 1820 | var starttime = 0; |
| 1818 | - var stopIntervalTime; | 1821 | + var playTotalTime = 0; |
| 1819 | 1822 | ||
| 1820 | console.log(playbackrecord) | 1823 | console.log(playbackrecord) |
| 1821 | - for(var j = 0; j < playbackrecord.length; j++){ | ||
| 1822 | - if (playbackrecord[j].trigger === 1) { | ||
| 1823 | - GBCodePlayBack.playRecordStart = playbackrecord[j].playTime; | ||
| 1824 | - playbackrecord.shift() | ||
| 1825 | - }else{ | ||
| 1826 | - break; | ||
| 1827 | - } | ||
| 1828 | - } | ||
| 1829 | - console.log(playbackrecord) | ||
| 1830 | for (var i = 0; i < playbackrecord.length; i++) { | 1824 | for (var i = 0; i < playbackrecord.length; i++) { |
| 1831 | - if (playbackrecord[i].trigger === 0) { | 1825 | + if (playbackrecord[i].trigger === 1) { |
| 1826 | + playTotalTime += parseInt(playbackrecord[i].intervaltime); | ||
| 1827 | + }else if (playbackrecord[i].trigger === 0) { | ||
| 1832 | var timeoutcontroller = null; | 1828 | var timeoutcontroller = null; |
| 1833 | var replayinterval = playbackrecord[i].intervaltime; | 1829 | var replayinterval = playbackrecord[i].intervaltime; |
| 1834 | 1830 | ||
| 1835 | if (!GBCodePlayBack.isPause) { | 1831 | if (!GBCodePlayBack.isPause) { |
| 1836 | - stopIntervalTime = GBCodePlayBack.pauseTime - GBCodePlayBack.playRecordStart; | ||
| 1837 | - playbackrecord[i].intervaltime = playbackrecord[i].intervaltime - stopIntervalTime; | ||
| 1838 | - starttime = playbackrecord[i].intervaltime; | ||
| 1839 | - // if (i === 0) { | ||
| 1840 | - // // 暂停后重制 intervaltime | ||
| 1841 | - // stopIntervalTime = GBCodePlayBack.pauseTime - GBCodePlayBack.playRecordStart; | ||
| 1842 | - // playbackrecord[i].intervaltime = playbackrecord[i].intervaltime - stopIntervalTime; | ||
| 1843 | - // starttime = playbackrecord[i].intervaltime; | ||
| 1844 | - // }else{ | ||
| 1845 | - // // 已有播放的代码 | ||
| 1846 | - // GBCodePlayBack.stopIntervalTime = GBCodePlayBack.pauseTime - playbackrecord[i - 1].playTime; | ||
| 1847 | - // playbackrecord[i].intervaltime = playbackrecord[i].intervaltime - GBCodePlayBack.stopIntervalTime; | ||
| 1848 | - // starttime = playbackrecord[i].intervaltime; | ||
| 1849 | - // } | 1832 | + starttime = replayinterval - (GBCodePlayBack.audioTime - playTotalTime); |
| 1850 | GBCodePlayBack.isPause = 1 | 1833 | GBCodePlayBack.isPause = 1 |
| 1851 | }else{ | 1834 | }else{ |
| 1852 | if (i == 0) { | 1835 | if (i == 0) { |
| @@ -1861,9 +1844,6 @@ $(function(){ | @@ -1861,9 +1844,6 @@ $(function(){ | ||
| 1861 | } | 1844 | } |
| 1862 | } | 1845 | } |
| 1863 | console.log(GBCodePlayBack.recordtimeoutcontrolls); | 1846 | console.log(GBCodePlayBack.recordtimeoutcontrolls); |
| 1864 | - // 记录播放的时间 | ||
| 1865 | - GBCodePlayBack.playRecordStart = new Date().getTime(); | ||
| 1866 | - | ||
| 1867 | } | 1847 | } |
| 1868 | 1848 | ||
| 1869 | function pauseCode(){ | 1849 | function pauseCode(){ |
| @@ -1875,11 +1855,6 @@ $(function(){ | @@ -1875,11 +1855,6 @@ $(function(){ | ||
| 1875 | } | 1855 | } |
| 1876 | GBCodePlayBack.recordtimeoutcontrolls = []; | 1856 | GBCodePlayBack.recordtimeoutcontrolls = []; |
| 1877 | GBCodePlayBack.recordtimeouts = []; | 1857 | GBCodePlayBack.recordtimeouts = []; |
| 1878 | - | ||
| 1879 | - // 每次暂停的时间 | ||
| 1880 | - GBCodePlayBack.pauseTime = new Date().getTime(); | ||
| 1881 | - | ||
| 1882 | - console.log(GBCodePlayBack.pauseTime) | ||
| 1883 | } | 1858 | } |
| 1884 | 1859 | ||
| 1885 | 1860 | ||
| @@ -2019,7 +1994,7 @@ $(function(){ | @@ -2019,7 +1994,7 @@ $(function(){ | ||
| 2019 | } | 1994 | } |
| 2020 | 1995 | ||
| 2021 | GBCodePlayBack.firstPlay = 1; | 1996 | GBCodePlayBack.firstPlay = 1; |
| 2022 | - | 1997 | + console.log(GBCodePlayBack.records); |
| 2023 | /* 初始化播放 */ | 1998 | /* 初始化播放 */ |
| 2024 | $('#play').data('status', 0); | 1999 | $('#play').data('status', 0); |
| 2025 | for (var i = 0; i < GBCodePlayBack.records.length; i++) { | 2000 | for (var i = 0; i < GBCodePlayBack.records.length; i++) { |