播放事件未在HTML5小部件上启动时触发 [英] Play event not firing on start on HTML5 widget
问题描述
当SoundCloud HTML5播放器窗口小部件加载 autoplay
选项时,播放
事件在轨道启动时不会触发。
但是在加载小部件(或将其他URL加载到小部件中)与轨道启动之间存在超时时间,因此调用该事件是一个不错的小部件。
When SoundCloud HTML5 Player Widget is loaded with autoplay
option, play
event not firing when track starts.
However there is a timeout between loading the widget (or loading other URL into the widget) and when the track starts, so it's nice widget to call the event.
这是设计还是要解决的问题?
Is this by design or is it issue to be solved?
推荐答案
HTML5播放器小部件应该触发SC.Widget。使用auto_play选项时的Events.PLAY事件。这是我用来验证的代码段:
The HTML5 Player widget should fire a SC.Widget.Events.PLAY event when the auto_play option is used. Here's a code snippet I used to verify:
HTML:
<!doctype html>
<html>
<head>
<title>Widget Demo</title>
<style type="text/css">
iframe {
display:block;
border:0;
margin-bottom: 20px;
height: 365px;
}
</style>
</head>
<body>
<iframe id="widget" width="100%"></iframe>
</body>
<script src="http://w.soundcloud.com/player/api.js"></script>
<script src="script.js"></script>
</html>
JavaScript(script.js的内容):
JavaScript (the contents of script.js):
(function() {
var iframe = document.querySelector('#widget');
iframe.src = 'http://w.soundcloud.com/player/?url=http://api.soundcloud.com/tracks/43315398&auto_play=true';
var widget = SC.Widget(iframe);
widget.bind(SC.Widget.Events.PLAY, function(eventData) {
alert('Playing...');
});
}());
你可以查看一个有效的例子这里有jsfiddle 。
You can check out a working example here on jsfiddle.
这篇关于播放事件未在HTML5小部件上启动时触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!