Control audio playback position with slider ?!


#1

Hi everyone,

I'm am trying to control the position of an audio playback with a slider...I've tried so many times and it doesn't work. The audio plays and everything works fine instead of the slider which fails to control and track the song position.

Take a look at the codes and help me with this problem. :)


void ComponentA::sliderValueChanged(Slider* slider)
{
   
    if (&sliderControl == slider)
    {
        
        transportSource.setPosition(sliderControl.getValue());
        
    }
    
}

I think that this function should change the position of the the song that is playing and I have add a listener for the slider so it must work. Anyway I am new in juce and need a little help from you.:)


#2

It should work, but is your slider's value range correct?


#3

Actually i don't know how to set the Range of the slider because i tried many times and failed. I mean i dont know what values I should set for the min, max and interval in order to control the position.

If you can help me with that it would be great. :)

 


#4

Well, think about it..! You need a position in seconds, so it'd need to go from 0 to the length of the thing you're playing.


#5

Well, thanks for the help. I was thinking and gonna keep thinking till i find out how it works. :P

About the Juce Jules...you have done a great job and I really appreciate it! ;)


#6

Cheers, hope you get your code working!


#7

I hope so. :P

Thanks. ;)