Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Soundcloud API / SoundManager2 SetPosition not working before track is playing

I am trying to set the position of a sample in SoundCloud using setPosition to play from a certain time when I call the play() method. I need to set this before the sample starts playing. Right now this code isn't working:

SC.whenStreamingReady(function() {
            var sound = SC.stream("/tracks/141543551");
            sound.play();
            sound.setPosition(300);
        });

However, when I call setPosition while the sample is playing it works just fine.

SC.whenStreamingReady(function() {
                setTimeout(function () {

                sound.pause();

                var positionCallback = function (eventPosition) {
                    this.clearOnPosition(0, positionCallback);
                    this.resume();
                };
                sound.onPosition(0, positionCallback);
                sound.setPosition(30000);


                sound.play();

 }, 5000);

    });

How can I setPosition() before the sample plays?

like image 293
user547794 Avatar asked Mar 27 '14 03:03

user547794


1 Answers

The docs that I found here http://www.schillmania.com/projects/soundmanager2/doc/

Say that this sound.setPosition(300); should look like sound.setPosition('position-name', 300); instead.

like image 98
erikvold Avatar answered Oct 06 '22 00:10

erikvold