comparison cagou/plugins/plugin_transfer_voice.py @ 312:772c170b47a9

Python3 port: /!\ Cagou now runs with Python 3.6+ Port has been done in the same way as for backend (check backend commit b2d067339de3 message for details).
author Goffi <goffi@goffi.org>
date Tue, 13 Aug 2019 19:14:22 +0200
parents ca4daced4638
children 4d660b252487
comparison
equal deleted inserted replaced
311:a0d978d3ce84 312:772c170b47a9
29 if sys.platform == "android": 29 if sys.platform == "android":
30 from plyer import audio 30 from plyer import audio
31 31
32 32
33 PLUGIN_INFO = { 33 PLUGIN_INFO = {
34 "name": _(u"voice"), 34 "name": _("voice"),
35 "main": "VoiceRecorder", 35 "main": "VoiceRecorder",
36 "platforms": ["android"], 36 "platforms": ["android"],
37 "description": _(u"transmit a voice record"), 37 "description": _("transmit a voice record"),
38 "icon_medium": u"{media}/icons/muchoslava/png/micro_off_50.png", 38 "icon_medium": "{media}/icons/muchoslava/png/micro_off_50.png",
39 } 39 }
40 40
41 41
42 class VoiceRecorder(BoxLayout): 42 class VoiceRecorder(BoxLayout):
43 callback = properties.ObjectProperty() 43 callback = properties.ObjectProperty()
65 try: 65 try:
66 audio.stop() 66 audio.stop()
67 except Exception as e: 67 except Exception as e:
68 # an exception can happen if record is pressed 68 # an exception can happen if record is pressed
69 # repeatedly in a short time (not a normal use) 69 # repeatedly in a short time (not a normal use)
70 log.warning(u"Exception on stop: {}".format(e)) 70 log.warning("Exception on stop: {}".format(e))
71 self._counter_timer.cancel() 71 self._counter_timer.cancel()
72 self.time = self.time + 1 72 self.time = self.time + 1
73 else: 73 else:
74 audio.start() 74 audio.start()
75 self._started_at = time.time() 75 self._started_at = time.time()
97 try: 97 try:
98 audio.play() 98 audio.play()
99 except Exception as e: 99 except Exception as e:
100 # an exception can happen in the same situation 100 # an exception can happen in the same situation
101 # as for audio.stop() above (i.e. bad record) 101 # as for audio.stop() above (i.e. bad record)
102 log.warning(u"Exception on play: {}".format(e)) 102 log.warning("Exception on play: {}".format(e))
103 self.time = 0 103 self.time = 0
104 return 104 return
105 105
106 self.playing = True 106 self.playing = True
107 self.record_time = self.time 107 self.record_time = self.time