Python VLC MediaPlayer – Getting Cursor
In this article we will see how we can get the cursor position in 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. We can create a MediaPlayer object with the help of MediaPlayer
method. Mouse pointer coordinates over a video are expressed as 2-tuple (x, y). Coordinates are expressed in terms of the decoded video resolution, not in terms of pixels on the screen/viewport.
In order to do this we will use video_get_cursor
method with the MediaPlayer object
Syntax : media_player.video_get_cursor()
Argument : It takes no argument
Return : It returns tuple
Below is the implementation
import vlc
import time
media_player = vlc.MediaPlayer()
mrl = "death_note.mkv"
media_player.set_mrl(mrl)
media_player.play()
time.sleep( 5 )
value = media_player.video_get_cursor()
print ( "Cursor Co-ordinates : " )
print (value)
|
Output :
Cursor Co-ordinates :
(655, 436)
Another example
Below is the implementation
import vlc
import time
media_player = vlc.MediaPlayer()
mrl = "1.mp4"
media_player.set_mrl(mrl)
media_player.play()
time.sleep( 5 )
value = media_player.video_get_cursor()
print ( "Cursor Co-ordinates : " )
print (value)
|
Output :
Cursor Co-ordinates :
(607, 267)
Last Updated :
09 Feb, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...