Related Articles

Related Articles

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

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

class 'vlc.MediaPlayer'

Another example

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :