VLC python模块在Ubuntu中不工作
我有这样的代码VLC python模块在Ubuntu中不工作,python,vlc,python-2.6,Python,Vlc,Python 2.6,我有这样的代码 import vlc # no error Instance = vlc.Instance() # no error MediaPlayer = Instance.media_player_new() # error triggered here 错误消息是 Instance.media_player_new() Traceback (most recent call last): File "<stdin&g
import vlc # no error
Instance = vlc.Instance() # no error
MediaPlayer = Instance.media_player_new() # error triggered here
错误消息是
Instance.media_player_new()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "vlc.py", line 895, in media_player_new
p._instance = self
AttributeError: 'NoneType' object has no attribute '_instance'
Instance.media\u player\u new()
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“vlc.py”,第895行,在media_player_new中
p、 _实例=self
AttributeError:“非类型”对象没有属性“\u实例”
我正在使用python 2.6
我的代码有什么问题?看起来像个bug。我在上浏览了一下代码(参见下面的代码片段) 看起来media_player_new调用libvlc_media_player_new(self),libvlc_media_player_new调用本机libvlc_media_player_new(…)函数。此函数返回NULL,结果为无,后续代码失败 根据文档字符串,如果发生错误,将返回NULL。也许您可以通过libvlc_log函数启用日志记录,看看出了什么问题。指 编辑:看起来您也可以通过vlc.py设置日志记录。(那么您不需要本机呼叫) 及
打印目录(实例)
?@ZagorulkinDmitry显示vlc.py中的所有函数
def media_player_new(self, uri=None):
"""Create a new MediaPlayer instance.
@param uri: an optional URI to play in the player.
"""
p = libvlc_media_player_new(self)
if uri:
p.set_media(self.media_new(uri))
p._instance = self
return p
def libvlc_media_player_new(p_libvlc_instance):
'''Create an empty Media Player object.
@param p_libvlc_instance: the libvlc instance in which the Media Player should be created.
@return: a new media player object, or NULL on error.
'''
f = _Cfunctions.get('libvlc_media_player_new', None) or \
_Cfunction('libvlc_media_player_new', ((1,),), class_result(MediaPlayer),
ctypes.c_void_p, Instance)
return f(p_libvlc_instance)