gpt4 book ai didi

javascript - 网站的 Javascript 变体

转载 作者:行者123 更新时间:2023-12-02 16:13:11 26 4
gpt4 key购买 nike

这里的网站有一个音乐播放器http://www.numberonedesigns.com/ubermusic.com/ ...当点击下一个按钮并随机突出显示时,它不会正确随机化。它总是返回到播放列表中的第一首歌曲,然后随机播放下一首歌曲。这是可变代码。我尝试搞乱它一段时间,但决定我需要一些帮助

$next.click(function(){
var num = 0;
$.cookie('plate_time', 1);
if($random.hasClass('active')){
while(num == $audio.currentTrack){num = Math.floor(Math.random() * (opt.playlist.length));}
}else{
num = $audio.currentTrack - 1;
}

$audio.loadTrack(num);
});

$playlist.on('click', '.track', function(){
$audio.loadTrack($(this).attr('rel'));
});

$prev.click(function(){
var num = 0;
$.cookie('plate_time', 0);
if($random.hasClass('active')){
while(num == $audio.currentTrack){num = Math.floor(Math.random() * (opt.playlist.length));}
}else{
num = $audio.currentTrack - 1;
}

$audio.loadTrack(num);
});

最佳答案

既然你问得这么好:

$next.click(function(){
var num = Math.floor(Math.random() * (opt.playlist.length));
//Set the random number here.
$.cookie('plate_time', 1);
if($random.hasClass('active')){
while(num == $audio.currentTrack){num = Math.floor(Math.random() * (opt.playlist.length));}
// leaving it here JIC you get the same track.
}else{
num = $audio.currentTrack - 1;
// cos the ordering still works here if not on random.
}

$audio.loadTrack(num);
});

$playlist.on('click', '.track', function(){
$audio.loadTrack($(this).attr('rel'));
});

$prev.click(function(){
var num = Math.floor(Math.random() * (opt.playlist.length));
$.cookie('plate_time', 0);
if($random.hasClass('active')){
while(num == $audio.currentTrack){num = Math.floor(Math.random() * (opt.playlist.length));}
}else{
num = $audio.currentTrack - 1;
}

$audio.loadTrack(num);
});

关于javascript - 网站的 Javascript 变体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29927483/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com