项目中我们在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);
}
}
}
请大侠指教~~
代码如下:
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);
}
}
}
请大侠指教~~
这个地方改成
if (song != null)
这样可以不
的确不太清楚跨浏览器的问题,请多赐教啊
The only solution here is to switch other audio/mpeg player that could be supported across browsers.