Is there anyway to create a Rewind / Forward buttons?

  • Question
  • Updated 4 years ago
  • Answered
I'm trying to create a rewind and forward button for the player but i don't get it to work :(

I was trying to use the code this guys were discused here http://getsatisfaction.com/schillmani... but i can't get it working.

Is there anyone that could help me to do so?? i attempted to use setPosition but i suck so it didn't work. I mean it allowed me to start from the time y set but i want to be able to click in the button and ADD the time or percentage i have in the funcction to the current position that is playing.
Photo of somers jack

somers jack

  • 2 Posts
  • 0 Reply Likes
  • frustrated

Posted 4 years ago

  • 1
Photo of Scott

Scott, Official Rep

  • 3813 Posts
  • 247 Reply Likes
Setting position can get a bit tricky while a sound is still loading, but if you wanted to have a function that does a seek by a relative position while a sound is playing, something like this might work..
function relativeSeek(soundID, percent) {

// given a sound, seek by a percentage of the total duration.
var s = soundManager.getSoundById(soundID);
if (!s || !s.playState || !s.duration) {
return false;
}
s.setPosition(s.position + (s.duration * (percent/100)));
}
// for example...
relativeSeek('mySound', 10); // "fast forward" 10%
relativeSeek('mySound', -5); // "rewind" 5%
Side disclaimer/note: I wrote this off the top of my head, but it should work. ;)

If you want to simply have a sound start from the beginning while it's playing, you can call
soundManager.setPosition('mySound', 0);
or whatever the relevant sound ID is.
Photo of somers jack

somers jack

  • 2 Posts
  • 0 Reply Likes
DUDE YOU'ARE AWESOME IT WORKS THE WAY I WANTED YAAAAAY :D
thanks for your help and time :)
Photo of Scott

Scott, Official Rep

  • 3813 Posts
  • 247 Reply Likes
Nice, I was thinking that should work. ;)