python-vlc 不会启动播放器 [英] python-vlc won't start the player

查看:63
本文介绍了python-vlc 不会启动播放器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,开始.我正在尝试播放位于在线的视频.我得到了网址,如下所示:http://fsi.stanford.edu/sites/default/files/video_4.mp4我不会在我的应用程序中使用它,它只是一个示例文件.阅读 python-vlc 模块的示例,我编写了以下代码:

Ok here go .Im trying to play a video located online.I got the url ,which is the following: http://fsi.stanford.edu/sites/default/files/video_4.mp4 Its not something i will use in my application but Its just a sample file . Reading the examples for the python-vlc module i wrote the following code:

import vlc

Instance = vlc.Instance('--fullscreen')
player = Instance.media_player_new()
Media = Instance.media_new('http://fsi.stanford.edu/sites/default/files/video_4.mp4')
Media.get_mrl()
player.set_media(Media)
player.play()

一般来说,我使用 anaconda 和 jupyter 来编写代码.在 jupyter 环境中,除了全屏参数(这仍然不是我需要的)之外,上面的代码正确执行.所以我尝试在命令窗口上运行我的代码,期待 vlc播放器开始进入全屏模式.相反,代码按预期返回 0,但播放器从未启动.我使用 Windows 10 和 vlc 2.2.4.你能解释一下或至少帮助我理解为什么会这样吗?

In general I use anaconda and jupyter to write code .In the jupyter enviroment the code above executes corectly except the fullscreen parameter(which is still not what i need).So i tried running my code on a command window expecting the vlc player to start to fullscreen mode.Instead the code returned 0 as expected but the player never started.Im using windows 10 and vlc 2.2.4 . Can you please explain or at least help me understand why is this happening ?

推荐答案

好吧我自己解决了,我只好最后放了一个无限循环,让玩家有足够的时间跑:

Ok I solved it on my own.I just had to put an infinite loop in the end,so the player has enough time to run:

while True:
     pass

这篇关于python-vlc 不会启动播放器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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