When using the VLC executable that comes with the package, after hitting button to set 'B' and initiate loop playback the player immediately goes to the 'A' point and begins playback as expected.
However when doing the same in my python program using the vlc python api (vlc.py), the video immediately goes to the first frame of the video, then a split-second later goes to 'A' point and begins playback as expected.
I'd like to eliminate the jump to the first frame of the video as it's visually jarring.
I'm using PyQt4 and have borrowed from the 'qtlvc.py' example from [url]https://wiki.videolan.org/Python_bindings[/url]
In my modified OpenFile() function, I'm calling
Code: Select all
self.instance.media_new(*args)
I suspect my issue is I'm recreating the mediaplayer (media_new) but I can't find any other way in the API to set the A/B points..
I know there's 'set_position()' etc,...but that doesn't seem to pertain to A/B looping,etc...(my OpenFile() function is listed below)
Is there another methodology or set of functions that I should be using to achieve this?
Thank you very much,
Cheers,
Code: Select all
def OpenFile(self, filename=None, startTime=None, stopTime=None, numRepeat=None):
"""Open a media file in a MediaPlayer"""
if not filename:
return
# create the media
if sys.version < '3':
filename = unicode(filename)
args = []
if filename:
args.append(filename)
if startTime:
cmd = 'start-time=%s' % startTime
args.append(cmd)
if stopTime:
cmd = 'stop-time=%s' % stopTime
args.append(cmd)
if numRepeat:
cmd = 'input-repeat=%s' % numRepeat
args.append(cmd)
self.media = self.instance.media_new(*args)
# put the media in the media player
self.mediaplayer.set_media(self.media)
# parse the metadata of the file
self.media.parse()
# set the title of the track as window title
self.setWindowTitle(self.media.get_meta(0))
# set Audio to Mute
#self.mediaplayer.audio_set_mute(True)
# the media player has to be 'connected' to the QFrame
# (otherwise a video would be displayed in it's own window)
# this is platform specific!
# you have to give the id of the QFrame (or similar object) to
# vlc, different platforms have different functions for this
if sys.platform.startswith('linux'): # for Linux using the X Server
self.mediaplayer.set_xwindow(self.videoframe.winId())
elif sys.platform == "win32": # for Windows
self.mediaplayer.set_hwnd(self.videoframe.winId())
elif sys.platform == "darwin": # for MacOS
self.mediaplayer.set_nsobject(self.videoframe.winId())
self.PlayPause()