Open In App

Python VLC MediaPlayer – Getting Instance of it

Last Updated : 11 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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

Python3




# 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 

Python3




# 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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads