Reputation: 122
I am working on a python project which allows users to stream and download high quality music from the internet and I am using python vlc for that.
As I have a progress bar in my application I want to add a function which will seek the music to the point where the user wants so for that I tried using the
.set_position()
argument of VLC but for some reason it doesn't work.
So is there a way to achieve what I want to.
Upvotes: 0
Views: 606
Reputation: 22443
Using .set_time()
presupposes that you know the running time of the media (which you won't know until the media has started).
Get the position on the progress bar of the click.
Calculate it as a percentage of the bar's length.
Convert that percentage to a seek_perc value between 0.0 and 1.0
Use the vlc player function .set_position(seek_perc)
or
Convert that percentage to a seek_time value of the running time in thousandths of a second.
Use the vlc player function .set_time(seek_time)
Notes/Caveats:
def set_position(self, f_pos):
'''Set movie position as percentage between 0.0 and 1.0.
This has no effect if playback is not enabled.
This might not work depending on the underlying input format and protocol.
@param f_pos: the position.
'''
return libvlc_media_player_set_position(self, f_pos)
def set_time(self, i_time):
'''Set the movie time (in ms). This has no effect if no media is being played.
Not all formats and protocols support this.
@param i_time: the movie time (in ms).
'''
return libvlc_media_player_set_time(self, i_time)
Upvotes: 1