[/quote]
Is this related to your other project?
viewtopic.php?p=2279543#p2279543
If yes, you should continue the discussion there. If no you should make it clear here that it is not related.
Either way, it is easy, but the devil is in the details. Most beginners get overwhelmed by the whole thing, whereas it's much easier to break it down and focus on small parts. Get them working then put everything together.
In this case you have several pieces:
Detect button press
Control an LED
Play a video
Show a still image
Start the program automatically
One caveat is that you are using a Pi 5. GPIO handling has changed for Pi 5, so old tutorials and examples won't work.
Probably "show a still image" and "play a video" can be achieved with the same media program. That's one step solved immediately!
Here's an up to date tutorial on buttons and LEDs:
https://www.tomshardware.com/how-to/con ... h-python-3
I suggest you try the tutorial and get it working, then you're almost done. If you can't get it working there's no point in worrying about the rest.
[/quote]
You are correct in that it was related to my other posts. I'm having issues going between the RPi4b and RPi5 and the differences, as you mentioned. Its hard because some of the code applies and some of it is now different. This thread was different because I cannot get the original solution working properly, so I pivoted to a new scope. I started this thread so the two scopes wouldnt be confusing.
Excitingly, I was able to get it working based on a few code examples. Shout out to https://magpi.raspberrypi.com/books/ess ... io-zero-v1
here is my code:
Is this related to your other project?
viewtopic.php?p=2279543#p2279543
If yes, you should continue the discussion there. If no you should make it clear here that it is not related.
Either way, it is easy, but the devil is in the details. Most beginners get overwhelmed by the whole thing, whereas it's much easier to break it down and focus on small parts. Get them working then put everything together.
In this case you have several pieces:
Detect button press
Control an LED
Play a video
Show a still image
Start the program automatically
One caveat is that you are using a Pi 5. GPIO handling has changed for Pi 5, so old tutorials and examples won't work.
Probably "show a still image" and "play a video" can be achieved with the same media program. That's one step solved immediately!
Here's an up to date tutorial on buttons and LEDs:
https://www.tomshardware.com/how-to/con ... h-python-3
I suggest you try the tutorial and get it working, then you're almost done. If you can't get it working there's no point in worrying about the rest.
[/quote]
You are correct in that it was related to my other posts. I'm having issues going between the RPi4b and RPi5 and the differences, as you mentioned. Its hard because some of the code applies and some of it is now different. This thread was different because I cannot get the original solution working properly, so I pivoted to a new scope. I started this thread so the two scopes wouldnt be confusing.
Excitingly, I was able to get it working based on a few code examples. Shout out to https://magpi.raspberrypi.com/books/ess ... io-zero-v1
here is my code:
Code:
from gpiozero import LED, Buttonfrom time import sleepfrom signal import pauseimport time, vlcled = LED(17)button = Button(2)def image(source): # creating a vlc instance vlc_instance = vlc.Instance() # creating a media player player = vlc_instance.media_player_new() #full screen player.toggle_fullscreen() #creating a media media = vlc_instance.media_new(source) # setting media to the player player.set_media(media) # play the video player.play() # wait time( until the button is pressed) def video(source): # creating a vlc instance vlc_instance = vlc.Instance() # creating a media player player = vlc_instance.media_player_new() #full screen player.toggle_fullscreen() #creating a media media = vlc_instance.media_new(source)# setting media to the player player.set_media(media) # play the video player.play() # wait time time.sleep(5) # getting the duration of the video duration = player.get_length() # printing the duration of the video print("Duration : " + str(duration))try: while True: led.off() # call the image method image("elevator.jpg") while(button.is_pressed == False): pass led.on() # call the video method video("handshake1080.mp4") led.off()except KeyboardInterrupt: exit()
Statistics: Posted by alfordtp — Fri Jan 17, 2025 4:15 am