Skip to content

Instantly share code, notes, and snippets.

@kakauandme
Created January 11, 2016 23:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kakauandme/bc29732c7c54dc272b4d to your computer and use it in GitHub Desktop.
Save kakauandme/bc29732c7c54dc272b4d to your computer and use it in GitHub Desktop.
Loop videos gaplessly on Pi
# https://github.com/willprice/python-omxplayer-wrapper
from omxplayer import OMXPlayer
from time import sleep
args=['--no-osd' ]
files = ['videos/green.m4v', 'videos/red.m4v', 'videos/orange.m4v', 'videos/blue.m4v']
durations = []
players = []
print('Initialising')
for f in files:
#OMXPlayer per file
players.append(OMXPlayer(f, args=args))
#get duration of each file
durations.append(players[len(players)-1].duration())
#just in case
sleep(2)
print('Playing')
#loop 5 times
for cnt in range(0,5):
#play each file
for i in range(0,len(players)):
players[i].set_position(0.0)
players[i].play()
# raspberry pi 2
#sleep(durations[i] - 0.5)
# raspberry pi 1
sleep(durations[i] - 1.5)
players[i].pause()
print('Quiting')
for p in players:
p.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment