feat: add start script
This commit is contained in:
36
main.py
36
main.py
@@ -1,17 +1,37 @@
|
||||
import time
|
||||
from player import Player
|
||||
from relay import Relay
|
||||
|
||||
video_path = "/home/wancat/mind-blowing.mp4"
|
||||
PIN = 12
|
||||
|
||||
def main():
|
||||
ON = 17
|
||||
OFF = 6 * 60 + 5
|
||||
|
||||
def wait(player, sec):
|
||||
while player.get_time() < sec * 1000:
|
||||
time.sleep(0.1)
|
||||
|
||||
|
||||
def main(on, off):
|
||||
player = Player(video_path)
|
||||
while True:
|
||||
player.play()
|
||||
while player.get_time() < 10000:
|
||||
time.sleep(0.1)
|
||||
player.reset()
|
||||
|
||||
relay = Relay(PIN)
|
||||
try:
|
||||
while True:
|
||||
player.play()
|
||||
wait(player, on)
|
||||
relay.turn_on()
|
||||
wait(player, off)
|
||||
relay.turn_off()
|
||||
wait(player, player.get_length() / 1000 - 1)
|
||||
player.reset()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
finally:
|
||||
print("exiting..")
|
||||
player.stop()
|
||||
relay.tear_down()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main(ON, OFF)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user