Python VLC 脚本错误:AttributeError: 'NoneType' 对象没有属性 'media_player_new' [英] Python VLC Script error: AttributeError: 'NoneType' object has no attribute 'media_player_new'

查看:70
本文介绍了Python VLC 脚本错误:AttributeError: 'NoneType' 对象没有属性 'media_player_new'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个简单的脚本,可以在 python 中播放视频 (.mp4).我不想在网上播放 YouTube 视频或任何内容,只想在我的电脑上播放视频.

I'm trying to make a simple script that will play a video (.mp4) in python. I don't want to play a you tube video or anything online, just a video on my computer.

这是我的代码:

import vlc
Instance = vlc.Instance()
player = Instance.media_player_new()
Media = Instance.media_new('test.mp4')
Media.get_mrl()
player.set_media(Media)
player.play()

我在运行它时不断收到此错误(谈论第 3 行):

I keep getting this error when I run it (talking about line 3):

AttributeError: 'NoneType' 对象没有属性 'media_player_new'

AttributeError: 'NoneType' object has no attribute 'media_player_new'

我在 macOS Sierra 的 IDLE 中使用 python 3.5.4.

I'm using python 3.5.4 in the IDLE on macOS Sierra.

推荐答案

我通过注释掉 vlc.py 中的 find_lib() 解决了这个问题.

I solved the problem by comment out find_lib() in vlc.py.

p = os.getcwd()
os.chdir(os.path.join(p, 'sdk'))
dll = ctypes.CDLL("libvlc.dll")
plugin_path = os.path.join(os.getcwd(), r'sdk\plugins')

这篇关于Python VLC 脚本错误:AttributeError: 'NoneType' 对象没有属性 'media_player_new'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆