Skip to content
Related Articles

Related Articles

Improve Article
Python VLC – Creating MediaPlayer object
  • Last Updated : 18 Aug, 2020

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. MediPlyer 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




# 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




# 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 :

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :