Beispiel #1
0
    def _button_release_cb(self, win, event):
        ''' Play a sound or video or jump to a card as indexed in the list. '''
        win.grab_focus()

        x, y = map(int, event.get_coords())
        spr = self._sprites.find_sprite((x, y))

        self.current_card = -1

        if self._activity.mode == 'letter':
            if spr in self._cards:
                self.current_card = self._cards.index(spr)
                play_audio_from_file(self._card_data[self.current_card][-1])
                return

            for a in self._image_data:
                for b in self._image_data[a]:
                    if spr == b[0]:
                         play_audio_from_file(b[1])
                         for c in range(len(self._card_data)):
                            if self._card_data[c][0] == a:
                                self.current_card = c
                                break
                         break
        else:
            for a in self._image_data:
                for b in self._image_data[a]:
                    if spr == b[0]:
                        play_audio_from_file(b[1])
                        return

            if spr in self._cards:
                self.current_card = self._cards.index(spr)
                play_audio_from_file(self._card_data[self.current_card][-1])

        if self.current_card == self.target:
            self._activity.status.set_text(_('Very good!'))
            self._play(True)
            if self.timeout is not None:
                GObject.source_remove(self.timeout)
            self.timeout = GObject.timeout_add(1000, self.new_page)
        else:
            self._activity.status.set_text(_('Please try again.'))
            self._play(False)
            self._play_target_sound()
            self.timeout = GObject.timeout_add(1000, self._hide_feedback)
Beispiel #2
0
    def _button_release_cb(self, win, event):
        ''' Play a sound or video or jump to a card as indexed in the list. '''
        win.grab_focus()

        x, y = map(int, event.get_coords())
        spr = self._sprites.find_sprite((x, y))

        self.current_card = -1

        if self._activity.mode == 'letter':
            if spr in self._cards:
                self.current_card = self._cards.index(spr)
                play_audio_from_file(self._card_data[self.current_card][-1])
                return

            for a in self._image_data:
                for b in self._image_data[a]:
                    if spr == b[0]:
                        play_audio_from_file(b[1])
                        for c in range(len(self._card_data)):
                            if self._card_data[c][0] == a:
                                self.current_card = c
                                break
                        break
        else:
            for a in self._image_data:
                for b in self._image_data[a]:
                    if spr == b[0]:
                        play_audio_from_file(b[1])
                        return

            if spr in self._cards:
                self.current_card = self._cards.index(spr)
                play_audio_from_file(self._card_data[self.current_card][-1])

        if self.current_card == self.target:
            self._activity.status.set_text(_('Very good!'))
            self._play(True)
            if self.timeout is not None:
                GObject.source_remove(self.timeout)
            self.timeout = GObject.timeout_add(1000, self.new_page)
        else:
            self._activity.status.set_text(_('Please try again.'))
            self._play(False)
            self._play_target_sound()
            self.timeout = GObject.timeout_add(1000, self._hide_feedback)
Beispiel #3
0
    def _button_release_cb(self, win, event):
        ''' Play a sound or video or jump to a card as indexed in the list. '''
        win.grab_focus()

        if self._looking_at_word_list:
            self._looking_at_word_list = False
            if self._goto_page > self.page:
                for _i in range(self._goto_page - self.page):
                    self.page += 1
                    self.new_page()
            else:
                self.page = self._goto_page
                self.new_page()
        else:
            x, y = map(int, event.get_coords())
            spr = self._sprites.find_sprite((x, y))
            if spr == self._picture:
                if self.page < len(self._card_data):
                    if len(self._media_data[self.page][0]) > 4 and \
                       os.path.exists(os.path.join(
                            self._sounds_path,
                            self._media_data[self.page][0])):
                        play_audio_from_file(
                            self,
                            os.path.join(self._sounds_path,
                                         self._media_data[self.page][0]))
            elif spr == self._cards[self.page]:
                if self.page < len(self._card_data):
                    if os.path.exists(
                            os.path.join(self._sounds_path,
                                         self._media_data[self.page][1])):
                        play_audio_from_file(
                            self,
                            os.path.join(self._sounds_path,
                                         self._media_data[self.page][1]))
                    '''
Beispiel #4
0
 def _play_target_sound(self):
     if self._activity.mode in ['letter', 'find by letter']:
         play_audio_from_file(os.path.join(
                 self._sounds_path,
                 self._media_data[self.target][1]))
     elif self._activity.mode == 'picture':
         play_audio_from_file(os.path.join(
                 self._sounds_path,
                 self._media_data[self.target][1]))
         GObject.timeout_add(1000, play_audio_from_file, os.path.join(
                 self._sounds_path,
                 self._media_data[self.target][0]))
     else:
         play_audio_from_file(os.path.join(
                 self._sounds_path,
                 self._media_data[self.target][0]))
     self.timeout = None
Beispiel #5
0
 def _play_target_sound(self):
     if self._activity.mode in ['letter', 'find by letter']:
         play_audio_from_file(
             os.path.join(self._sounds_path,
                          self._media_data[self.target][1]))
     elif self._activity.mode == 'picture':
         play_audio_from_file(
             os.path.join(self._sounds_path,
                          self._media_data[self.target][1]))
         GObject.timeout_add(
             1000, play_audio_from_file,
             os.path.join(self._sounds_path,
                          self._media_data[self.target][0]))
     else:
         play_audio_from_file(
             os.path.join(self._sounds_path,
                          self._media_data[self.target][0]))
     self.timeout = None
Beispiel #6
0
 def _play_target_sound(self, queue=True):
     if self._activity.mode == 'letter':
         play_audio_from_file(self._card_data[self.target][-1], queue)
     else:
         play_audio_from_file(self.chosen_image[-1], queue)
     self.timeout = None
Beispiel #7
0
 def _play_target_sound(self, queue=True):
     if self._activity.mode == 'letter':
         play_audio_from_file(self._card_data[self.target][-1], queue)
     else:
         play_audio_from_file(self.chosen_image[-1], queue)
     self.timeout = None
 def _play_audio_cb(self, win, event):
     ''' Preview audio '''
     if self.audio_id:
         play_audio_from_file(datastore.get(self.audio_id).get_file_path())
 def _playback_recording_cb(self, button=None):
     play_audio_from_file(self._page,
                          os.path.join(self.datapath, 'output.ogg'))
     return