簡體   English   中英

VLC Python模塊在Ubuntu中不起作用

[英]VLC python module not working in Ubuntu

我有這樣的代碼

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'

我正在使用python 2.6我的代碼有什么問題?

看起來像個錯誤。 我在https://github.com/geoffsalmon/vlc-python/blob/master/generated/vlc.py中查看了代碼(請參見下面的代碼段)。

看起來media_player_new調用libvlc_media_player_new(self),而libvlc_media_player_new調用本地libvlc_media_player_new(...)函數。 該函數返回NULL,結果為None,並且其他代碼失敗。

根據文檔字符串,如果發生錯誤,將返回NULL。 也許您可以通過libvlc_log函數啟用日志記錄,然后看看出了什么問題。 請參閱http://www.videolan.org/developers/vlc/doc/doxygen/html/group_ libvlc _log.html

編輯:看起來您也可以通過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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM