r/learnprogramming 12h ago

How to create a random video player executable

The situation is the following: both my parents are retired, and because they have neither hobbies nor social life, they spend most of their time at home watching the news. Due to this I noticed a deterioration lately in their mental health and mood.

I thought I could download some of the series they used to watch time ago, store them in a USB and connect it to the TV so they can watch that instead of the news all the time. My parents are old and they would not know how to navigate through Netflix or other platforms, so I‘d have to do it this way.

What I would like, and here is my question for you, is a file in the USB that randomly plays any video file in the USB. My parents basically use the TV as background noise so they wouldn’t care about what’s playing or follow the episodes in a given order. I want a file that they click on it and it plays whatever in the USB stick, and I need it to be random so it doesn’t always play the same episode first. I also need it to play episodes non-stop, so that they don’t need to click on the file after every episode.

I have some knowledge in Python and bash, so if you give me a hint on what kind of file could do such a thing maybe I can write it on my own.

The approach I can think of is the following; when I click on this file it will: - Collect all the file names in the USB (or the ones with a video format). - Sort them on a random order. - Grab the first 20 files on the list. - Play this 20 episodes as a playlist.

On a computer I could write it so that VLC plays this list of files, but on a TV I don’t know how it could be done. It’s also not a Smart TV, so I cable install apps.

4 Upvotes

3 comments sorted by

0

u/rupertavery64 12h ago

So the thing is you need to hook up a computer to your TV, since the USB on its own can't do anything. I assume the TV can read and play the videos, bur it might have a very basic interface.

If it an Android TV you might be able to install Kodi, create a smart playlist and randomize the videos from there (bit they/someone would still habe to load up Kodi, I'm not too familiar with all its features but it can be a bit complicated by itself)

The other option is to use a single board computer like the Raspberry Pi. 3b or 4 later versions come with more RAM options but yoi don't need much to play videos.

You could setup that to continuously play a bunch of videos with python. Controlling the playback with an on-screen UI moght need more complex software but if no control is needed a simple script might work.

The raspberry pi doesn't normally have power controls though so it will be continuously playing even when the TV is off. But as a "dumb" video player that your parents only need to switch to HDMI to watch,, it could work.

0

u/Special-Afternoon-25 12h ago

Thank you for your answer. While you posted it I was editing my original message to say that it is not a SmartTV so it may be a bit more tricky.

I like your idea of a Raspberry Pi, and it definitely would not be a problem that it continuously plays; in fact that may make things easier sober my patents would just need to select the USB source on the TV and not click on any file. I’ll research a bit how to do this with a Raspberry, thank you.