So I want it so when you click the x button on the top it stops the whole process but there is this "interrupt" error I keep getting and I tried multiple ways to stop the video, pygame or audio and none of them work. It just keeps printing in console interrupt.
import random
import psutil
import sys
from pygame.locals import *
from moviepy.editor import *
from pypresence import Presence
import time
pygame.init()
pygame.mixer.init()
pygame.display.set_caption('lofi hip hop radio - beats to relax/study to - v1.0')
def launch(movie):
clip = VideoFileClip(movie)
clip.preview()
def checkIfProcessRunning(processName):
'''
Check if there is any running process that contains the given name processName.
'''
#Iterate over the all the running process
for proc in psutil.process_iter():
try:
# Check if process name contains the given name string.
if processName.lower() in proc.name().lower():
return True
except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess):
pass
return False;
def repeat():
running = True
clip = VideoFileClip("lofivid1.mp4")
time.sleep(5)
randomNumber = random.randint(1, 2)
print(str(randomNumber))
pygame.mixer.music.load("song" + str(randomNumber) + ".wav")
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() and running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
if(running):
clip.preview()
else:
pygame.quit()
exit(0)
while 1:
if checkIfProcessRunning('discord'):
client_id = 'ID CLIENT' #Put your client ID here
RPC = Presence(client_id)
RPC.connect()
print(RPC.update(state="Listening", details="Doing homework", large_image="https://static.actu.fr/uploads/2020/04/maxresdefault-960x640.jpg", small_image="https://static.actu.fr/uploads/2020/04/maxresdefault-960x640.jpg", large_text="LofiCli", start=time.time()))
else:
pass
repeat()
Every-time you click the x button you get this printed in console
Interrupt
And it does not close or change anything