-
Notifications
You must be signed in to change notification settings - Fork 0
/
player.py
executable file
·63 lines (57 loc) · 1.63 KB
/
player.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
from time import sleep
import os
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(10, GPIO.IN)
GPIO.setup(22, GPIO.IN)
GPIO.setup(23, GPIO.IN)
GPIO.setup(24, GPIO.IN)
GPIO.setup(25, GPIO.IN)
os.system('sudo rm /tmp/cmd')
os.system('mkfifo /tmp/cmd')
print 'Witam ;-)\n'
print 'Zapalam diode...\n'
os.system('/usr/local/bin/gpio mode 7 out')
os.system('/usr/local/bin/gpio write 7 1')
print 'Laduje pliki audio...\n'
os.system('/usr/bin/omxplayershuffle local /media/*/ < /tmp/cmd &')
#print 'Play >\n'
#os.system('echo -n p > /tmp/cmd &')
x=1
#y=0
while True:
# if (y==0):
# os.system('echo -n p > /tmp/cmd &')
# y=1
if ( GPIO.input(23) == False ):
if(x==1):
os.system('echo -n p > /tmp/cmd &')
print 'Play >\n'
sleep(0.5);
else:
os.system('omxplayershuffle local /media/*/ < /tmp/cmd &')
os.system('echo -n p > /tmp/cmd &')
print 'Pauza ||\n'
x=1
sleep(0.5);
if ( GPIO.input(24) == False ):
os.system('sudo pkill omxplayer')
os.system('omxplayershuffle local /media/*/ < /tmp/cmd &')
os.system('echo -n p > /tmp/cmd &')
print 'Shuffle\n'
x=1
sleep(0.5);
if ( GPIO.input(25)== False ):
os.system('sudo pkill omxplayer')
print 'Stop\n'
x=0
sleep(0.5);
if ( GPIO.input(22) == False ):
os.system('echo -n i > /tmp/cmd &')
print '<< Poprzednia\n'
sleep(0.5);
if ( GPIO.input(10) == False ):
os.system('echo -n o > /tmp/cmd &')
print 'Nastepna >>\n'
sleep(0.5);