2013-05-04 70 views
0

我使用的是使用SoundCloud脚本的ajax页面切换方法。SoundCloud:如何在散列更改时停止播放

如何在用户使用SoundCloud容器离开页面时停止播放音乐?

我发现这些斯托克斯:

// stop all players, might be useful, before replacing the player dynamically 
    $.scPlayer.stopAll = function() { 
    $('.sc-player.playing a.sc-pause').click(); 
    }; 

目前我叫初始化$(".sc-player").scPlayer();.load功能,但我需要在把代码将停止任何页面切换之前播放音频?

回答

0

您可以添加事件侦听器window.onhashchange = stopAll;

和STOPALL的定义()将

stopAll = function() { $('.sc-player.playing a.sc-pause').click(); };

+1

cucko,谢谢!现在它工作了! 对不起,我无法为您添加声誉,因为我无权执行此操作。不管怎样,谢谢! – user1393989 2013-05-06 21:49:00

相关问题