Jul-25-2024, 04:04 PM
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 |
import tkinter as tk from PIL import Image, ImageTk import imageio root = tk.Tk() class VideoPlayer: def __init__( self , root, video_path): self .root = root self .video_label = tk.Label(root) self .video_label.pack() self .video = imageio.get_reader(video_path) self .play_video = True self .frame_iter = self .video.iter_data() self .update() def update( self ): if self .play_video: self .root.after( 50 , self .update) # call update again after 1/20 of a second. try : frame = next ( self .frame_iter) image = Image.fromarray(frame).resize(( 1000 , 250 )) self .video_label.config(image = image) self .video_label.image = image self .root.update() except StopIteration: self .play_video = False else : self .video.close() root.destroy() def stop( self ): self .play_video = False if __name__ = = "__main__" : root.title( "Video Player" ) video_path = r "C:\Users\RPC-K\Videos\vlc-record-2024-07-24-18h10m00s-windows 95 maze screensaver 022 speedrun [WORLD RECORD].mp4-.mp4" player = VideoPlayer(root, video_path) root.protocol( "WM_DELETE_WINDOW" , player.stop) root.mainloop() [ |
NOTE: I had to get rid of the music because I was getting other issues.
JUST A FRIENDLY REMINDER, I AM INFACT A YOUNG CHILD SO PLEASE FORGIVE ME IF I LACK OF ANY KNOWLEDGE THAT MAY SEEM OBVIOUS...I AM STILL DEVELOPING MY SKILLS IN PYTHON - YOURS SINCERELY, Moon
😋
😋