-
Notifications
You must be signed in to change notification settings - Fork 1
/
sc.html
85 lines (77 loc) · 3.63 KB
/
sc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<html>
<head>
<script type="text/javascript" src="//s3.amazonaws.com/staging.res.milq.com/js/u.js"></script>
<script type="text/javascript" src="//w.soundcloud.com/player/api.js"></script>
</head>
<body>
<!-- Player will go here. -->
</body>
<script type="text/javascript">
(function() {
window.resumePlayback = function() { window.sound.play(); }
window.pausePlayback = function() { window.sound.pause(); };
window.seekToTime=function(timeMillis){window.sound.seekTo(timeMillis)};
window.updatePosition=function(){
self.sound.getPosition(function(len){
window.playerBridge && window.playerBridge.onGetPosition(len);
window.timer=window.setTimeout(updatePosition,100);
});
}
window.startPlayback = function(contentUri) {
this.dom = document.body;
this.streamToPlay = { contenturi: contentUri };
if (!window.SC) {
if (!__pendingLoad) {
__pendingLoad = true;
_u.loadScript("//w.soundcloud.com/player/api.js", function() {
__pendingLoad = false;
});
}
var self = this;
this.pendingPlay = setTimeout(function () { initPlayback.call(self); }, 100);
return;
}
if (this.sound) unbindSCEvents.call(this);
this.dom.innerHTML = '<iframe width="100%" scrolling="no" ' +
'frameborder="no" src="//w.soundcloud.com/player/?color=ff004f&show_artwork=false&show_comments=false&sharing=false&buying=false&show_playcount=false&url='
+ encodeURIComponent(this.streamToPlay.contenturi)
+'" class="sc-widget player_soundcloud_frame"></iframe>';
if (window.SC) {
var iFrame = this.dom.querySelector('iframe');
var self = this, startTimeHandled;
window.sound = SC.Widget(iFrame);
window.sound.bind('ready', function () {
self.sound.bind(SC.Widget.Events.PAUSE, function(data) {
// PAUSED
console.log("paused");
window.playerBridge && window.playerBridge.onPause();
clearTimeout(window.timer);
});
self.sound.bind(SC.Widget.Events.PLAY, function(data) {
// PLAYING
console.log("playing");
window.playerBridge && window.playerBridge.onPlaying();
self.sound.getDuration(function(len){
window.playerBridge && window.playerBridge.onGetDuration(len);
});
window.timer=window.setTimeout(updatePosition,100);
});
self.sound.bind(SC.Widget.Events.FINISH, function(data) {
// FINISH
console.log("finished");
window.playerBridge && window.playerBridge.onFinish();
clearTimeout(window.timer);
});
self.sound.bind(SC.Widget.Events.ERROR, function(err) {
// ERROR
console.log("error: " + err);
window.playerBridge && window.playerBridge.onError(err);
clearTimeout(window.timer);
});
self.sound.play();
});
}
}
})();
</script>
</html>