私は、行うプロジェクトがあります、javascriptでカラオケを作る。曲が行くと、歌詞が続く必要があります。 javascript現在の時間は動作しません
私のコードのhtml:テキストファイル内<div id="lyric"></div>
<audio id="audioPlayer" controls>
<source src="http://supjs.fr/DEV2018/myKaraoke/music/LOR.mp3" type="audio/mpeg">
</audio>
作詞:
[00:00.00] Fanuilos heryn aglar
[00:10.00]Rînatharannún-aearath
[00:20.00] Calad ammen i reniar
[00:30.00] Mi'aladhremmin ennorath
[00:40.00] A Elbereth!ギルソニエル!
[00:50.00]私は[01:00.00] THA»リットルLINマリエルに
をchînFanuilos!ルlinnathon
[01:09.00]ネオンndorのhaer iはaearon
[01:20.00]エルガイムeglerib
NA ELIN [01:30.00]ネッドînベンanor trerennin
[01:39.00]のSi silivrin NEのpherth「waewib
[01:48.00]
thuiennin Cenim lythlthÃlyn[01:58.00] Elbereth Gilthoniel
[02:08.00]男性echenim SA derthiel
[02:17.00] Neがヘンnu'aladhath
[02:27.00] chaered Ngilithまたはannún-aearath
とJavaScript:
をwindow.onload = function(){
var track = document.getElementById('audioPlayer');
track.ontimeupdate = function(){
console.log(this.currentTime);
if (this.currentTime > 0 && this.curentTime < 9){
getRSS(0);
}
};
};
function getRSS(i) {
var rss = new XMLHttpRequest();
console.log("hello");
rss.open('GET', 'lyrics.txt', false);
console.log("hello1");
rss.send(null);
console.log("hello");
var ligne = rss.responseText.split(/\n/g);/* Stock tout le fichier dans la variable (tableau)*/
console.log("hello");
var linkRss = ligne[i];
document.write(linkRss);
}
それは動作しません、行が表示されますが、音楽停止とオーディオが消えて、私は何か起こっている人が私を助けることができないのですか?あなたの問題はあなたがdocument.write(linkRss);
文であなたのページを上書きしていること、であるgetTime()
あなたのコードに誤字があります: 'this.curentTime'は' this.currentTime'です。私は1分後に回答を投稿します。 –
ああ、はい、私はこれはまだ動作していない問題ではないと思う: '( – Nil