How to insert a video player inside a tkinter window with Python 3? -
i want build video player python, application have more buttons play/pause, need insert video inside window.
i have code until now:
import tkinter import os import gi gi.require_version('gst', '1.0') gi.repository import gobject, gst def set_frame_handle(bus, message, frame_id): if not message.get_structure() none: if message.get_structure().get_name() == 'prepare-window-handle': display_frame = message.src display_frame.set_property('force-aspect-ratio', true) display_frame.set_window_handle(frame_id) root = tkinter.tk() w, h = root.winfo_screenwidth(), root.winfo_screenheight() root.geometry("%dx%d+0+0" % (w, h)) gst.init(none) gobject.threads_init() video = tkinter.frame(root, bg='#000000') video.grid(row=0, column=0, sticky="nsew") frame_id = video.winfo_id() player = gst.elementfactory.make('playbin', none) player.set_property('video-sink', none) player.set_property('uri', 'file://%s' % (os.path.abspath('out.mpeg'))) player.set_state(gst.state.playing) bus = player.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() bus.connect('sync-message::element', set_frame_handle, frame_id) root.mainloop()
but creates 2 windows, 1 of them opengl renderer... need video player inside same window...
i propose create frame instead of videoplayer. in frame pack videoplayer , nothing else. can create many windows around want , refer frame. make way easier arrange other buttons , stuff want add.
wiki
Comments
Post a Comment