mirror of
https://github.com/pkali/piradio-mini.git
synced 2026-05-20 22:34:22 +02:00
Streaming off in sleep mode.
This commit is contained in:
@@ -266,7 +266,7 @@ class MyDaemon(Daemon):
|
|||||||
radio.unmute()
|
radio.unmute()
|
||||||
displayWakeUpMessage(lcd)
|
displayWakeUpMessage(lcd)
|
||||||
radio.setDisplayMode(radio.MODE_TIME)
|
radio.setDisplayMode(radio.MODE_TIME)
|
||||||
|
radio.streamingWakeup()
|
||||||
|
|
||||||
# Toggle line 2 & 3 scrolling
|
# Toggle line 2 & 3 scrolling
|
||||||
if toggleScrolling:
|
if toggleScrolling:
|
||||||
@@ -845,6 +845,7 @@ def checkTimer(radio):
|
|||||||
if radio.getSource() == radio.PANDORA: # Jesli gra pandora to nie pauzujemy (mutujemy) tylko stopujemy
|
if radio.getSource() == radio.PANDORA: # Jesli gra pandora to nie pauzujemy (mutujemy) tylko stopujemy
|
||||||
radio.pandora_stop()
|
radio.pandora_stop()
|
||||||
radio.setDisplayMode(radio.MODE_SLEEP)
|
radio.setDisplayMode(radio.MODE_SLEEP)
|
||||||
|
radio.streamingSleep()
|
||||||
interrupt = True
|
interrupt = True
|
||||||
return interrupt
|
return interrupt
|
||||||
|
|
||||||
|
|||||||
+38
-3
@@ -328,14 +328,17 @@ class Radio:
|
|||||||
self.setInterrupt()
|
self.setInterrupt()
|
||||||
|
|
||||||
elif key == 'STREAMING_TOGGLE':
|
elif key == 'STREAMING_TOGGLE':
|
||||||
|
if self.display_mode != self.MODE_SLEEP: # no in sleep mode! (Pecus)
|
||||||
self.toggleStreaming()
|
self.toggleStreaming()
|
||||||
self.setInterrupt()
|
self.setInterrupt()
|
||||||
|
|
||||||
elif key == 'STREAMING_ON':
|
elif key == 'STREAMING_ON':
|
||||||
|
if self.display_mode != self.MODE_SLEEP: # no in sleep mode! (Pecus)
|
||||||
self.streamingOn()
|
self.streamingOn()
|
||||||
self.setInterrupt()
|
self.setInterrupt()
|
||||||
|
|
||||||
elif key == 'STREAMING_OFF':
|
elif key == 'STREAMING_OFF':
|
||||||
|
if self.display_mode != self.MODE_SLEEP: # no in sleep mode! (Pecus)
|
||||||
self.streamingOff()
|
self.streamingOff()
|
||||||
self.setInterrupt()
|
self.setInterrupt()
|
||||||
|
|
||||||
@@ -382,6 +385,7 @@ class Radio:
|
|||||||
display_mode = self.MODE_TIME # (Pecus)
|
display_mode = self.MODE_TIME # (Pecus)
|
||||||
self.setDisplayMode(display_mode) # (Pecus)
|
self.setDisplayMode(display_mode) # (Pecus)
|
||||||
self.setInterrupt() # (Pecus)
|
self.setInterrupt() # (Pecus)
|
||||||
|
self.streamingWakeup()
|
||||||
|
|
||||||
elif key == 'KEY_TIME': # timer on/off (Pecus)
|
elif key == 'KEY_TIME': # timer on/off (Pecus)
|
||||||
if self.display_mode != self.MODE_SLEEP: # no in sleep mode! (Pecus)
|
if self.display_mode != self.MODE_SLEEP: # no in sleep mode! (Pecus)
|
||||||
@@ -1423,6 +1427,29 @@ class Radio:
|
|||||||
self.streammetadata = ''
|
self.streammetadata = ''
|
||||||
return self.streaming
|
return self.streaming
|
||||||
|
|
||||||
|
# Sleep Icecast2 streaming
|
||||||
|
def streamingSleep(self):
|
||||||
|
if self.streamingStat():
|
||||||
|
output_id = 2
|
||||||
|
self.execMpcCommand("disable " + str(output_id))
|
||||||
|
self.execCommand("service darkice stop")
|
||||||
|
self.execCommand("service icecast2 stop")
|
||||||
|
self.streamingStatus()
|
||||||
|
self.streammetadata = ''
|
||||||
|
return self.streaming
|
||||||
|
|
||||||
|
# Wakeup Icecast2 streaming
|
||||||
|
def streamingWakeup(self):
|
||||||
|
if self.streaming and not self.streamingStat():
|
||||||
|
if self.streamingAvailable():
|
||||||
|
output_id = 2
|
||||||
|
self.execCommand("service icecast2 start")
|
||||||
|
self.execCommand("service darkice start")
|
||||||
|
self.execMpcCommand("enable " + str(output_id))
|
||||||
|
self.streamingStatus()
|
||||||
|
self.streammetadata = ''
|
||||||
|
return self.streaming
|
||||||
|
|
||||||
# Switch off Icecast2 streaming
|
# Switch off Icecast2 streaming
|
||||||
def streamingOff(self):
|
def streamingOff(self):
|
||||||
output_id = 2
|
output_id = 2
|
||||||
@@ -1435,11 +1462,19 @@ class Radio:
|
|||||||
self.streammetadata = ''
|
self.streammetadata = ''
|
||||||
return self.streaming
|
return self.streaming
|
||||||
|
|
||||||
# Display streaming status
|
# Check streaming status
|
||||||
def streamingStatus(self):
|
def streamingStat(self):
|
||||||
status = self.execCommand("mpc outputs | grep -i stream")
|
status = self.execCommand("mpc outputs | grep -i 2\.*\enabled")
|
||||||
|
stat = True
|
||||||
if len(status)<1:
|
if len(status)<1:
|
||||||
|
stat = False
|
||||||
|
return stat
|
||||||
|
|
||||||
|
# Log streaming status
|
||||||
|
def streamingStatus(self):
|
||||||
status = "No Icecast streaming"
|
status = "No Icecast streaming"
|
||||||
|
if self.streamingStat():
|
||||||
|
status = "Icecast streaming enabled"
|
||||||
log.message(status, log.INFO)
|
log.message(status, log.INFO)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user