-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththeEnd.py
61 lines (45 loc) · 1.73 KB
/
theEnd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import tkinter as tk
from tkvideo import tkvideo
import pygame
class TheEnd:
def __init__(self):
# Initialize Pygame for audio playback
pygame.init()
pygame.mixer.init()
# Load the separated audio file as a Sound object
audio_path = "club.mp3" # Replace with the actual path or name of your audio file
self.sound = pygame.mixer.Sound(audio_path)
# Set up the Tkinter window for video playback
self.root = tk.Tk()
self.root.title("Video Player")
self.lbl_video = tk.Label(self.root)
self.lbl_video.pack()
self.player = tkvideo("goodbye.mp4",
self.lbl_video,
loop=1,
size=(1400, 788))
self.playing = True # Flag to track playing state
def play_video(self):
# Play the video
self.player.play()
# Play the associated audio
self.sound.play()
# Schedule the exit after 27 seconds
self.root.after(52000, self.exit_after_34_seconds)
# Check for events to handle window closing
self.root.protocol("WM_DELETE_WINDOW", self.on_close)
self.root.mainloop()
def exit_after_34_seconds(self):
# Stop playing the video and sound
self.player.stop()
pygame.mixer.stop()
# Set the playing flag to False
self.playing = False
# Destroy the Tkinter window
self.root.destroy()
def on_close(self):
# Handle window closing event
self.exit_after_34_seconds()
def is_playing(self):
# Check whether the video is still playing
return self.playing