Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Autostart videoplay from usb

Sat Jan 19, 2019 6:15 am

Hello guys.
I want do automatic videoplay from usb flash. For example, I will create "playlist" file on usb flash and I will attach my flash to rpi. My python script will automatic read "playlist" file and if usb has "playlist" file, Rpi will make list this video and show to me. You can think like slideshow. Just should there is video show instead of image. I research python script for this but I could not find yet. How can i write this script ?
Thanks

tempest766
Posts: 105
Joined: Sun Jan 07, 2018 3:44 pm

Re: Autostart videoplay from usb

Sat Jan 19, 2019 8:06 am

I think dbus is used a lot in determining hardware changes these days but the quick-n-dirty way would be to periodically check /dev/disk/* to see if a new disk device has been inserted. If so, then mount it and handle it.

the python code to do this is left as an exercise for you.

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: Autostart videoplay from usb

Sat Jan 19, 2019 9:13 am

I tried this code but does not work.

Code: Select all

#!/usr/bin/env python
#-*- coding: utf-8 -*-

import glob 
import os
import subprocess

videolist=[]
uzunluk=0
list_lenght=0

videolist=glob.glob('/media/pi/FLASH/playlist/*.mp4')
videolist=videolist+glob.glob('/media/pi/FLASH/playlist/*.mp4')

list_lenght=len(videolist)

for i in xrange(0,list_lenght,1):
	videoproc=subprocess.Popen(['omxplayer', videolist[i]], stdin=subprocess.PIPE, shell=False)
I can read file in usb flash and make queue. But just one video played, the other does not working.

Faruk
Posts: 54
Joined: Sat Sep 08, 2018 7:34 am

Re: Autostart videoplay from usb

Sat Jan 19, 2019 1:15 pm

Just wait subprocess until finish. Script is work this way

Return to “Python”