Skip to content
This repository has been archived by the owner on Sep 21, 2023. It is now read-only.

Commit

Permalink
Merge parts of branch 'feature/resume_after_volume_change' into featu…
Browse files Browse the repository at this point in the history
…re/googlebutton
  • Loading branch information
xtools-at committed Jul 13, 2017
2 parents 86b1fcd + e8e2dd6 commit 06292e2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@ class Player(object):
playlist_last_item = None
progressReportRequired = []

###
# last_playlist = None
###

def __init__(self, config, platform, pHandler): # pylint: disable=redefined-outer-name
self.config = config
self.platform = platform
self.pHandler = pHandler # pylint: disable=invalid-name
self.tunein_parser = tunein.TuneIn(5000)

def play_playlist(self, payload):
###
# self.last_playlist = payload
###
self.navigation_token = payload['navigationToken']
self.playlist_last_item = payload['audioItem']['streams'][-1]['streamId']

Expand Down Expand Up @@ -341,9 +348,11 @@ def assistant_handler(voice_command):
return False
else:
voice_command = voice_command.rstrip()
logger.debug('Pocketsphinx triggered with hotword: **' + voice_command + '**')
logger.debug('Triggered with hotword: **' + voice_command + '**')
# compare to phrase_assistant from config
voice_command_assistant = config['triggers']['pocketsphinx']['phrase_assistant']
logger.debug('Google Assistant Hotword(s): ' + str(voice_command_assistant))

if voice_command in voice_command_assistant: # works for both lists and strings
global p
if p is not None:
Expand Down Expand Up @@ -389,7 +398,7 @@ def start_assistant():
else:
flush_size = ""
except:
logger.debug("Old configuration file without Assistant audio settings detected. To be able to adjust Google Adio settings, run setup again and create a new configuration.")
logger.debug("Old configuration file without Assistant audio settings detected. To be able to adjust Google Audio settings, run setup again and create a new configuration.")
logger.debug("see also https://developers.google.com/assistant/sdk/prototype/getting-started-pi-python/troubleshooting")

# Start Assistant SDK
Expand Down Expand Up @@ -554,6 +563,15 @@ def process_response(response):

logger.debug("new volume = %s", volume)

'''
This causes a deadlock on triggers
### Resume playing the last station after setting volume
if player.last_playlist is not None:
player.play_playlist(player.last_playlist)
###
'''


# Additional Audio Iten
elif 'audioItem' in j['messageBody']:
player.play_playlist(j['messageBody'])
Expand Down

0 comments on commit 06292e2

Please sign in to comment.