Python Forum
Making a video interruptible
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making a video interruptible
#1
Hello!

I'm wanting to run a video with python but have it close if the program detects user input (of any kind).  The issues that I have so far is that whenever I initiate the video the window that the video is running in is in focus.  I use vlc player to run the video, so there is no way that my script can sense a key press (as the vlc window is in focus) and will only apply hotkey actions if one of those hotkeys are pressed while the video is playing.

I want to play a video, and upon user input it kills the video and stops the script.  Does anyone have any ideas?

I'm not stuck on the idea of using vlc player.  I just want to get this to work.

This is the code that I'm using so far.  Everything works as intended except I have to click in the open terminal and press a key for the video to terminate.

import os
import tty
import sys
import pygame


tty.setraw(sys.stdin.fileno())
key = 'n'

if key == 'n':
   os.system("vlc /home/user/Intro.mpg &")
   os.system("")
   key = sys.stdin.read(1)
   if(key != 'n'):
       os.system("killall vlc")    
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020