forked from mrlan/EnglishPal
Compare commits
2 Commits
Bug546-Lix
...
Bug547_Fan
Author | SHA1 | Date |
---|---|---|
范雯琦 | bf23f3f8a1 | |
范雯琦 | b4a4bd6723 |
|
@ -3,6 +3,7 @@ var Reader = (function() {
|
|||
let current_position = 0;
|
||||
let original_position = 0;
|
||||
let to_speak = "";
|
||||
let current_rate = 1; // 添加这一行,设置默认速率为 1
|
||||
|
||||
function makeUtterance(str, rate) {
|
||||
let msg = new SpeechSynthesisUtterance(str);
|
||||
|
@ -24,12 +25,24 @@ var Reader = (function() {
|
|||
reader.speak(msg);
|
||||
}
|
||||
|
||||
function updateRate(rate) {
|
||||
// 停止当前的朗读
|
||||
stopRead();
|
||||
|
||||
// 更新当前速率
|
||||
current_rate = rate;
|
||||
|
||||
// 重新开始朗读
|
||||
read(to_speak, current_rate);
|
||||
}
|
||||
|
||||
function stopRead() {
|
||||
reader.cancel();
|
||||
}
|
||||
|
||||
return {
|
||||
read: read,
|
||||
stopRead: stopRead
|
||||
stopRead: stopRead,
|
||||
updateRate: updateRate // 添加这一行,将 updateRate 方法暴露出去
|
||||
};
|
||||
}) ();
|
||||
|
|
|
@ -244,11 +244,16 @@
|
|||
$('#read_all').show();
|
||||
}
|
||||
}
|
||||
document.getElementById('rangeComponent').addEventListener('input', function() {
|
||||
var rate = this.value;
|
||||
Reader.updateRate(rate);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
<style>
|
||||
mark {
|
||||
color: #{{ yml['highlight']['color'] }};
|
||||
color: {{ yml['highlight']['color'] }};
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue