0

First sorry for my English, I'm French.

I'm currently working on this project : I have a training bike and I'd like to be able to play videos depending on my pedaling speed.

Here is the hardware I have so far :

  • A training bike
  • A HDTV screen
  • A Raspberry Pi 3 connected to the screen via HDMI
  • A Hall effect sensor connected to the RPI 3 via GPIO
  • A magnet mounted on the pedal.

In details, this is the plan :

  • When the RPI boots, a welcome video (always the same) should play
  • When I start pedaling (after 3-5 turns), an intro video should play
  • Then, while this first video is playing, I'd like to measure the average speed and, depending on this speed, I'd like to play automatically a video from the folder "High Speed", "Medium Speed" or "Low Speed"
  • I repeat this video during each video played
  • If I don't pedal during a video or if I finish a folder, I'd like to play an outro video and then go back to the welcome video

All of the code should be contained into a Python script automatically lauched when the RPI boots. I've installed Raspberry PI OS and use it from CLI since the desktop environement can't play 1080p videos smoothly.

So far, I managed to get a bit of my code working. For example, I have an eventListenner that watches my Hall Effect sensor so I can't count the turns.

I can launch a video with VLC but I can't find a way to run code to measure my speed and then use that speed at the end of the video to lauch the next one.

I'd like to get the media length while it's playing, do some math at the end of the video to calculate an estimated speed but it seems that I'm doing it really wrong... Defintly not in a Pythonic way.

I've read a lot about it here, tried to use different libraries like "python-vlc", "vlc-ctrl", I also tried to run it as a subprocess because I thought I needed it to control my player but I've spent days trying to solve this problem that I thought would be really easy to solve !

I think I don't really understand how the process system works.

If anyone has some advice I'd be more than happy.

Thanks.

  • 1
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community May 07 '23 at 18:11

1 Answers1

0

I have a similar situation in which VLC is started to play a movie and I needed python code to run as well during the movie. My solution was to use a timer that periodically calls a so called Callback function. Have a look at https://pypi.org/project/timesched/

  • Thanks Aad, I didn't really solve my problem with this since I can't interact with my VLC instance but it actually solves another problem that I had. I'll keep trying, thanks. – Dimitri Simonin May 08 '23 at 07:30
  • You could have a look at this: https://stackoverflow.com/questions/71660553/python-vlc-instance-fullscreen-not-working?rq=1 – Aad Slingerland May 08 '23 at 08:35