diff --git a/aqt/editor.py b/aqt/editor.py index e92e7e14b..2cbbab911 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -891,7 +891,8 @@ to a cloze type first, via Edit>Change Note Type.""")) "Couldn't record audio. Have you installed lame and sox?") + "\n\n" + repr(str(e))) return - self.addMedia(file) + if file: + self.addMedia(file) # Media downloads ###################################################################### diff --git a/aqt/sound.py b/aqt/sound.py index ffd23853b..2c8fb39b6 100644 --- a/aqt/sound.py +++ b/aqt/sound.py @@ -15,10 +15,11 @@ def getAudio(parent, encode=True): restoreGeom(mb, "audioRecorder") mb.setWindowTitle("Anki") mb.setIconPixmap(QPixmap(":/icons/media-record.png")) - but = QPushButton(_(" Stop")) - but.setIcon(QIcon(":/icons/media-playback-stop.png")) - #but.setIconSize(QSize(32, 32)) + but = QPushButton(_("Save")) + mb.addButton(but, QMessageBox.AcceptRole) + but = QPushButton(_("Cancel")) mb.addButton(but, QMessageBox.RejectRole) + mb.setEscapeButton(but) t = time.time() r.start() QApplication.instance().processEvents() @@ -27,6 +28,9 @@ def getAudio(parent, encode=True): mb.setText(txt % (time.time() - t)) mb.show() QApplication.instance().processEvents() + if mb.clickedButton() == mb.escapeButton(): + r.stop() + return saveGeom(mb, "audioRecorder") # ensure at least a second captured while time.time() - t < 1: