def play_update(self):
        global framerate

        if not self.player.music.get_busy():
            return
        millis = int(self.player.music.get_pos())

        if self.slider_moved:
            slider_pos = int(self.my_slider.get()) * 1000
            self.ext_time = millis + slider_pos
            self.slider_moved = False

        fr_cur = int((millis / 1000 * framerate) % framerate)
        if fr_cur != self.fr_prev:
            param_list = self.active_song_param()
            song_anet_time = param_list[2]
            anet_millis = self.ext_time + millis + song_anet_time
            a1 = artnet_tc.anet_conv(anet_millis, framerate)
            self.opened_socket.sendto(a1, (self.broadcast_ip, 6454))
            self.fr_prev = fr_cur
            # Display current TC
            tc_str = artnet_tc.millis_to_tc(self.ext_time + millis, framerate)
            self.labeltextTC.set(tc_str)
            anet_tc_str = artnet_tc.millis_to_tc(anet_millis, framerate)
            self.labeltextATC.set(anet_tc_str)

        self.my_slider.after(5, self.play_update)
    def callback_listbox(self, event):
        #self.stop()
        param_list = self.active_song_param()
        print(param_list)

        song_anet_time = param_list[2]
        # song_index = self.song_box.curselection()
        global framerate

        try:
            song_ext = param_list[3]
            song_anet_time = param_list[2]
            song_duration = param_list[1]
            self.labeltextATC.set(
                artnet_tc.millis_to_tc(song_anet_time, framerate))
            print(artnet_tc.millis_to_tc(song_anet_time, framerate))
            audio_duration = artnet_tc.millis_to_tc(song_duration * 1000,
                                                    framerate)
            self.status_bar.config(text=audio_duration + '  ')

            if song_ext == "WAV":
                self.my_slider.state(['disabled'])
                self.paused = False
            else:
                self.my_slider.state(['!disabled'])
                self.paused = False
        except TypeError:
            print("TypeError callback_listbox")
    def slider_update(self, value):
        param_list = self.active_song_param()
        song_path = param_list[0]
        song_length = param_list[1]
        song_anet_time = param_list[2]
        self.player.music.load(song_path)
        slider_size = int(song_length)
        self.my_slider.config(to=slider_size, value=self.my_slider.get())

        # update Audio TC and ArtNet TC label data
        tc_str = artnet_tc.millis_to_tc(int(self.my_slider.get() * 1000),
                                        framerate)
        self.labeltextTC.set(tc_str)
        anet_tc_str = artnet_tc.millis_to_tc(
            int(self.my_slider.get() * 1000) + song_anet_time, framerate)
        self.labeltextATC.set(anet_tc_str)
        self.slider_moved = True

        if self.stopped or self.paused:
            return
        elif not self.stopped or not self.paused:
            pygame.mixer.music.play(loops=0, start=int(self.my_slider.get()))
    def stop(self):
        self.player.music.stop()
        self.enable_gui()
        # song_box.selection_clear(ACTIVE)
        self.stopped = True

        param_list = self.active_song_param()
        song_length = param_list[1]
        song_anet_time = param_list[2]

        slider_position = int(song_length)
        self.my_slider.config(to=slider_position, value=0)
        self.status_bar.config(text=f'STOPPED  ')

        # update Audio TC and ArtNet TC label data
        tc_str = artnet_tc.millis_to_tc(int(self.my_slider.get() * 1000),
                                        framerate)
        self.labeltextTC.set(tc_str)
        anet_tc_str = artnet_tc.millis_to_tc(
            int(self.my_slider.get() * 1000) + song_anet_time, framerate)
        self.labeltextATC.set(anet_tc_str)
        self.slider_moved = True
 def save_tc(self):
     song_index = self.song_box.curselection()
     try:
         if song_index[0] >= 0:
             song_index = int(song_index[0])
             print(song_index)
             print(self.listofsongs[song_index])
             tcstr_append = self.anetTextTC.get()
             tclist = tcstr_append.split(':')
             fr_ms = int(round(int(tclist[3]) * 1000 / framerate))
             msecs = int(tclist[0]) * 60 * 60 * 1000 + int(
                 tclist[1]) * 60 * 1000 + int(tclist[2]) * 1000 + fr_ms + 1
             # Save ArtNet offset to list
             self.songsartnet_time[song_index] = msecs
             # Output ArtNet offset
             self.labeltextATC.set(artnet_tc.millis_to_tc(msecs, framerate))
     except IndexError:
         print("IndexError")
         self.status_bar.config(text=f'SELECT AUDIO TO SAVE TC!  ')
     except TypeError:
         print("TypeError")