SoundCloud ontimedcomments Event
HTML
<script src="http://connect.soundcloud.com/sdk.js"></script>
<ol id="comments"></ol>
CSS
#comments {
width: 400px;
margin: auto;
margin-top: 30px;
font-family: "Helvetica";
font-size: 14px;
}
#comments li {
border-bottom: 1px solid #eee;
padding-bottom: 5px;
padding-top: 5px;
}
JavaScript
SC.initialize({
client_id: "1edca1472792d51e3e4995751a0c2eea"
});
SC.stream("/tracks/23132314", {
autoPlay: true,
ontimedcomments: function(comments){
// we only handle the first comment for this timestamp
var firstComment = comments[0];
var text = "";
$("<li/>").text(
firstComment.user.username + " (@" +
Math.floor(firstComment.timestamp / 1000) + "s): " +
firstComment.body
).appendTo("#comments");
}
});