我想在加载时设置Sound Manager Player的位置。例如,这里是URL:http://wp.simplepressplugins.com/sls247-what-content-you-should-be-using-for-2020/?t=300
if (isset($_GET['t']))
{
$time = $_GET['t'];
$params = array('time' => $time);
wp_localize_script('timestamp-js', 'timestampget', $params);
}
jQuery(window).load(function($) {
if (typeof timestampget !== 'undefined') {
if (timestampget.time) {
var time = timestampget.time;
var soundurl = jQuery(".playercontent").find('.sm2-playlist-wrapper ul li a').attr('href');
// using url converted to md5 hash so we can get it ... md5 function i already created a custom function
var soundId = md5(soundurl);
setTimeout(function() {
window.soundManager.getSoundById(soundId).start();
window.soundManager.getSoundById(soundId).setPosition(time * 1000);
}, 500);
setTimeout(function() {
window.soundManager.getSoundById(Soundid).stop();
}, 800);
}
}
});
当浏览器加载时,我想将播放器栏设置为t=300
,即5分钟
它在Firefox中有效,但在Chrome或Safari(Mac)中无效。
[或者在任何情况下都可以检查setPosition是否完成并将小节移至准确的时间,然后我们可以停止播放器,或者我们可以不玩而只将小节移至给定的时间?
不是使用外部JavaScript,而是尝试使用(SoundManager API)吗?这样做的方法很少,但是在这里,我选择了传递给play()方法的参数。在页面加载时调用此脚本以实现所需的内容。
var sound = soundManager.getSoundById('chinaCymbal');
sound.play({
position: 30000 // 30 seconds into sound
});
或其他选项
var fhDemo = soundManager.createSound({
url: 'http://freshly-ground.com/data/audio/sm2/fitter-happier-64kbps.mp3'
});
function playFrom(nFrom) {
fhDemo.stop();
fhDemo.play({
from: nFrom
});
}
jQuery(window).load(function{
playFrom(30000);
});