Skip to content
Related Articles

Related Articles

Python VLC MediaList – Checking if it is read only
  • Last Updated : 29 Aug, 2020

In this article we will see how we can check if the MediaList object is read only 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. MediaList object contains the multiple media, in other words it has list of media which can be used with MediaListPlayer object to play these multiple media object. Multiple media can be added to the media list object with the help of add_media method. Read only indicates if this media list is read-only from a user point of view.

In order to do this we will use is_readonly method with the MediaList object

Syntax : media_list.is_readonly()

Argument : It takes no argument

Return : It returns 1 on readonly, 0 on readwrite.



Below is the implementation




# importing vlc module
import vlc
  
# importing time module
import time
  
# creating a media player object
media_player = vlc.MediaListPlayer()
  
# creating Instance class object
player = vlc.Instance()
  
# creating a media list object
media_list = vlc.MediaList()
  
# creating a new media
media1 = player.media_new("death_note.mkv")
  
# adding media to media list
media_list.add_media(media1)
  
# creating a new media
media2 = player.media_new("1.mp4")
  
# adding another media
media_list.add_media(media2)
  
  
# setting media list to the media player
media_player.set_media_list(media_list)
  
  
# start playing video
media_player.play()
  
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)
  
# checking if the media list is read only
value = media_list.is_readonly()
  
# printing value
print(value)

Output :

0

Another example




# importing vlc module
import vlc
  
# importing time module
import time
  
# creating a media player object
media_player = vlc.MediaListPlayer()
  
# creating Instance class object
player = vlc.Instance()
  
# creating a media list object
media_list = vlc.MediaList()
  
# creating a new media
media1 = player.media_new("1.mp4")
  
# adding media to media list
media_list.add_media(media1)
  
# creating a new media
media2 = player.media_new("death_note.mkv")
  
# adding media to media list
media_list.add_media(media2)
  
  
  
# setting media list to the media player
media_player.set_media_list(media_list)
  
  
# start playing video
media_player.play()
  
# wait so the video can be played for 5 seconds
# irrespective for length of video
time.sleep(5)
  
# checking if the media list is read only
value = media_list.is_readonly()
  
# printing value
print(value)

Output :

0

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 :