项目中我们在web页面设计了MP3播放控件,在全屏界面,当点击播放进度条想实现快进,结果却是歌曲重新从头播放。这种状况仅在Chrome下正常实现,而在IE9,FF中都是重头播放音频。利用e=e||window.event做了区别对待,但还是不行.
代码如下:
changeProgress: function(e, elem)
{
  var x= e.pageX - ($(document).width() - 900)/2 - elem.offsetLeft;
  if (!Music.isFlash)
  {
    var song = document.getElementById('currsong');
    if (song !== null)
    {
      // If x is less than 16 (the initial pixel value of the bar), set time to the start of the song
       if (x >= 16)
         song.currentTime = Math.round((x - 16) * song.duration / 484);
       else
         song.currentTime = 0;
    }
  }
  else
  {
    var swf = document.getElementById(fpName);//fpName=ALTPLAYER
    if (swf !== null)
    {
      // If x is less than 16 (the initial pixel value of the bar), set time to the start of the song
      if (x >= 16)
        swf.setSeek(Math.round((x - 16) * swf.getLength() / 484));
      else
        swf.setSeek(0);
    }
  }
}
请大侠指教~~

解决方案 »

  1.   

    if (song !== null)
    这个地方改成
    if (song != null)
    这样可以不
      

  2.   

    问题是在chrome下鼠标点击进程条的某个位置时可以实现快进播放功能啊。而且,在其它浏览器如IE9和FF下也只是说该音频文件又回到起点播放,重新计算进程和时间,由此song不可能为空。经FireDebugger检测,也可以发现song不为空的。
    的确不太清楚跨浏览器的问题,请多赐教啊
      

  3.   

    Seems the problem lies in the swf that refers to that of flash player. IE and FF choose the swf player and swf.setSeek(time) malfunctions in this way.
    The only solution here is to switch other audio/mpeg player that could be supported across browsers.