Soundcloud API: how to play only a part of a track?

南楼画角 提交于 2019-12-01 11:54:29

问题


For an upcoming project I am investigating the possibility to play only a certain length (for example 20s) of a track, using the Soundcloud API.

Could anybody indicate me if that is possible, or should a different track with that limited length be created separately?

Many thanks ! Maarten (WebForDreams)


回答1:


There are a few ways you can do this. Are you going to be using the JavaScript SDK or the player widget? For the player widget, you can just use seekTo().

If you're using the JavaScript SDK you can use the setPosition() method:

SC.initialize({
  client_id: 'foo'
});
SC.whenStreamingReady(function() {
  var sound = SC.stream(52933447);
  sound.setPosition(2000); // position, measured in milliseconds
  sound.play();
});

If you want to stop at a particular point, you could use onPosition().

Hope that helps!



来源:https://stackoverflow.com/questions/11820504/soundcloud-api-how-to-play-only-a-part-of-a-track

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!