Skip to content
Related Articles

Related Articles

Python VLC MediaPlayer – Getting Instance of it
  • Last Updated : 18 Aug, 2020

In this article we will see how we can get the instance of the 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. We can create a MediaPlayer object with the help of MediaPlayer method.

In order to do this we will use get_instance method with the MediaPlayer object

Syntax : media_player.get_instance()

Argument : It takes no argument

Return : It returns the associated Instance with it



Below is the implementation




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

Output :

Media player Instance : <vlc.Instance object at 0x000001DE3184EE08

Another example




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

Output :

Media player Instance : <vlc.Instance object at 0x000001AD5452ED48

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 :