problem with vlc python api with vlc 3.0
Posted: 25 Feb 2018 16:24
I use vlc api for python.
i used a function for loading a movie file after i wait 1 second and after i read object python to know the duration of file (method GetDurationVideo).
I add that there is no widget to see the movie because i just want to know the duration of file.
My code looks like this:
import vlc
# import standard libraries
class Player():
"""The main window has to deal with events.
"""
def __init__(self):
# VLC player controls
self.Instance = vlc.Instance("--vout", "dummy", "--no-audio" )
self.player = self.Instance.media_player_new()
def _OnOpen(self, mrl):
"""Pop up a new dialow window to choose a file, then play the selected file.
"""
if os.path.isfile(mrl):
#print (mrl)
# Creation
self.Media = self.Instance.media_new(mrl)
# self.Media = self.Instance.media_new(str(os.path.join(dirname, filename)))
self.player.set_media(self.Media)
""" retourne la duree en seconde de la video """
def _GetDurationCurrentPlaying(self):
return self.player.get_length() / 1000
'''method i used in my application'''
def GetDurationVideo(self, nomVideo, repertoire):
self._OnOpen(str(os.path.join(repertoire, nomVideo)))
self._OnPlay()
time.sleep(1) #on attend une seconde pour que vlc charge entete
duration = self._GetDurationCurrentPlaying()
self._OnStop() #instruction qui plante depuis 20/02/2018
return duration
def _OnStop(self):
"""Stop the player.
"""
self.player.stop()
the code crash when python execute :
self.player.stop()
when pyhon execte self.player.stop(), it call this method above.
here is api function which always crash in python 3.0.
def libvlc_media_player_stop(p_mi):
'''Stop (no effect if there is no media).
@param p_mi: the Media Player.
'''
f = _Cfunctions.get('libvlc_media_player_stop', None) or \
_Cfunction('libvlc_media_player_stop', ((1,),), None,
None, MediaPlayer)
return f(p_mi) --> CRASH
i have no problem with vlc 2.2.6
Do you have an idea ?
it is windows 10 update that have installed vlc 3.0 in my computer so one solution is to reinstall vlc 2.2.6 instead of vlc 3.0.0.
But i would like to use vlc 3.0.
i used a function for loading a movie file after i wait 1 second and after i read object python to know the duration of file (method GetDurationVideo).
I add that there is no widget to see the movie because i just want to know the duration of file.
My code looks like this:
import vlc
# import standard libraries
class Player():
"""The main window has to deal with events.
"""
def __init__(self):
# VLC player controls
self.Instance = vlc.Instance("--vout", "dummy", "--no-audio" )
self.player = self.Instance.media_player_new()
def _OnOpen(self, mrl):
"""Pop up a new dialow window to choose a file, then play the selected file.
"""
if os.path.isfile(mrl):
#print (mrl)
# Creation
self.Media = self.Instance.media_new(mrl)
# self.Media = self.Instance.media_new(str(os.path.join(dirname, filename)))
self.player.set_media(self.Media)
""" retourne la duree en seconde de la video """
def _GetDurationCurrentPlaying(self):
return self.player.get_length() / 1000
'''method i used in my application'''
def GetDurationVideo(self, nomVideo, repertoire):
self._OnOpen(str(os.path.join(repertoire, nomVideo)))
self._OnPlay()
time.sleep(1) #on attend une seconde pour que vlc charge entete
duration = self._GetDurationCurrentPlaying()
self._OnStop() #instruction qui plante depuis 20/02/2018
return duration
def _OnStop(self):
"""Stop the player.
"""
self.player.stop()
the code crash when python execute :
self.player.stop()
when pyhon execte self.player.stop(), it call this method above.
here is api function which always crash in python 3.0.
def libvlc_media_player_stop(p_mi):
'''Stop (no effect if there is no media).
@param p_mi: the Media Player.
'''
f = _Cfunctions.get('libvlc_media_player_stop', None) or \
_Cfunction('libvlc_media_player_stop', ((1,),), None,
None, MediaPlayer)
return f(p_mi) --> CRASH
i have no problem with vlc 2.2.6
Do you have an idea ?
it is windows 10 update that have installed vlc 3.0 in my computer so one solution is to reinstall vlc 2.2.6 instead of vlc 3.0.0.
But i would like to use vlc 3.0.