Open In App

Python VLC MediaListPlayer – Pause/Resume

Last Updated : 29 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

In this article we will see how we can pause/resume the MediaListPlayer 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. Media list player is used to play multiple media in a row for example playing a series, instead of taking single media it accepts media list. Its working is almost similar like the MediaPlayer object but it is capable of playing list of media. We can pause and resume the media list player any time, when it get paused the frame and the audio get stopped and when it get resumed it start from the paused point.

In order to do this we will use set_pause method with the MediaListPlayer object

Syntax : media_list_player.set_pause(1)

Argument : It takes 0 to play/resume and non-zero to pause

Return : It returns None

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 new media list object
media_list = player.media_list_new()
  
# creating a new media
media = player.media_new("death_note.mkv")
  
# adding media to media list
media_list.add_media(media)
  
# 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)
  
# pausing media
media_player.set_pause(1)
  
# wait for 4 second
# so that it remained paused for 4 seconds
time.sleep(4)


Output :

Another example
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 new media list
media_list = player.media_list_new()
  
# creating a new media
media = player.media_new("1.mp4")
  
# adding media to media list
media_list.add_media(media)
  
# 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)
  
# pausing media
media_player.set_pause(1)
  
# wait for 4 second
# so that it remained paused for 4 seconds
time.sleep(4)


Output :



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads