📜  Python VLC MediaPlayer – 获取它的实例

📅  最后修改于: 2022-05-13 01:55:27.042000             🧑  作者: Mango

Python VLC MediaPlayer – 获取它的实例

在本文中,我们将了解如何在Python vlc 模块中获取 MediaPlayer 对象的实例。 VLC媒体播放器是VideoLAN项目开发的一款免费开源的便携式跨平台媒体播放软件和流媒体服务器。 MediaPlayer 对象是 vlc 模块中用于播放视频的基本对象。 MediaPlayer 类是用于一次播放单个视频的基本类。我们可以借助 MediaPlayer 方法创建一个 MediaPlayer 对象。

下面是实现

Python3
# importing time module
import time
 
 
# creating vlc media player object
media_player = vlc.MediaPlayer("death_note.mkv")
 
# start playing video
media_player.play()
 
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)
 
# getting instance of the media player
inst = media_player.get_instance()
print("Media player Instance : " + str(inst))


Python3
# importing vlc module
import vlc
 
# importing time module
import time
 
# creating vlc media player object
media_player = vlc.MediaPlayer()
 
# getting instance of the media player
inst = media_player.get_instance()
print("Media player Instance : " + str(inst))


输出 :

Media player Instance : 

另一个例子

Python3

# importing vlc module
import vlc
 
# importing time module
import time
 
# creating vlc media player object
media_player = vlc.MediaPlayer()
 
# getting instance of the media player
inst = media_player.get_instance()
print("Media player Instance : " + str(inst))

输出 :

Media player Instance :