Play Position


#1

what do these instructions mean: 06 regarding this bit of code:!
void FilePlayerGui::sliderValueChanged(Slider* slider)
{
// std::cout << " : " << playPos.getValue() << " \n" ;
// filePlayer.setPostion(playPos.getValue())

} …when theres no access to setPosition function in this class?


#2

edit: Noticed the tutorial is telling you to add the setPosition method into the FilePlayer class yourself. So you will just have to do that…


#3

Well I wanted to avoid audio processing in the FilePlayerGui? and i think thats what would happen if I make the GUI class inherit the public member setPosition


#4

Doesn’t the tutorial have the full code included? Where is that tutorial anyway?

edit : In any case, do not inherit from a class just to get access to some method. Instead have the other class as a member in the class that wants to use the method. And yeah, you need to be careful when calling audio related methods from the GUI. (Some mutex locking is probably required.)


#5

This is a C++ course exercise its not on the tutorials


#6

ah that makes scene to have a class as a type for a member in another class? Its asking to use FilePlayer& filePlayer; which is in the private section of the FilePlayerGUI…what does the & mean ? because FilePlayer is a separate class which handles the audio file, it has access to AudioTransportSource which i think has the public member function setPosition()…But then why cant i go name a variable type FilePlayer& fileplayer and then say fileplayer.audioTransportSource.setPosition(slider.getValue()); ?


#7

If the compiler complains already about the FilePlayer& fileplayer declaration in the class members, it probably means your constructor is not taking in the reference to the actual fileplayer instance. (Class member references always have to be initialized during construction.)

If it complains about fileplayer.audioTransportSource.setPosition(slider.getValue()), it probably means the audioTransportSource is private to the FilePlayer. So you would need to add the setPosition method in the FilePlayer and call the setPosition of the audioTransportSource from that.

It’s kind of difficult to say much more without seeing all of your code.


#8

Thanks for your help !