![]() Raspberry Pi has been a perfect choice for a home media centre ever since it was released in 2012, due to it being inexpensive and supported by an active community. Only Raspberry Pi 4 can output at 4K, so it’s important to remember this when deciding on which Raspberry Pi to choose. Grab a Raspberry Pi 4 and a micro-HDMI cable, and let’s get started. We asked Wes Archer to take us through setting one up. With the release of the super-powered Raspberry Pi 4, it’s time to fully upgrade our media centre to become a 4K-playing powerhouse. While we always have a few Raspberry Pi computers at hand for making robots and cooking gadgets, or just simply coding a Scratch game, there’s always at least one in the house powering a TV. You could define different methods depending on what commands omxplayer understands and what commands you need.We love Raspberry Pi for how it’s helping a new generation of children learn to code, how it’s resulted in an explosion of new makers of all ages, and how it’s really easy to turn any TV into a smart TV. Specify appropriate start_command, quit_command, toggle_command. Logger.warning("can't toggle %s: %s", self.movie, e) P.stdin.write(toggle_command) # pause/unpause Logger.error("can't stop %s: %s", self.movie, e) P.wait() # -> move into background thread if necessary P.stdin.write(quit_command) # send quit command Stdout=DEVNULL, close_fds=True, bufsize=0) Where Player is a simple wrapper around omxplayer subprocess: import loggingįrom subprocess import Popen, PIPE, DEVNULL Players = įor key in get_key_events(): # get GPIO input subprocess.Popen runs a separate process it doesn't block your main thread: names = 'sippycup', 'dodgeballs', 'shoppingcart' I would simplify your code by removing all globals and threads. NameError: global name 'playDodgeballs' is not defined means that you are trying to use playDodgeballs before it is defined playDodgeballs =. Thread.start_new_thread( welcome_loop, () )įile "./labmural2.py", line 28, in welcome_loop Shoppingcart_video=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True) ![]() Sippycup_video=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True)ĭodgeballs_video=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True) PlayProcess=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True) Thread.start_new_thread( shoppingcart, ("Playing Shoppingcart",) ) Thread.start_new_thread( dodgeballs, ("Playing Dodgeballs",) ) Thread.start_new_thread( sippycup, ("Playing Sippycup",) ) PlayShoppingcart=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True) PlayDodgeballs=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True) PlaySippycup=subprocess.Popen(,stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE, close_fds=True) Thanks so much for any help you guys can offer! #!/usr/bin/env python NameError: global name 'playShoppingcart' is not defined NameError: global name 'playDodgeballs' is not definedįile "./labmural2.py", line 71, in shoppingcart Unhandled exception in thread started by įile "./labmural2.py", line 53, in dodgeballs Here's are the errors I'm currently receiving: Unhandled exception in thread started by Playing Sippycup I am able to close the video after it plays for 10 seconds, but I can't move the quit command anywhere else to close other videos: ('q') I wasn't able to close the thread though when another thread starts. ![]() In the code below I'm trying to accomplish it using multithreading. I'm pretty new to Python so please keep it as simple as possible. When you press a button the video plays, but when you press a different button or the same button it opens the video without closing the video that was currently playing. When someone presses a button the corresponding video plays. ![]() Using a Raspberry Pi and some push buttons I want to control video playback. ![]()
0 Comments
Leave a Reply. |