The solution is probably simple, but I'm stuck, as an amateur is

A simple script to play a movie:

import pygame

import moviepy.editor

pygame.init()

screen = pygame.display.set_mode(( 1000 , 500 ))

clock = pygame.time.Clock()

pygame.time.set_timer(pygame.USEREVENT, 5 )

running = True

while running:

for event in pygame.event.get():

if event. type = = pygame.QUIT:

running = False

if event. type = = pygame.MOUSEBUTTONDOWN:

if event.button = = 1 :

print ( 'You left clicked' )

# video

film = "Lacuna.avi"

video = moviepy.editor.VideoFileClip(film)

video.preview()

The problem is that no action is possible (e.g. a mouse click) until the video is over.
How to perform any action during the video playback.

Best regards.
Wookie

You can format your comment using triple backquotes to start and end the code section…

...like this.

Otherwise, it’s hard to know if the indentation on your code is correct. Right now, it looks like you are doing all the # video stuff inside the for loop for event handling, which would explain why it doesn’t seem to be handling events.

One solution is to run the video playing in a separate thread. Here’s some example code:

from moviepy.editor import VideoFileClip
import threading, time

# Function to play video in a separate thread
def play_video():
    clip = VideoFileClip("Lacuna.avi")
    clip.preview()  # Plays the video

# Create and start the thread
video_thread = threading.Thread(target=play_video)
video_thread.start()

# Main program can handle events here
while video_thread.is_alive():
    # Place your event handling code here
    # e.g., check for keypresses or mouse events
    print("Put your event handling loop here...")
    time.sleep(0.1)