Jul-18-2023, 02:22 PM
(This post was last modified: Jul-18-2023, 03:01 PM by deanhystad.)
First post; not sure if this is the proper forum?
I'm working on a Python Windows VLC media player script, and ran into a problem I can't figure out.
I've done a lot of reading and testing, but am getting nowhere.
After I start playing my video I need a popup window to select the proper subtitle.
As soon as I select the popup, I lose control of VLC.
I can close the popup and the video keeps playing but I have no control over it.
I have included the 2 functions that are relevant. They have been stripped to the minimum required to produce the problem.
I would truly appreciate any help.
Thanx!
I'm working on a Python Windows VLC media player script, and ran into a problem I can't figure out.
I've done a lot of reading and testing, but am getting nowhere.
After I start playing my video I need a popup window to select the proper subtitle.
As soon as I select the popup, I lose control of VLC.
I can close the popup and the video keeps playing but I have no control over it.
I have included the 2 functions that are relevant. They have been stripped to the minimum required to produce the problem.
I would truly appreciate any help.
Thanx!
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 |
from pynput import keyboard from pynput.keyboard import Key import time import keyboard global media_player def vlc_player(filename): # creating vlc media player object media_player = vlc.MediaPlayer() # making keyboard input enable media_player.video_set_key_input( True ) # media object media = vlc.Media(filename) media_player.set_media(media) # toggling full screen media_player.toggle_fullscreen() # set volumes media_player.audio_set_volume( 100 ) #time=media_player.get_time() media_player.play() # STOP playing when end-of-file reached Ended = 6 #set arbitrary value current_state = media_player.get_state() while current_state ! = Ended: # define keys pressed during playback if keyboard.is_pressed( "s" ): media_player.stop() if keyboard.is_pressed( "ctrl+x" ): sub_popup() current_state = media_player.get_state() media_player.stop() def sub_popup(): top = Toplevel(my_canvas, width = 250 , height = 400 ) top.geometry( '%dx%d+%d+%d' % ( 300 , 350 , 800 , 200 )) top.configure(bg = "black" ,highlightthickness = 7 ) top.wm_overrideredirect( True ) top.attributes( "-topmost" , True ) play = Button(top, text = "Okay" , command = top.destroy) play.pack() top.mainloop() |
deanhystad write Jul-18-2023, 03:01 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.