Anki Forums

Previewer: NoneType error for audio if additional card selected

  1. Select card with audio on it, hit preview so it shows a side that includes the latter
  2. Leaving the preview window open, add another card to the selection

Rather than switch to the “(please select 1 card)” warning if one was to try and open the previewer only now, the existing previewer stays as is, but bugs out if you try to…

… click any audio buttons with:

Caught exception:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/aqt/webview.py", line 37, in cmd
    return json.dumps(self.onCmd(str))
  File "/usr/lib/python3.8/site-packages/aqt/webview.py", line 123, in _onCmd
    return self._onBridgeCmd(str)
  File "/usr/lib/python3.8/site-packages/aqt/webview.py", line 574, in _onBridgeCmd
    return self.onBridgeCmd(cmd)
  File "/usr/lib/python3.8/site-packages/aqt/previewer.py", line 131, in _on_bridge_cmd
    play_clicked_audio(cmd, self.card())
  File "/usr/lib/python3.8/site-packages/aqt/sound.py", line 636, in play_clicked_audio
    tags = card.answer_av_tags()
AttributeError: 'NoneType' object has no attribute 'answer_av_tags'

… hit R for replay with:

Caught exception:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/aqt/previewer.py", line 103, in _on_replay_audio
    replay_audio(self.card(), False)
  File "/usr/lib/python3.8/site-packages/aqt/reviewer.py", line 37, in replay_audio
    tags = card.answer_av_tags()
AttributeError: 'NoneType' object has no attribute 'answer_av_tags'

e: Also, audio won’t end if the previewer is closed.

1 Like

I appreciate the report, but would appreciate a PR even more :slight_smile:

Thanks to @abdo for sending through a fix.

1 Like