Beispiel #1
0
    def skip(self, track_number):
        if self.queue.is_empty():
            return
        if track_number > self.queue.size() - 1:
            return

        for i in range(track_number):
            self.queue.pop_item()
        reversed_list = list(self.queue)
        reversed_list.reverse()
        self.status.update_queue(reversed_list)

        self.callback_check('on_skip')
        if global_settings.audio_inst:
            stop_audio_instance()

        if track_number == 0:
            global_settings.gui_service.quick_gui(
                f"Skipping to next track in the audio queue.",
                text_type='header',
                box_align='left')
        else:
            global_settings.gui_service.quick_gui(
                f"Skipping to track {track_number} in the audio queue.",
                text_type='header',
                box_align='left')

        self.status['start_time'] = int(time())
        self.status['pause_time'] = 0
        self.status['progress_time'] = 0

        self.play(audio_lib=self.status['audio_library'], override=True)
Beispiel #2
0
 def play(self, audio_lib, override=False):
     if not override:
         if self.status.get_status() == TrackStatus.PLAYING:
             return
         if self.status.get_status() == TrackStatus.PAUSED:
             track_info = self.status.get_track()
         else:
             track_info = self.queue.pop_item()
             self.status.set_track(track_info)
             reversed_list = list(self.queue)
             reversed_list.reverse()
             self.status.update_queue(reversed_list)
     else:
         track_info = self.queue.pop_item()
         self.status.set_track(track_info)
         reversed_list = list(self.queue)
         reversed_list.reverse()
         self.status.update_queue(reversed_list)
     if not track_info:
         global_settings.gui_service.quick_gui(
             f"There is no track available to play",
             text_type='header',
             box_align='left')
         return
     self.callback_check('on_play')
     if global_settings.audio_inst:
         stop_audio_instance()
     self.status['audio_library'] = audio_lib
     create_audio_instance(self.status.get_track().uri,
                           skipto=self.status['progress_time'],
                           audio_lib=audio_lib)
     self.status['start_time'] = int(time())
     self.status.set_status(TrackStatus.PLAYING)
     if not track_info.quiet:
         self.display_playing_gui()
Beispiel #3
0
    def pause(self):
        if self.status.is_playing():
            if global_settings.audio_inst:
                stop_audio_instance()
            self.calculate_progress()
            self.status['pause_time'] = int(time())

            self.status.set_status(TrackStatus.PAUSED)
            global_settings.gui_service.quick_gui(
                f"Paused track at {self.audio_utilities.sec_formatted(self.status['progress_time'])}",
                text_type='header',
                box_align='left')
Beispiel #4
0
    def seek(self, seconds: int):
        if self.status.is_playing():
            if global_settings.audio_inst:
                stop_audio_instance()
            create_audio_instance(self.status.get_track().uri,
                                  skipto=seconds,
                                  audio_lib=self.status['audio_library'])

            self.status['start_time'] = int(time())
            self.status['pause_time'] = 0
            self.status['progress_time'] = int(seconds)

            global_settings.gui_service.quick_gui(
                f"Skipped to {str(timedelta(seconds=int(seconds)))} in the audio track.",
                text_type='header',
                box_align='left')
Beispiel #5
0
 def stop(self):
     if global_settings.audio_inst:
         stop_audio_instance()
     self.callback_check('on_stop')
     self.queue = queue_handler.QueueHandler(
         [],
         maxlen=int(
             global_settings.cfg[C_MEDIA_SETTINGS][P_MEDIA_QUEUE_LEN]))
     self.status.update({
         'plugin_owner':
         '',
         'plugin_name':
         '',
         'sender':
         '',
         'track':
         TrackInfo(uri='',
                   name='',
                   sender='',
                   duration=-1,
                   track_type=TrackType.FILE),
         'track_uri':
         '',
         'alt_uri':
         '',
         'image_uri':
         '',
         'img_uri_hashed':
         '',
         'track_id':
         '',
         'queue': [],
         'queue_length':
         0,
         'status':
         TrackStatus.STOPPED,
         'pause_time':
         0,
         'start_time':
         0,
         'progress_time':
         0,
         'volume':
         self.status['volume'],
         'loop':
         self.status['loop'],
         'duck_audio':
         self.status['duck_audio'],
         'ducking_volume':
         self.status['ducking_volume'],
         'ducking_threshold':
         self.status['ducking_threshold'],
         'ducking_delay':
         self.status['ducking_delay'],
         # Internal Audio Ducking Settings
         'is_ducking':
         False,
         'duck_start':
         0.0,
         'duck_end':
         0.0,
         'last_volume':
         self.status['last_volume'],
         'audio_library':
         ''
     })
     self.clear_dni()