|
|
|
@ -1,5 +1,42 @@ |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
window.RecordAudio = (function () { |
|
|
|
|
function startTimer() { |
|
|
|
|
$("#timer").show(); |
|
|
|
|
var timerData = { |
|
|
|
|
hour: parseInt($("#hour").text()), |
|
|
|
|
minute: parseInt($("#minute").text()), |
|
|
|
|
second: parseInt($("#second").text()) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
clearInterval(window.timerInterval); |
|
|
|
|
window.timerInterval = setInterval(function(){ |
|
|
|
|
// Seconds
|
|
|
|
|
timerData.second++; |
|
|
|
|
if (timerData.second >= 60) { |
|
|
|
|
timerData.second = 0; |
|
|
|
|
timerData.minute++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Minutes
|
|
|
|
|
if (timerData.minute >= 60) { |
|
|
|
|
timerData.minute = 0; |
|
|
|
|
timerData.hour++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$("#hour").text(timerData.hour < 10 ? '0' + timerData.hour : timerData.hour); |
|
|
|
|
$("#minute").text(timerData.minute < 10 ? '0' + timerData.minute : timerData.minute); |
|
|
|
|
$("#second").text(timerData.second < 10 ? '0' + timerData.second : timerData.second); |
|
|
|
|
}, 1000); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function stopTimer() { |
|
|
|
|
$("#hour").text('00'); |
|
|
|
|
$("#minute").text('00'); |
|
|
|
|
$("#second").text('00'); |
|
|
|
|
$("#timer").hide(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function useRecordRTC(rtcInfo, fileName) { |
|
|
|
|
$(rtcInfo.blockId).show(); |
|
|
|
|
|
|
|
|
@ -82,6 +119,8 @@ window.RecordAudio = (function () { |
|
|
|
|
navigator.getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia || navigator.webkitGetUserMedia; |
|
|
|
|
|
|
|
|
|
function successCallback(stream) { |
|
|
|
|
stopTimer(); |
|
|
|
|
startTimer(); |
|
|
|
|
recordRTC = RecordRTC(stream, { |
|
|
|
|
numberOfAudioChannels: 1, |
|
|
|
|
type: 'audio' |
|
|
|
@ -99,6 +138,7 @@ window.RecordAudio = (function () { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function errorCallback(error) { |
|
|
|
|
stopTimer(); |
|
|
|
|
alert(error.message); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -138,6 +178,7 @@ window.RecordAudio = (function () { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
stopTimer(); |
|
|
|
|
recordRTC.stopRecording(function (audioURL) { |
|
|
|
|
btnStart.prop('disabled', false).removeClass('hidden'); |
|
|
|
|
btnPause.prop('disabled', true).addClass('hidden'); |
|
|
|
|