Saturday, December 28, 2024
Google search engine
HomeLanguagesPython VLC – Creating MediaPlayer object

Python VLC – Creating MediaPlayer object

In this article we will see how we can create a MediaPlayer object in the python vlc module. VLC media player is a free and open-source portable cross-platform media player software and streaming media server developed by the VideoLAN project. MediaPlayer object is the basic object in vlc module for playing the video. MediaPlayer class is the basic class it is used to play single video at a time.

In order to do this we will use MediaPlayer method Syntax : MediaPlayer(video_uri) Argument : It takes video uri as optional argument Return : It returns MediaPlayer object

Below is the implementation 

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))


Output :

class 'vlc.MediaPlayer'

Another example 

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)


Output :

RELATED ARTICLES

Most Popular

Recent Comments