📜  Python VLC – 创建 MediaPlayer 对象

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

Python VLC – 创建 MediaPlayer 对象

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

下面是实现

Python3
# importing vlc module
import vlc
import time
import time
 
# creating vlc media player object
media_player = vlc.MediaPlayer()
 
# printing type of media player variable
print(type(media_player))


Python3
# importing vlc module
import vlc
import time
 
# creating vlc media player object
media_player = vlc.MediaPlayer("1.mp4")
 
# start playing video
media_player.play()
 
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)


输出 :

class 'vlc.MediaPlayer'

另一个例子

Python3

# importing vlc module
import vlc
import time
 
# creating vlc media player object
media_player = vlc.MediaPlayer("1.mp4")
 
# start playing video
media_player.play()
 
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)

输出 :