Skip to content

Commit

Permalink
Change implementation of play and pause
Browse files Browse the repository at this point in the history
  • Loading branch information
ol-iver committed Jan 2, 2020
1 parent 7b9e3b1 commit a910a8d
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions denonavr/denonavr.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
TUNERSTATUS_URL = "/goform/formTuner_TunerXml.xml"
HDTUNERSTATUS_URL = "/goform/formTuner_HdXml.xml"
COMMAND_NETAUDIO_POST_URL = "/NetAudio/index.put.asp"
COMMAND_PAUSE = "/goform/formiPhoneAppDirect.xml?NS9B"
COMMAND_PLAY = "/goform/formiPhoneAppDirect.xml?NS9A"


# Main Zone URLs
Expand Down Expand Up @@ -142,7 +144,8 @@
"command_volume_down", "command_set_volume",
"command_mute_on", "command_mute_off",
"command_sel_sound_mode", "command_netaudio_post",
"command_set_all_zone_stereo"])
"command_set_all_zone_stereo", "command_pause",
"command_play"])

DENONAVR_URLS = ReceiverURLs(appcommand=APPCOMMAND_URL,
status=STATUS_URL,
Expand All @@ -162,7 +165,9 @@
command_mute_off=COMMAND_MUTE_OFF_URL,
command_sel_sound_mode=COMMAND_SEL_SM_URL,
command_netaudio_post=COMMAND_NETAUDIO_POST_URL,
command_set_all_zone_stereo=COMMAND_SET_ZST_URL)
command_set_all_zone_stereo=COMMAND_SET_ZST_URL,
command_pause=COMMAND_PAUSE,
command_play=COMMAND_PLAY)

ZONE2_URLS = ReceiverURLs(appcommand=APPCOMMAND_URL,
status=STATUS_Z2_URL,
Expand All @@ -182,7 +187,9 @@
command_mute_off=COMMAND_MUTE_OFF_Z2_URL,
command_sel_sound_mode=COMMAND_SEL_SM_URL,
command_netaudio_post=COMMAND_NETAUDIO_POST_URL,
command_set_all_zone_stereo=COMMAND_SET_ZST_URL)
command_set_all_zone_stereo=COMMAND_SET_ZST_URL,
command_pause=COMMAND_PAUSE,
command_play=COMMAND_PLAY)

ZONE3_URLS = ReceiverURLs(appcommand=APPCOMMAND_URL,
status=STATUS_Z3_URL,
Expand All @@ -202,7 +209,9 @@
command_mute_off=COMMAND_MUTE_OFF_Z3_URL,
command_sel_sound_mode=COMMAND_SEL_SM_URL,
command_netaudio_post=COMMAND_NETAUDIO_POST_URL,
command_set_all_zone_stereo=COMMAND_SET_ZST_URL)
command_set_all_zone_stereo=COMMAND_SET_ZST_URL,
command_pause=COMMAND_PAUSE,
command_play=COMMAND_PLAY)

POWER_ON = "ON"
POWER_OFF = "OFF"
Expand Down Expand Up @@ -1551,15 +1560,12 @@ def play(self):
"""Send play command to receiver command via HTTP post."""
# Use pause command only for sources which support NETAUDIO
if self._input_func in self._netaudio_func_list:
# In fact play command is a play/pause toggle. Thus checking state
if self._state == STATE_PLAYING:
_LOGGER.info("Already playing, play command not sent")
return False
body = {"cmd0": "PutNetAudioCommand/CurEnter",
"cmd1": "aspMainZone_WebUpdateStatus/",
"ZoneName": "MAIN ZONE"}
return True
try:
if self.send_post_command(
self._urls.command_netaudio_post, body):
if self.send_get_command(self._urls.command_play):
self._state = STATE_PLAYING
return True
else:
Expand All @@ -1572,15 +1578,8 @@ def pause(self):
"""Send pause command to receiver command via HTTP post."""
# Use pause command only for sources which support NETAUDIO
if self._input_func in self._netaudio_func_list:
if self._state == STATE_PAUSED:
_LOGGER.info("Already paused, pause command not sent")
return False
body = {"cmd0": "PutNetAudioCommand/CurEnter",
"cmd1": "aspMainZone_WebUpdateStatus/",
"ZoneName": "MAIN ZONE"}
try:
if self.send_post_command(
self._urls.command_netaudio_post, body):
if self.send_get_command(self._urls.command_pause):
self._state = STATE_PAUSED
return True
else:
Expand Down

0 comments on commit a910a8d

Please sign in to comment.