Python VLC MediaList – Removing Media from specific index
Last Updated :
29 Aug, 2020
In this article we will see how we can remove the specific media through index in the MediaList 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. 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. Inserting means we can add media at given index, it can be inserted with the help of insert_media
method and we can add media to media list with the help of add_media
method.
In order to do this we will use remove_media
method with the MediaList object
Syntax : media_list.remove_media(index)
Argument : It takes index as argument
Return : It returns 0 on success, -1 if the media list is read-only
Below is the implementation
import vlc
import time
media_player = vlc.MediaListPlayer()
player = vlc.Instance()
media_list = vlc.MediaList()
media = player.media_new( "death_note.mkv" )
media_list.add_media(media)
media = player.media_new( "1.mp4" )
media_list.insert_media(media, 0 )
media_list.remove_index( 0 )
media_player.set_media_list(media_list)
media_player.play()
time.sleep( 5 )
|
Output :
Another example
import vlc
import time
media_player = vlc.MediaListPlayer()
player = vlc.Instance()
media_list = vlc.MediaList()
media = player.media_new( "1.mp4" )
media_list.add_media(media)
media = player.media_new( "death_note.mkv" )
media_list.insert_media(media, 0 )
media_list.remove_index( 0 )
media_player.set_media_list(media_list)
media_player.play()
time.sleep( 5 )
|
Output :
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...