我的項目7 js 實現歌詞同步(額,小小的效果),
在項目中需要做一個播放器,還要實現歌詞同步的效果,就跟現在搜狗音樂的歌詞同步差不多,在網上查了一些關於這方面的,整理了一下,在這裡,其實用這個方法可以嗎?
<!DOCTYPE html><html><head><meta charset="utf-8" /><title></title><script type="text/javascript" src="js/jquery.min.js" ></script><script type="text/javascript">window.setInterval("dd()",200);var i=0;function dd(){i=i+10;//alert(i)document.getElementById("mydiv2").style.width=i+"px"; }function x(){//alert("-----")document.getElementById("mydiv2").style.color="red";}</script></head><body> <div class="mydiv1" style="position: absolute; z-index: 1;"> <h1>影月瑩瑩哈哈哈哈哈哈</h1> </div> <div class="mydiv2" id="mydiv2" style="position: absolute; z-index:2; color: blue; width: 100px; overflow:hidden;text-overflow:ellipsis;white-space:nowrap;"> <h1>影月瑩瑩哈哈哈哈哈哈</h1> </div> <button id="mybutton" onclick="x()" style="height: 100px; width: 200px; margin-top: 100px;">電機 </button></body></html>在這裡,,我用了一個這種方法,不知行不行的通 ,,至於歌詞同步,就調時間吧,向網上一些部落格,,看了都是需要AJAX解析歌曲檔案,擷取歌詞,歌詞時間,實現歌詞同步,在這裡,如果只是一兩首歌曲,自己調一調時間也行吧。。。。,至於大家有什麼看法。。額額。。。嘿嘿