You need to wait for the video to load or pre-roll before it will play.
It will not pause before it is playing.
The simple answer is to allow the video to get to a "playing" state and then pause it.
This can be done, simply by allowing it time to get to the playing state, by sleeping, for say 1 tenth of a second.
You don't indicate what the activation trigger
is, so in the following example, I've added a Linux friendly, keyboard trigger, that times-out after 10 seconds.
import time, vlc
import sys, select
# media object
media_player = vlc.MediaPlayer()
media = vlc.Media('V1.mp4')
vlc_playing = set([3, 4]) # 3 - Playing | 4 - Paused
media_state = None
# setting media to the media player
media_player.set_media(media)
# Play to open/load the video
media_player.play()
while media_state not in vlc_playing:
time.sleep(0.1)
media_state = media_player.get_state()
media_player.pause()
print("Paused - waiting for trigger")
print("Activate trigger with Enter or Ctrl+C to terminate")
# Here the activation trigger is provide by pressing the Enter key
# within 10 seconds
# I've no idea if this will work on a Non Linux box
#
try:
inp, out, err = select.select( [sys.stdin], [], [], 10 )
if inp:
media_player.play()
else:
media_state = None
except KeyboardInterrupt:
media_state = None
if media_state: # Play loop
while media_state in vlc_playing:
time.sleep(1)
try: # Cater for Ctrl+C during Play
media_state = media_player.get_state()
except Exception:
media_state = None
continue
else:
print("No Activation trigger - Terminated")