Guest User

Manage Decks

a guest
Jul 26th, 2021
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from PyQt5 import QtCore, QtGui, QtWidgets
  2. from PyQt5.QtWidgets import QApplication, QDialog, QLabel, QMessageBox
  3. from PyQt5.QtCore import QObject, QThread, pyqtSignal
  4. from PyQt5.QtCore import Qt, pyqtSignal, QTimer
  5. import data
  6. import os
  7. from datetime import datetime
  8. from pydub import AudioSegment,effects,utils,generators
  9. import pyaudio
  10. import miniaudio
  11. import math
  12. from time import sleep
  13. import time
  14. import wave
  15. from pynput.keyboard import Key,Controller
  16. import sys
  17. import io
  18. import queue
  19. import math
  20.  
  21. class Manage_Decks:
  22.  
  23.     def __init__(self,main_self):
  24.         self.main_self = main_self
  25.        
  26.         system_volume = int(self.main_self.main_ui.general_deck_system_control.value())
  27.         volume = int(self.main_self.main_ui.general_deck_volume_control.value())
  28.         normalize = int(self.main_self.main_ui.general_deck_normalize_checkbox.isChecked())
  29.         pan = int(self.main_self.main_ui.general_deck_pan_control.value())
  30.         low_frequency = int(self.main_self.main_ui.general_deck_low_frequency_input.text())
  31.         high_frequency = int(self.main_self.main_ui.general_deck_high_frequency_input.text())
  32.         if self.RepresentsInt(low_frequency)==False or self.RepresentsInt(high_frequency) ==False:
  33.             low_frequency = 20
  34.             self.main_self.main_ui.general_deck_low_frequency_input.setText(20)
  35.             high_frequency = 20000
  36.             self.main_self.main_ui.general_deck_high_frequency_input.setText(20000)
  37.         else:
  38.             if low_frequency>high_frequency:
  39.                 low_frequency = 20
  40.                 high_frequency = 20000
  41.                 self.main_self.main_ui.general_deck_low_frequency_input.setText(20)
  42.                 self.main_self.main_ui.general_deck_high_frequency_input.setText(20000)
  43.             else:
  44.                 if low_frequency<20 or high_frequency<20 or high_frequency>20000 or low_frequency>20000:
  45.                     low_frequency = 20
  46.                     high_frequency = 20000
  47.                     self.main_self.main_ui.general_deck_low_frequency_input.setText(20)
  48.                     self.main_self.main_ui.general_deck_high_frequency_input.setText(20000)
  49.        
  50.         self.active_transmition = False
  51.        
  52.         self.general_deck = {
  53.             "system-volume":system_volume,
  54.             "volume":volume,
  55.             "normalize":normalize,
  56.             "pan":pan,
  57.             "low-frequency":low_frequency,
  58.             "high-frequency":high_frequency,
  59.             "play-status":"stopped"
  60.         }
  61.        
  62.         self.deck_1 = {
  63.             "player-list-item":None,
  64.             "player-list-row":None,
  65.             "play-status":"stopped",
  66.             "chunk-number":0,
  67.             "mute":0,
  68.             "total-duration-human":"00:00:00",
  69.             "total-duration-milliseconds":0,
  70.             "current-duration-milliseconds":0,
  71.             "muted":False,
  72.             "volume":100,
  73.             "normalize":0,
  74.             "pan":0,
  75.             "low-frequency":20,
  76.             "high-frequency":20000,
  77.             "player-history-number":None,
  78.             "stopped-timestamp":0,
  79.             "paused-timestamp":0,
  80.         }
  81.        
  82.         self.deck_2 = {
  83.             "player-list-item":None,
  84.             "player-list-row":None,
  85.             "play-status":"stopped",
  86.             "chunk-number":0,
  87.             "mute":0,
  88.             "total-duration-human":"00:00:00",
  89.             "total-duration-milliseconds":0,
  90.             "current-duration-milliseconds":0,
  91.             "muted":False,
  92.             "volume":100,
  93.             "normalize":0,
  94.             "pan":0,
  95.             "low-frequency":20,
  96.             "high-frequency":20000,
  97.             "player-history-number":None,
  98.             "stopped-timestamp":0,
  99.             "paused-timestamp":0,
  100.         }
  101.        
  102.         self.music_clip_deck = {
  103.             "player-list-item":None,
  104.             "player-list-row":None,
  105.             "play-status":"stopped",
  106.             "chunk-number":0,
  107.             "mute":0,
  108.             "total-duration-human":"00:00:00",
  109.             "total-duration-milliseconds":0,
  110.             "current-duration-milliseconds":0,
  111.             "muted":False,
  112.             "volume":100,
  113.             "normalize":0,
  114.             "pan":0,
  115.             "low-frequency":20,
  116.             "high-frequency":20000,
  117.             "player-history-number":None,
  118.             "stopped-timestamp":0,
  119.             "paused-timestamp":0,
  120.         }
  121.        
  122.         self.speackers_deck = {
  123.             "play-status":"stopped",
  124.             "volume":100,
  125.             "normalize":0,
  126.             "pan":0,
  127.             "mute":0,
  128.             "low-frequency":20,
  129.             "high-frequency":20000
  130.         }
  131.        
  132.         self.ip_call_1 = {
  133.             "call-status":"stopped",
  134.             "volume":100,
  135.             "normalize":0,
  136.             "pan":0,
  137.             "mute":0,
  138.             "low-frequency":20,
  139.             "high-frequency":20000,
  140.         }
  141.        
  142.         self.ip_call_2 = {
  143.             "call-status":"stopped",
  144.             "volume":100,
  145.             "normalize":0,
  146.             "pan":0,
  147.             "mute":0,
  148.             "low-frequency":20,
  149.             "high-frequency":20000
  150.         }
  151.        
  152.         self.ip_call_3 = {
  153.             "call-status":"stopped",
  154.             "volume":100,
  155.             "normalize":0,
  156.             "pan":0,
  157.             "low-frequency":20,
  158.             "high-frequency":20000
  159.         }
  160.        
  161.         self.active_radio_connections = []
  162.        
  163.         self.record_status = "stopped"
  164.        
  165.         #get system_sound_volume
  166.         self.general_deck["system-volume"] = int(data.read_setting("system sound volume")[0]["current value"])
  167.        
  168.         #for system-volume
  169.         self.keyboard = Controller()
  170.  
  171.         for i in range(50):
  172.             self.keyboard.press(Key.media_volume_down)
  173.             self.keyboard.release(Key.media_volume_down)
  174.            
  175.         for i in range(0,int(self.general_deck["system-volume"]/2)):
  176.             self.keyboard.press(Key.media_volume_up)
  177.             self.keyboard.release(Key.media_volume_up)
  178.            
  179.         self.main_self.main_ui.general_deck_system_control.setValue(int(self.general_deck["system-volume"]))
  180.         self.main_self.main_ui.general_deck_volume_label_2.setText(str(self.general_deck["system-volume"])+"/100")
  181.  
  182.        
  183.         #create music thread
  184.         self.send_data_to_servers = Send_Data_To_Servers()
  185.         self.send_data_to_servers.connections = self.main_self.manage_connections.connections
  186.         self.send_data_to_servers.start()
  187.        
  188.         self.microphone_input = Microphone()
  189.         self.microphone_input.microphone_segment_ready.connect(self.put_microphone_segment_to_queue)
  190.         self.microphone_input.start()
  191.        
  192.         self.papinhio_player = Papinhio_Player(self.general_deck)
  193.         self.papinhio_player.connections = self.main_self.manage_connections.connections
  194.         self.papinhio_player.start()
  195.        
  196.         #display music clips
  197.         self.display_music_clips()
  198.        
  199.         #create thread emit function for final slice
  200.         self.papinhio_player.final_slice_ready.connect(self.final_slice_ready_method)
  201.        
  202.         #create thread emit function handlers for general deck
  203.         self.papinhio_player.general_deck_status_signal.connect(self.general_deck_status_changed)
  204.         self.papinhio_player.general_deck_volume_signal.connect(self.general_deck_volume_changed)
  205.        
  206.         #create thread emit function handlers for deck 1
  207.         self.papinhio_player.deck_1_status_signal.connect(self.deck_1_status_changed)
  208.         self.papinhio_player.deck_1_duration_signal.connect(self.deck_1_duration_changed)
  209.         self.papinhio_player.deck_1_volume_signal.connect(self.deck_1_volume_strength_changed)
  210.        
  211.         #create thread emit function handlers for deck 2
  212.         self.papinhio_player.deck_2_status_signal.connect(self.deck_2_status_changed)
  213.         self.papinhio_player.deck_2_duration_signal.connect(self.deck_2_duration_changed)
  214.         self.papinhio_player.deck_2_volume_signal.connect(self.deck_2_volume_strength_changed)
  215.        
  216.         #create thread emit function handlers for music clip deck
  217.         self.papinhio_player.music_clip_deck_status_signal.connect(self.music_clip_deck_status_changed)
  218.         self.papinhio_player.music_clip_deck_duration_signal.connect(self.music_clip_deck_duration_changed)
  219.         self.papinhio_player.music_clip_deck_volume_signal.connect(self.music_clip_deck_volume_strength_changed)
  220.        
  221.         #create thread emit function handlers for speackers deck
  222.         self.papinhio_player.speackers_deck_duration_signal.connect(self.speackers_deck_duration_changed)
  223.         self.papinhio_player.speackers_deck_volume_signal.connect(self.speackers_deck_volume_strength_changed)
  224.        
  225.         #create thread emit function handlers for ip call 1 deck
  226.         self.papinhio_player.ip_call_1_deck_duration_signal.connect(self.ip_call_1_deck_duration_changed)
  227.         self.papinhio_player.ip_call_1_deck_volume_signal.connect(self.ip_call_1_deck_volume_strength_changed)
  228.        
  229.         #create thread emit function handlers for ip call 2 deck
  230.         self.papinhio_player.ip_call_2_deck_duration_signal.connect(self.ip_call_2_deck_duration_changed)
  231.         self.papinhio_player.ip_call_2_deck_volume_signal.connect(self.ip_call_2_deck_volume_strength_changed)
  232.        
  233.         #create thread emit function handlers for ip call 3 deck
  234.         self.papinhio_player.ip_call_3_deck_duration_signal.connect(self.ip_call_3_deck_duration_changed)
  235.         self.papinhio_player.ip_call_3_deck_volume_signal.connect(self.ip_call_3_deck_volume_strength_changed)
  236.        
  237.        
  238.        
  239.         #create event handlers for general deck
  240.         self.main_self.main_ui.general_deck_previous_song.clicked.connect(lambda:self.load_previous_song())
  241.         self.main_self.main_ui.general_deck_play_or_pause.clicked.connect(lambda:self.general_deck_play_or_pause_clicked())
  242.         self.main_self.main_ui.general_deck_stop.clicked.connect(lambda:self.general_deck_stop_clicked())
  243.         self.main_self.main_ui.general_deck_next_song.clicked.connect(lambda:self.load_next_song())
  244.         self.main_self.main_ui.general_deck_auto_dj.clicked.connect(lambda:self.manage_auto_dj())
  245.         self.main_self.main_ui.general_deck_repeat_playlist_checkBox.stateChanged.connect(lambda:self.repeat_player_list_checkbox_changed())
  246.         self.main_self.main_ui.general_deck_volume_control.valueChanged.connect(lambda:self.general_deck_signal_volume_changed())
  247.         self.main_self.main_ui.general_deck_reset_volume_strength.clicked.connect(lambda:self.general_deck_reset_volume_signal())
  248.         self.main_self.main_ui.general_deck_system_control.sliderReleased.connect(lambda:self.general_deck_system_volume_changed())
  249.         self.main_self.main_ui.general_deck_reset_system_volume.clicked.connect(lambda:self.general_deck_reset_system_volume())
  250.         self.main_self.main_ui.general_deck_normalize_checkbox.stateChanged.connect(lambda:self.general_deck_normalize_changed())
  251.         self.main_self.main_ui.general_deck_pan_control.valueChanged.connect(lambda:self.general_deck_pan_changed())
  252.         self.main_self.main_ui.general_deck_reset_pan.clicked.connect(lambda:self.general_deck_reset_pan())
  253.         self.main_self.main_ui.general_deck_apply_filter.clicked.connect(lambda:self.general_deck_apply_filter())
  254.         self.main_self.main_ui.general_deck_reset_filter.clicked.connect(lambda:self.general_deck_reset_filter())
  255.         self.main_self.main_ui.open_records_folder.clicked.connect(lambda:self.open_records_folder())
  256.         self.main_self.main_ui.player_history_report.clicked.connect(lambda:self.create_player_history_report())
  257.        
  258.         #create event handlers for deck 1
  259.         self.main_self.main_ui.deck_1_timeline.valueChanged.connect(lambda:self.deck_1_timeline_changed())
  260.         self.main_self.main_ui.deck_1_play_pause.clicked.connect(lambda:self.deck_1_play_or_pause_clicked())
  261.         self.main_self.main_ui.deck_1_stop.clicked.connect(lambda:self.deck_1_stop_clicked())
  262.         self.main_self.main_ui.deck_1_mute.clicked.connect(lambda:self.deck_1_mute_clicked())
  263.         self.main_self.main_ui.deck_1_volume_control.valueChanged.connect(lambda:self.deck_1_volume_changed())
  264.         self.main_self.main_ui.deck_1_normalize.stateChanged.connect(lambda:self.deck_1_normalize_changed())
  265.         self.main_self.main_ui.deck_1_pan_control.valueChanged.connect(lambda:self.deck_1_pan_changed())
  266.         self.main_self.main_ui.deck_1_apply_filter.clicked.connect(lambda:self.deck_1_apply_filter())
  267.         self.main_self.main_ui.deck_1_reset_filter.clicked.connect(lambda:self.deck_1_reset_filter())
  268.        
  269.         #create event handlers for deck 2
  270.         self.main_self.main_ui.deck_2_timeline.valueChanged.connect(lambda:self.deck_2_timeline_changed())
  271.         self.main_self.main_ui.deck_2_play_pause.clicked.connect(lambda:self.deck_2_play_or_pause_clicked())
  272.         self.main_self.main_ui.deck_2_stop.clicked.connect(lambda:self.deck_2_stop_clicked())
  273.         self.main_self.main_ui.deck_2_mute.clicked.connect(lambda:self.deck_2_mute_clicked())
  274.         self.main_self.main_ui.deck_2_volume_control.valueChanged.connect(lambda:self.deck_2_volume_changed())
  275.         self.main_self.main_ui.deck_2_normalize.stateChanged.connect(lambda:self.deck_2_normalize_changed())
  276.         self.main_self.main_ui.deck_2_pan_control.valueChanged.connect(lambda:self.deck_2_pan_changed())
  277.         self.main_self.main_ui.deck_2_apply_filter.clicked.connect(lambda:self.deck_2_apply_filter())
  278.         self.main_self.main_ui.deck_2_reset_filter.clicked.connect(lambda:self.deck_2_reset_filter())
  279.        
  280.         #create event handlers for music clip deck
  281.         self.main_self.main_ui.music_clip_deck_timeline.valueChanged.connect(lambda:self.music_clip_deck_timeline_changed())
  282.         self.main_self.main_ui.music_clip_deck_play_pause.clicked.connect(lambda:self.music_clip_deck_play_or_pause_clicked())
  283.         self.main_self.main_ui.music_clip_deck_stop.clicked.connect(lambda:self.music_clip_deck_stop_clicked())
  284.         self.main_self.main_ui.music_clip_deck_mute.clicked.connect(lambda:self.music_clip_deck_mute_clicked())
  285.         self.main_self.main_ui.music_clip_deck_volume_control.valueChanged.connect(lambda:self.music_clip_deck_volume_changed())
  286.         self.main_self.main_ui.music_clip_normalize.stateChanged.connect(lambda:self.music_clip_deck_normalize_changed())
  287.         self.main_self.main_ui.music_clip_deck_pan_control.valueChanged.connect(lambda:self.music_clip_deck_pan_changed())
  288.         self.main_self.main_ui.music_clip_deck_apply_filter.clicked.connect(lambda:self.music_clip_deck_apply_filter())
  289.         self.main_self.main_ui.music_clip_deck_reset_filter.clicked.connect(lambda:self.music_clip_deck_reset_filter())
  290.        
  291.         #create event handlers for speackers deck
  292.         self.main_self.main_ui.speakers_deck_open_or_close_microphone.clicked.connect(lambda:self.speackers_deck_click_to_talk_clicked())
  293.         self.main_self.main_ui.speakers_deck_click_to_talk.pressed.connect(lambda:self.speackers_deck_click_to_talk_pressed())
  294.         self.main_self.main_ui.speakers_deck_click_to_talk.released.connect(lambda:self.speackers_deck_click_to_talk_released())
  295.         self.main_self.main_ui.speackers_deck_volume_control.valueChanged.connect(lambda:self.speackers_deck_volume_changed())
  296.         self.main_self.main_ui.speackers_deck_normalize.stateChanged.connect(lambda:self.speackers_deck_normalize_changed())
  297.         self.main_self.main_ui.speackers_deck_pan_control.valueChanged.connect(lambda:self.speackers_deck_pan_changed())
  298.         self.main_self.main_ui.speackers_deck_apply_filter.clicked.connect(lambda:self.speackers_deck_apply_filter())
  299.         self.main_self.main_ui.speackers_deck_reset_filter.clicked.connect(lambda:self.speackers_deck_reset_filter())
  300.        
  301.         #create event handlers for ip call 1 deck
  302.         self.main_self.main_ui.ip_call_1_answer.clicked.connect(lambda:self.ip_call_1_deck_answer())
  303.         self.main_self.main_ui.ip_call_1_reject.clicked.connect(lambda:self.ip_call_1_deck_reject())
  304.         self.main_self.main_ui.ip_call_1_forward.clicked.connect(lambda:self.ip_call_1_transmit_call())
  305.         self.main_self.main_ui.ip_call_1_volume_control.valueChanged.connect(lambda:self.ip_call_1_deck_volume_changed())
  306.         self.main_self.main_ui.ip_call_1_normalize.stateChanged.connect(lambda:self.ip_call_1_deck_normalize_changed())
  307.         self.main_self.main_ui.ip_call_1_pan_control.valueChanged.connect(lambda:self.ip_call_1_deck_pan_changed())
  308.         self.main_self.main_ui.ip_call_1_apply_filter.clicked.connect(lambda:self.ip_call_1_deck_apply_filter())
  309.         self.main_self.main_ui.ip_call_1_reset_filter.clicked.connect(lambda:self.ip_call_1_deck_reset_filter())
  310.        
  311.         #create event handlers for ip call 2 deck
  312.         self.main_self.main_ui.ip_call_2_answer.clicked.connect(lambda:self.ip_call_2_deck_answer())
  313.         self.main_self.main_ui.ip_call_2_reject.clicked.connect(lambda:self.ip_call_2_deck_reject())
  314.         self.main_self.main_ui.ip_call_2_forward.clicked.connect(lambda:self.ip_call_2_transmit_call())
  315.         self.main_self.main_ui.ip_call_2_volume_control.valueChanged.connect(lambda:self.ip_call_2_deck_volume_changed())
  316.         self.main_self.main_ui.ip_call_2_normalize.stateChanged.connect(lambda:self.ip_call_2_deck_normalize_changed())
  317.         self.main_self.main_ui.ip_call_2_pan_control.valueChanged.connect(lambda:self.ip_call_2_deck_pan_changed())
  318.         self.main_self.main_ui.ip_call_2_apply_filter.clicked.connect(lambda:self.ip_call_2_deck_apply_filter())
  319.         self.main_self.main_ui.ip_call_2_reset_filter.clicked.connect(lambda:self.ip_call_2_deck_reset_filter())
  320.        
  321.         #create event handlers for ip call 3 deck
  322.         self.main_self.main_ui.ip_call_3_answer.clicked.connect(lambda:self.ip_call_3_deck_answer())
  323.         self.main_self.main_ui.ip_call_3_reject.clicked.connect(lambda:self.ip_call_3_deck_reject())
  324.         self.main_self.main_ui.ip_call_3_forward.clicked.connect(lambda:self.ip_call_3_transmit_call())
  325.         self.main_self.main_ui.ip_call_3_volume_control.valueChanged.connect(lambda:self.ip_call_3_deck_volume_changed())
  326.         self.main_self.main_ui.ip_call_3_normalize.stateChanged.connect(lambda:self.ip_call_3_deck_normalize_changed())
  327.         self.main_self.main_ui.ip_call_3_pan_control.valueChanged.connect(lambda:self.ip_call_3_deck_pan_changed())
  328.         self.main_self.main_ui.ip_call_3_apply_filter.clicked.connect(lambda:self.ip_call_3_deck_apply_filter())
  329.         self.main_self.main_ui.ip_call_3_reset_filter.clicked.connect(lambda:self.ip_call_3_deck_reset_filter())
  330.        
  331.         self.set_greek_timer_function()
  332.        
  333.     def put_microphone_segment_to_queue(self,segment):
  334.         self.papinhio_player.microphone_queue.put(segment)
  335.  
  336.     def final_slice_ready_method(self,segment):
  337.         self.send_data_to_servers.q.put(segment)
  338.  
  339.     def reload_player_list_data(self):
  340.         self.active_transmition = False
  341.         self.deactivate_auto_dj()
  342.        
  343.         #delete player_list_data
  344.         #data.empty_player_list()
  345.        
  346.         #put previous player list data
  347.         for item in self.player_list_data_copy:
  348.             if item["type"]!="retransmitions" and item["type"]!="greek time files":
  349.                 data.add_to_player_list_bottom(item["type"],item["relative number"])
  350.             elif item["type"]=="retransmitions":
  351.                 data.add_retransmition_to_player_list_bottom(item["relative number"],item["duration"])
  352.             else:
  353.                 data.add_greek_time_to_player_list(item["relative number"])
  354.                
  355.         self.main_self.display_player_list_items(search=False,first_time=False)
  356.         self.active_transmition = False
  357.         self.activate_auto_dj()
  358.  
  359.     def start_record(self,error=False):
  360.         if self.record_status == "stopped":
  361.             if error == False:
  362.                 self.output_filename, ok = QtWidgets.QInputDialog.getText(self.main_self.mainWindow, 'Όνομα αρχείου ηχογράφησης', 'Παρακαλώ εισάγετε το όνομα του αρχείου της ηχογράφησης.\nΠαράδειγμα: Ομιλία vabab 2021-07-01\nΕπιτρεπόμενοι χαρακτήρες: γράμματα (κεφαλαία και μικρά, ελληνικά και αγγλικά), χαρακτήρας \'-\',χαρακτήρας \'_\', ')
  363.             else:
  364.                 self.output_filename, ok = QtWidgets.QInputDialog.getText(self.main_self.mainWindow, 'Όνομα αρχείου ηχογράφησης', 'Παρακαλώ εισάγετε το όνομα του αρχείου της ηχογράφησης (λανθασμένη εισαγωγή).\nΠαράδειγμα: Ομιλία vabab 2021-07-01\nΕπιτρεπόμενοι χαρακτήρες: γράμματα (κεφαλαία και μικρά, ελληνικά και αγγλικά), χαρακτήρας \'-\',χαρακτήρας \'_\', ')
  365.             if ok:
  366.                 self.output_path = "../../disket_box/records/"
  367.                 self.record_full_path = self.output_path+self.output_filename+".wav"
  368.                 self.record_full_path = os.path.abspath(self.record_full_path)
  369.                 try:
  370.                     self.papinhio_player.output_file = wave.open(self.record_full_path, 'wb')
  371.                 except:
  372.                     self.start_record(True)
  373.                 self.papinhio_player.output_file.setnchannels(self.papinhio_player.channels)
  374.                 self.papinhio_player.output_file.setsampwidth(self.papinhio_player.p.get_sample_size(self.papinhio_player.format))
  375.                 self.papinhio_player.output_file.setframerate(self.papinhio_player.new_sample_rate)
  376.                 self.record_status = "recording"
  377.                 self.papinhio_player.record_status = "recording"
  378.                 self.main_self.main_ui.menu_record_pause.setEnabled(True)
  379.                 self.main_self.main_ui.menu_record_stop.setEnabled(True)
  380.                 self.main_self.main_ui.menu_record_start.setEnabled(False)
  381.                 self.main_self.main_ui.menu_record_start.setText("Έναρξη ηχογράφησης")
  382.                 self.main_self.main_ui.record_label.setText("Ηχογραφείτε τώρα: ΝΑΙ")
  383.         else:
  384.             self.record_status = "recording"
  385.             self.papinhio_player.record_status = "recording"
  386.             self.main_self.main_ui.menu_record_pause.setEnabled(True)
  387.             self.main_self.main_ui.menu_record_stop.setEnabled(True)
  388.             self.main_self.main_ui.menu_record_start.setEnabled(False)
  389.             self.main_self.main_ui.menu_record_start.setText("Έναρξη ηχογράφησης")
  390.             self.main_self.main_ui.record_label.setText("Ηχογραφείτε τώρα: ΝΑΙ")
  391.            
  392.     def pause_record(self):
  393.         self.record_status = "paused"
  394.         self.papinhio_player.record_status = "paused"
  395.         self.main_self.main_ui.menu_record_pause.setEnabled(False)
  396.         self.main_self.main_ui.menu_record_stop.setEnabled(True)
  397.         self.main_self.main_ui.menu_record_start.setEnabled(True)
  398.         self.main_self.main_ui.menu_record_start.setText("Συνέχιση ηχογράφησης")
  399.         self.main_self.main_ui.record_label.setText("Ηχογραφείτε τώρα: ΟΧΙ (σε παύση)")
  400.    
  401.     def stop_record(self):
  402.         self.record_status = "stopped"
  403.         self.papinhio_player.record_status = "stopped"
  404.         self.papinhio_player.output_file.close()
  405.         self.papinhio_player.output_file = None
  406.         self.main_self.main_ui.menu_record_pause.setEnabled(False)
  407.         self.main_self.main_ui.menu_record_stop.setEnabled(False)
  408.         self.main_self.main_ui.menu_record_start.setEnabled(True)
  409.         self.main_self.main_ui.menu_record_start.setText("Έναρξη ηχογράφησης")
  410.         self.main_self.main_ui.record_label.setText("Ηχογραφείτε τώρα: ΟΧΙ")
  411.        
  412.     def set_greek_timer_function(self):
  413.         self.greek_time_timer = QtCore.QTimer(self.main_self.mainWindow)
  414.         self.greek_time_timer.timeout.connect(lambda:self.play_greek_time())
  415.         now = datetime.now()
  416.         minutes = now.minute
  417.         seconds = now.second
  418.         if (int(minutes)>=30):
  419.             seconds = 1000*(60*(59-minutes)+(60-seconds))
  420.         else:
  421.             seconds = 1000*(60*(29-minutes)+(60-seconds))
  422.         self.greek_time_timer.start(seconds)
  423.                
  424.     def play_greek_time(self):
  425.         self.greek_time_timer.start(1000*30*60)
  426.         now = datetime.now()
  427.         group_title = ""
  428.         for item in self.main_self.player_list_data:
  429.             if item["type"]=="greek time files":
  430.                 group_title = item["relative number"]
  431.                 break
  432.         if group_title!="":
  433.             greek_time_collection = data.search_greek_time_by_group_title(group_title)
  434.             case = greek_time_collection[0]["case"]
  435.             hours = int(now.hour)
  436.             minutes = int(now.minute)
  437.             if(hours<10):
  438.                 hours = "0"+str(hours)
  439.             if minutes<10:
  440.                 minutes = "0"+str(minutes)
  441.             hours = str(hours)
  442.             minutes = str(minutes)
  443.            
  444.            
  445.            
  446.             when_to_play = str(hours)+":"+str(minutes)
  447.            
  448.             for greek_time_entry in greek_time_collection:
  449.                 when_to_play_db = greek_time_entry["when to play"].split("|")
  450.                 for when_to_play_db_part in when_to_play_db:
  451.                     if(when_to_play==when_to_play_db_part):
  452.                         #1. pause all decks and play greek time from deck_1
  453.                        
  454.                         if self.deck_1["play-status"]=="playing":
  455.                             self.deck_1["previous-play-status"] = "playing"
  456.                             self.deck_1["play-status"] = "paused"
  457.                             self.papinhio_player.deck_1["play-status"] = "paused"
  458.                         else:
  459.                             self.deck_1["previous-play-status"] = self.deck_1["play-status"]
  460.                        
  461.                         if self.deck_2["play-status"]=="playing":
  462.                             self.deck_2["previous-play-status"] = "playing"
  463.                             self.deck_2["play-status"] = "paused"
  464.                             self.papinhio_player.deck_1["play-status"] = "paused"
  465.                         else:
  466.                             self.deck_2["previous-play-status"] = self.deck_2["play-status"]
  467.                        
  468.                        
  469.                         if self.music_clip_deck["play-status"]!="stopped":
  470.                             self.music_clip_deck["play-status"] = "stopped"
  471.                             self.music_clip_deck_status_changed("stopped")
  472.                             self.papinhio_player.music_clip_deck["play-status"] = "stopped"
  473.                            
  474.                         self.music_clip_deck["player-list-item"] = {"title":greek_time_entry["title"],"saved path":greek_time_entry["saved path"],"type":"greek time files","relative number":greek_time_entry["number"],"duration":0,"append":greek_time_entry["append"],"append sound file number":greek_time_entry["append sound file number"]}
  475.                         self.music_clip_deck["player-list-row"] = -1
  476.                        
  477.                         #greek_time_segment = AudioSegment.from_file(self.music_clip_deck["player-list-item"]["saved path"])
  478.                            
  479.                         self.music_clip_deck["total-duration-milliseconds"] = greek_time_entry["duration milliseconds"]
  480.                         self.music_clip_deck["player-list-item"]["duration milliseconds"] = self.music_clip_deck["total-duration-milliseconds"]
  481.                         self.music_clip_deck["total-duration-human"] = greek_time_entry["duration human"]
  482.                         self.music_clip_deck["player-list-item"]["duration human"] = self.music_clip_deck["total-duration-human"]
  483.                        
  484.                         self.music_clip_deck["player-list-item"]["repeats"] = 0
  485.                        
  486.                         #Update music clip deck
  487.                         self.main_self.main_ui.music_clip_deck_title.setText("Music clip deck: "+str(self.music_clip_deck["player-list-item"]["title"]))
  488.                        
  489.                         self.main_self.main_ui.music_clip_deck_time.setText("00:00:00/"+str(self.music_clip_deck["total-duration-human"]))
  490.                         self.main_self.main_ui.music_clip_deck_timeline.setMaximum(self.music_clip_deck["total-duration-milliseconds"])
  491.                         self.main_self.main_ui.music_clip_deck_timeline.setSingleStep(500)
  492.                         self.main_self.main_ui.music_clip_deck_timeline.setPageStep(1000)
  493.                         self.main_self.main_ui.music_clip_deck_timeline.setProperty("value", 0)
  494.                         self.main_self.main_ui.music_clip_deck_timeline.setEnabled(True)
  495.                        
  496.                            
  497.                         icon3 = QtGui.QIcon()
  498.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  499.                         self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  500.                        
  501.                         self.papinhio_player.prepare_music_clip_deck(self.music_clip_deck)
  502.                         self.music_clip_deck["play-status"] = "playing"
  503.                         self.papinhio_player.music_clip_deck["play-status"] = "playing"
  504.                         self.music_clip_deck_status_changed("playing")
  505.    
  506.     def general_deck_status_changed(self,new_status):
  507.         if new_status == "playing":
  508.             if self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  509.                 if self.deck_1["stopped-timestamp"]>self.deck_2["stopped-timestamp"] and self.deck_1["stopped-timestamp"]>self.music_clip_deck["stopped-timestamp"]:
  510.                    
  511.                     #play deck_1
  512.                     self.deck_1_status_changed("playing")
  513.                    
  514.                     icon3 = QtGui.QIcon()
  515.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  516.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  517.                    
  518.                     self.general_deck["play-status"] = "playing"
  519.                     self.papinhio_player.general_deck["play-status"] = "playing"
  520.                    
  521.                 elif self.deck_2["stopped-timestamp"]>self.deck_1["stopped-timestamp"] and self.deck_2["stopped-timestamp"]>self.music_clip_deck["stopped-timestamp"]:
  522.                     #play deck 2
  523.                     self.deck_2_status_changed("playing")
  524.                    
  525.                     icon3 = QtGui.QIcon()
  526.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  527.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  528.                    
  529.                     self.general_deck["play-status"] = "playing"
  530.                     self.papinhio_player.general_deck["play-status"] = "playing"
  531.                    
  532.                 elif self.music_clip_deck["stopped-timestamp"]>self.deck_1["stopped-timestamp"] and self.music_clip_deck["stopped-timestamp"]>self.deck_2["stopped-timestamp"]:
  533.                     #play music_clip_deck
  534.                     self.music_clip_deck_status_changed("playing")
  535.                    
  536.                     icon3 = QtGui.QIcon()
  537.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  538.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  539.                    
  540.                     self.general_deck["play-status"] = "playing"
  541.                     self.papinhio_player.general_deck["play-status"] = "playing"
  542.                 elif self.deck_1["stopped-timestamp"]!=0 and self.deck_1["stopped-timestamp"]==self.deck_2["stopped-timestamp"] and self.music_clip_deck["stopped-timestamp"]==self.deck_1["stopped-timestamp"]:
  543.                     if self.deck_1["player-list-item"] is not None:
  544.                         #play deck_1
  545.                         self.deck_1_status_changed("playing")
  546.                        
  547.                         icon3 = QtGui.QIcon()
  548.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  549.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  550.                        
  551.                         self.general_deck["play-status"] = "playing"
  552.                         self.papinhio_player.general_deck["play-status"] = "playing"
  553.                     elif self.deck_2["player-list-item"] is not None:
  554.                         #play deck 2
  555.                         self.deck_2_status_changed("playing")
  556.                        
  557.                         icon3 = QtGui.QIcon()
  558.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  559.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  560.                        
  561.                         self.general_deck["play-status"] = "playing"
  562.                         self.papinhio_player.general_deck["play-status"] = "playing"
  563.                     elif self.music_clip_deck["player-list-item"] is not None:
  564.                         #play music_clip_deck
  565.                         self.music_clip_deck_status_changed("playing")
  566.                        
  567.                         icon3 = QtGui.QIcon()
  568.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  569.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  570.                        
  571.                         self.general_deck["play-status"] = "playing"
  572.                         self.papinhio_player.general_deck["play-status"] = "playing"
  573.                     else:
  574.                         if len(self.main_self.player_list_data)>0:
  575.                             player_list_number = self.main_self.player_list_data[0]["player number"]
  576.                             self.prepare_and_play_deck_1(player_list_number)
  577.                            
  578.                             icon3 = QtGui.QIcon()
  579.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  580.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  581.                            
  582.                             self.general_deck["play-status"] = "playing"
  583.                             self.papinhio_player.general_deck["play-status"] = "playing"
  584.                         else:
  585.                             icon3 = QtGui.QIcon()
  586.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  587.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  588.                            
  589.                             self.general_deck["play-status"] = "stopped"
  590.                             self.papinhio_player.general_deck["play-status"] = "stopped"
  591.                 elif self.deck_1["stopped-timestamp"]==0 and self.deck_2["stopped-timestamp"]==0 and self.music_clip_deck["stopped-timestamp"]==0:
  592.                     #play in deck 1 the next song
  593.                     if len(self.main_self.player_list_data)>0:
  594.                         player_list_number = self.main_self.player_list_data[0]["player number"]
  595.                         self.prepare_and_play_deck_1(player_list_number)
  596.                        
  597.                         icon3 = QtGui.QIcon()
  598.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  599.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  600.                        
  601.                         self.general_deck["play-status"] = "playing"
  602.                         self.papinhio_player.general_deck["play-status"] = "playing"
  603.                     else:
  604.                         icon3 = QtGui.QIcon()
  605.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  606.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  607.                        
  608.                         self.general_deck["play-status"] = "stopped"
  609.                         self.papinhio_player.general_deck["play-status"] = "stopped"
  610.             else:#paused+stopped
  611.                 if self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="paused":
  612.                     if self.deck_1["paused-timestamp"]>self.deck_2["paused-timestamp"] and self.deck_1["paused-timestamp"]>self.music_clip_deck["paused-timestamp"]:
  613.                         #play deck_1
  614.                         self.deck_1_status_changed("playing")
  615.                        
  616.                         icon3 = QtGui.QIcon()
  617.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  618.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  619.                        
  620.                         self.general_deck["play-status"] = "playing"
  621.                         self.papinhio_player.general_deck["play-status"] = "playing"
  622.                        
  623.                     elif self.deck_2["paused-timestamp"]>self.deck_1["paused-timestamp"] and self.deck_2["paused-timestamp"]>self.music_clip_deck["paused-timestamp"]:
  624.                         #play deck 2
  625.                         self.deck_2_status_changed("playing")
  626.                        
  627.                         icon3 = QtGui.QIcon()
  628.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  629.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  630.                        
  631.                         self.general_deck["play-status"] = "playing"
  632.                         self.papinhio_player.general_deck["play-status"] = "playing"
  633.                        
  634.                     elif self.music_clip_deck["paused-timestamp"]>self.deck_1["paused-timestamp"] and self.music_clip_deck["paused-timestamp"]>self.deck_2["stopped-timestamp"]:
  635.                         #play music_clip_deck
  636.                         self.music_clip_deck_status_changed("playing")
  637.                        
  638.                         icon3 = QtGui.QIcon()
  639.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  640.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  641.                        
  642.                         self.general_deck["play-status"] = "playing"
  643.                         self.papinhio_player.general_deck["play-status"] = "playing"
  644.                 elif self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="stopped":
  645.                     if self.deck_1["paused-timestamp"]>self.deck_2["paused-timestamp"]:
  646.                         #play deck_1
  647.                         self.deck_1_status_changed("playing")
  648.                        
  649.                         icon3 = QtGui.QIcon()
  650.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  651.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  652.                        
  653.                         self.general_deck["play-status"] = "playing"
  654.                         self.papinhio_player.general_deck["play-status"] = "playing"
  655.                        
  656.                     elif self.deck_2["paused-timestamp"]>self.deck_1["paused-timestamp"]:
  657.                         #play deck 2
  658.                         self.deck_2_status_changed("playing")
  659.                        
  660.                         icon3 = QtGui.QIcon()
  661.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  662.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  663.                        
  664.                         self.general_deck["play-status"] = "playing"
  665.                         self.papinhio_player.general_deck["play-status"] = "playing"
  666.                 elif self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="paused":
  667.                     if self.deck_1["paused-timestamp"]>self.music_clip_deck["paused-timestamp"]:
  668.                         #play deck_1
  669.                         self.deck_1_status_changed("playing")
  670.                        
  671.                         icon3 = QtGui.QIcon()
  672.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  673.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  674.                        
  675.                         self.general_deck["play-status"] = "playing"
  676.                         self.papinhio_player.general_deck["play-status"] = "playing"
  677.                        
  678.                     elif self.music_clip_deck["paused-timestamp"]>self.deck_1["paused-timestamp"]:
  679.                         #play music clip deck
  680.                         self.music_clip_deck_status_changed("playing")
  681.                        
  682.                         icon3 = QtGui.QIcon()
  683.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  684.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  685.                        
  686.                         self.general_deck["play-status"] = "playing"
  687.                         self.papinhio_player.general_deck["play-status"] = "playing"
  688.                 elif self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="paused":
  689.                     if self.deck_2["paused-timestamp"]>self.music_clip_deck["paused-timestamp"]:
  690.                         #play deck_1
  691.                         self.deck_2_status_changed("playing")
  692.                        
  693.                         icon3 = QtGui.QIcon()
  694.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  695.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  696.                        
  697.                         self.general_deck["play-status"] = "playing"
  698.                         self.papinhio_player.general_deck["play-status"] = "playing"
  699.                        
  700.                     elif self.music_clip_deck["paused-timestamp"]>self.deck_2["paused-timestamp"]:
  701.                         #play music clip deck
  702.                         self.music_clip_deck_status_changed("playing")
  703.                        
  704.                         icon3 = QtGui.QIcon()
  705.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  706.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  707.                        
  708.                         self.general_deck["play-status"] = "playing"
  709.                         self.papinhio_player.general_deck["play-status"] = "playing"
  710.                 elif self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="paused":
  711.                         self.music_clip_deck_status_changed("playing")
  712.                        
  713.                         icon3 = QtGui.QIcon()
  714.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  715.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  716.                        
  717.                         self.general_deck["play-status"] = "playing"
  718.                         self.papinhio_player.general_deck["play-status"] = "playing"
  719.                 elif self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  720.                         self.deck_1_status_changed("playing")
  721.                        
  722.                         icon3 = QtGui.QIcon()
  723.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  724.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  725.                        
  726.                         self.general_deck["play-status"] = "playing"
  727.                         self.papinhio_player.general_deck["play-status"] = "playing"
  728.                 elif self.deck_2["play-status"]=="paused" and self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  729.                         self.deck_2_status_changed("playing")
  730.                        
  731.                         icon3 = QtGui.QIcon()
  732.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  733.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  734.                        
  735.                         self.general_deck["play-status"] = "playing"
  736.                         self.papinhio_player.general_deck["play-status"] = "playing"
  737.                 elif self.deck_2["play-status"]=="stopped" and self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  738.                     if self.deck_1["stopped-timestamp"]>self.deck_2["stopped-timestamp"] and self.deck_1["stopped-timestamp"]>self.music_clip_deck["stopped-timestamp"]:
  739.                         #play deck_1
  740.                         self.deck_1_status_changed("playing")
  741.                        
  742.                         icon3 = QtGui.QIcon()
  743.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  744.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  745.                        
  746.                         self.general_deck["play-status"] = "playing"
  747.                         self.papinhio_player.general_deck["play-status"] = "playing"
  748.                        
  749.                     elif self.deck_2["stopped-timestamp"]>self.deck_1["stopped-timestamp"] and self.deck_2["stopped-timestamp"]>self.music_clip_deck["stopped-timestamp"]:
  750.                         #play deck 2
  751.                         self.deck_2_status_changed("playing")
  752.                        
  753.                         icon3 = QtGui.QIcon()
  754.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  755.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  756.                        
  757.                         self.general_deck["play-status"] = "playing"
  758.                         self.papinhio_player.general_deck["play-status"] = "playing"
  759.                        
  760.                     elif self.music_clip_deck["stopped-timestamp"]>self.deck_1["stopped-timestamp"] and self.music_clip_deck["stopped-timestamp"]>self.deck_2["stopped-timestamp"]:
  761.                         #play music_clip_deck
  762.                         self.music_clip_deck_status_changed("playing")
  763.                        
  764.                         icon3 = QtGui.QIcon()
  765.                         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  766.                         self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  767.                        
  768.                         self.general_deck["play-status"] = "playing"
  769.                         self.papinhio_player.general_deck["play-status"] = "playing"
  770.                     elif self.deck_1["stopped-timestamp"]!=0 and self.deck_1["stopped-timestamp"]==self.deck_2["stopped-timestamp"] and self.music_clip_deck["stopped-timestamp"]==self.deck_1["stopped-timestamp"]:
  771.                         if self.deck_1["player-list-item"] is not None:
  772.                             #play deck_1
  773.                             self.deck_1_status_changed("playing")
  774.                            
  775.                             icon3 = QtGui.QIcon()
  776.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  777.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  778.                            
  779.                             self.general_deck["play-status"] = "playing"
  780.                             self.papinhio_player.general_deck["play-status"] = "playing"
  781.                         elif self.deck_2["player-list-item"] is not None:
  782.                             #play deck 2
  783.                             self.deck_2_status_changed("playing")
  784.                            
  785.                             icon3 = QtGui.QIcon()
  786.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  787.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  788.                            
  789.                             self.general_deck["play-status"] = "playing"
  790.                             self.papinhio_player.general_deck["play-status"] = "playing"
  791.                         elif self.music_clip_deck["player-list-item"] is not None:
  792.                             #play music_clip_deck
  793.                             self.music_clip_deck_status_changed("playing")
  794.                            
  795.                             icon3 = QtGui.QIcon()
  796.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  797.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  798.                            
  799.                             self.general_deck["play-status"] = "playing"
  800.                             self.papinhio_player.general_deck["play-status"] = "playing"
  801.                         else:
  802.                             if len(self.main_self.player_list_data)>0:
  803.                                 player_list_number = self.main_self.player_list_data[0]["player number"]
  804.                                 self.prepare_and_play_deck_1(player_list_number)
  805.                                
  806.                                 icon3 = QtGui.QIcon()
  807.                                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  808.                                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  809.                                
  810.                                 self.general_deck["play-status"] = "playing"
  811.                                 self.papinhio_player.general_deck["play-status"] = "playing"
  812.                             else:
  813.                                 icon3 = QtGui.QIcon()
  814.                                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  815.                                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  816.                                
  817.                                 self.general_deck["play-status"] = "stopped"
  818.                                 self.papinhio_player.general_deck["play-status"] = "stopped"
  819.                     elif self.deck_1["stopped-timestamp"]==0 and self.deck_2["stopped-timestamp"]==0 and self.music_clip_deck["stopped-timestamp"]==0:
  820.                         #play in deck 1 the next song
  821.                         if len(self.main_self.player_list_data)>0:
  822.                             player_list_number = self.main_self.player_list_data[0]["player number"]
  823.                             self.prepare_and_play_deck_1(player_list_number)
  824.                            
  825.                             icon3 = QtGui.QIcon()
  826.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  827.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  828.                            
  829.                             self.general_deck["play-status"] = "playing"
  830.                             self.papinhio_player.general_deck["play-status"] = "playing"
  831.                         else:
  832.                             icon3 = QtGui.QIcon()
  833.                             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  834.                             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  835.                            
  836.                             self.general_deck["play-status"] = "stopped"
  837.                             self.papinhio_player.general_deck["play-status"] = "stopped"
  838.                
  839.                    
  840.         elif new_status == "paused":
  841.             if self.deck_1["play-status"]!="stopped":
  842.                 self.deck_1_status_changed("paused")
  843.             if self.deck_2["play-status"]!="stopped":
  844.                 self.deck_2_status_changed("stopped")
  845.             if self.music_clip_deck["play-status"]!="playing":
  846.                 self.music_clip_deck_status_changed("paused")
  847.            
  848.             icon3 = QtGui.QIcon()
  849.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  850.             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  851.            
  852.             self.general_deck["play-status"] = "paused"
  853.             self.papinhio_player.general_deck["play-status"] = "paused"
  854.         elif new_status == "stopped":
  855.             self.deck_1_status_changed("stopped")
  856.             self.deck_2_status_changed("stopped")
  857.             self.music_clip_deck_status_changed("stopped")
  858.            
  859.             icon3 = QtGui.QIcon()
  860.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  861.             self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  862.            
  863.             self.general_deck["play-status"] = "stopped"
  864.             self.papinhio_player.general_deck["play-status"] = "stopped"
  865.        
  866.     def general_deck_volume_changed(self,normalized_value):
  867.         frame_width = self.main_self.main_ui.general_deck_pick.geometry().width()
  868.         stop_red = 255
  869.         stop_green = int(255*(1-normalized_value))
  870.         if(stop_green>255):
  871.             stop_green = 255
  872.         normalized_value = int(frame_width*normalized_value)
  873.         self.main_self.main_ui.general_deck_pick_strength.setGeometry(QtCore.QRect(0, 0, normalized_value, 16))
  874.         self.main_self.main_ui.general_deck_pick_strength.setStyleSheet("QFrame{background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(255, 255, 0), stop:1 rgb("+str(stop_red)+", "+str(stop_green)+", 0))}")
  875.         self.main_self.main_ui.general_deck_pick_strength.update()
  876.        
  877.     def deck_1_status_changed(self,new_status):
  878.         if new_status == "playing":
  879.             if self.deck_1["play-status"]!="paused":
  880.                 now = datetime.now()
  881.                 player_history_item = (now,now,self.deck_1["player-list-item"]["type"],self.deck_1["player-list-item"]["relative number"])
  882.                 self.deck_1["player-history-number"] = data.import_player_history(player_history_item)
  883.         elif new_status == "stopped":
  884.            
  885.             if self.deck_1["play-status"]!="stopped":
  886.                 if self.deck_1["player-history-number"] is not None:
  887.                     now = datetime.now()
  888.                     player_history_item = (now,self.deck_1["player-history-number"])
  889.                     data.edit_player_history(player_history_item)
  890.                     self.deck_1["player-history-number"] = None
  891.        
  892.         #self.deck_1["play-status"] = new_status
  893.         if(new_status=="playing"):
  894.             if self.deck_1["player-list-item"] is not None:
  895.                 icon3 = QtGui.QIcon()
  896.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  897.                 self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  898.            
  899.                 icon3 = QtGui.QIcon()
  900.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  901.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  902.                 self.general_deck["play-status"]="playing"
  903.                 self.papinhio_player.general_deck["play-status"]="playing"
  904.                 self.papinhio_player.deck_1["play-status"]="playing"
  905.                 self.deck_1["play-status"] = new_status
  906.             else:
  907.                 self.deck_1["play-status"] = "stopped"
  908.                 icon3 = QtGui.QIcon()
  909.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  910.                 self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  911.         elif new_status == "paused":
  912.             if self.deck_1["player-list-item"] is not None:
  913.                 icon3 = QtGui.QIcon()
  914.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  915.                 self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  916.                
  917.                 self.deck_1["play-status"] = "paused"
  918.                 self.deck_1["paused-timestamp"] = time.time()
  919.                
  920.                 if self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  921.                     icon3 = QtGui.QIcon()
  922.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  923.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  924.                     self.general_deck["play-status"]="paused"
  925.                     self.papinhio_player.general_deck["play-status"]="paused"
  926.                 elif self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="paused":
  927.                     icon3 = QtGui.QIcon()
  928.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  929.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  930.                     self.general_deck["play-status"]="paused"
  931.                     self.papinhio_player.general_deck["play-status"]="paused"
  932.                 elif (self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="stopped") or (self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="paused"):
  933.                     icon3 = QtGui.QIcon()
  934.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  935.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  936.                     self.general_deck["play-status"]="paused"
  937.                     self.papinhio_player.general_deck["play-status"]="paused"
  938.                 elif self.deck_2["play-status"]=="playing" or self.music_clip_deck["play-status"]=="playing":
  939.                     icon3 = QtGui.QIcon()
  940.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  941.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  942.                     self.general_deck["play-status"]="playing"
  943.                     self.papinhio_player.general_deck["play-status"]="playing" 
  944.             else:
  945.                 self.deck_1["play-status"] = "stopped"
  946.                 icon3 = QtGui.QIcon()
  947.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  948.                 self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  949.         elif new_status == "stopped":
  950.             icon3 = QtGui.QIcon()
  951.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  952.             self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  953.            
  954.             self.deck_1["play-status"] = "stopped"
  955.             self.deck_1["stopped-timestamp"] = time.time()
  956.            
  957.             if self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  958.                 icon3 = QtGui.QIcon()
  959.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  960.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  961.                 self.general_deck["play-status"]="stopped"
  962.                 self.papinhio_player.general_deck["play-status"]="stopped"
  963.             elif self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="paused":
  964.                 icon3 = QtGui.QIcon()
  965.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  966.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  967.                 self.general_deck["play-status"]="paused"
  968.                 self.papinhio_player.general_deck["play-status"]="paused"
  969.             elif (self.deck_2["play-status"]=="paused" and self.music_clip_deck["play-status"]=="stopped") or (self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="paused"):
  970.                 icon3 = QtGui.QIcon()
  971.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  972.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  973.                 self.general_deck["play-status"]="paused"
  974.                 self.papinhio_player.general_deck["play-status"]="paused"
  975.             elif self.deck_2["play-status"]=="playing" or self.music_clip_deck["play-status"]=="playing":
  976.                 icon3 = QtGui.QIcon()
  977.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  978.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  979.                 self.general_deck["play-status"]="playing"
  980.                 self.papinhio_player.general_deck["play-status"]="playing"
  981.            
  982.             if self.main_self.auto_dj==1:
  983.                 if self.deck_2["player-list-item"] is not None:
  984.                     #play deck 2
  985.                     self.deck_2["play-status"] = "playing"
  986.                     self.papinhio_player.deck_2["play-status"] = "playing"
  987.                     self.deck_2_status_changed("playing")
  988.                
  989.                 #prepare next song to deck 1
  990.                 counter = 0
  991.                 for item in self.main_self.player_list_data:
  992.                     if item["type"]!="greek time files":
  993.                         counter = 1
  994.                         player_list_number = item["player number"]
  995.                         self.prepare_deck_1(player_list_number)
  996.                         break
  997.                 if counter == 0:
  998.                     self.deck_1["player-list-item"] = None
  999.                     self.deck_1["player-list-row"] = None
  1000.                     self.deck_1["player-status"] = "stopped"
  1001.                     self.deck_1["chunk-number"] = 0
  1002.                     self.deck_1["total-duration-human"] = "00:00:00"
  1003.                     self.deck_1["total-duration-milliseconds"] = 0
  1004.                     self.deck_1["current-duration-milliseconds"] = 0
  1005.                
  1006.                 if self.active_transmition == True:
  1007.                     if self.deck_2["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped" and len(self.main_self.player_list_data)==0:
  1008.                         self.reload_player_list_data()
  1009.                
  1010.     def deck_1_duration_changed(self,duration_in_milliseconds):
  1011.         self.main_self.main_ui.deck_1_timeline.blockSignals(True)
  1012.         self.main_self.main_ui.deck_1_timeline.setValue(int(duration_in_milliseconds))
  1013.         self.main_self.main_ui.deck_1_timeline.blockSignals(False)
  1014.        
  1015.         current_duration_human = self.convert_duration_from_milliseconds_to_human(duration_in_milliseconds)
  1016.         self.main_self.main_ui.deck_1_time.setText(str(current_duration_human)+"/"+str(self.deck_1["total-duration-human"]))
  1017.         self.main_self.main_ui.deck_1_duration.setText("Διάρκεια: "+str(current_duration_human)+"/"+str(self.deck_1["total-duration-human"]))
  1018.        
  1019.     def deck_1_volume_strength_changed(self,normalized_value):
  1020.         frame_width = self.main_self.main_ui.deck_1_pick.geometry().width()
  1021.         stop_red = 255
  1022.         stop_green = int(255*(1-normalized_value))
  1023.         if(stop_green>255):
  1024.             stop_green = 255
  1025.         normalized_value = int(frame_width*normalized_value)
  1026.         self.main_self.main_ui.deck_1_pick_strength.setGeometry(QtCore.QRect(0, 0, normalized_value, 16))
  1027.         self.main_self.main_ui.deck_1_pick_strength.setStyleSheet("QFrame{background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(255, 255, 0), stop:1 rgb("+str(stop_red)+", "+str(stop_green)+", 0))}")
  1028.         self.main_self.main_ui.deck_1_pick_strength.update()
  1029.        
  1030.     def deck_2_status_changed(self,new_status):
  1031.         if new_status == "playing":
  1032.             if self.deck_2["play-status"]!="paused":
  1033.                 now = datetime.now()
  1034.                 player_history_item = (now,now,self.deck_2["player-list-item"]["type"],self.deck_2["player-list-item"]["relative number"])
  1035.                 self.deck_2["player-history-number"] = data.import_player_history(player_history_item)
  1036.         elif new_status == "stopped":
  1037.            
  1038.             if self.deck_2["play-status"]!="stopped":
  1039.                 if self.deck_2["player-history-number"] is not None:
  1040.                     now = datetime.now()
  1041.                     player_history_item = (now,self.deck_2["player-history-number"])
  1042.                     data.edit_player_history(player_history_item)
  1043.                     self.deck_2["player-history-number"] = None
  1044.        
  1045.         if(new_status=="playing"):
  1046.             if self.deck_2["player-list-item"] is not None:
  1047.                 icon3 = QtGui.QIcon()
  1048.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1049.                 self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1050.            
  1051.                 icon3 = QtGui.QIcon()
  1052.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1053.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1054.                 self.general_deck["play-status"]="playing"
  1055.                 self.papinhio_player.general_deck["play-status"]="playing"
  1056.                 self.papinhio_player.deck_2["play-status"]="playing"
  1057.                 self.deck_2["play-status"] = new_status
  1058.             else:
  1059.                 self.deck_2["play-status"] = "stopped"
  1060.                 icon3 = QtGui.QIcon()
  1061.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1062.                 self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1063.         elif new_status == "paused":
  1064.             if self.deck_2["player-list-item"] is not None:
  1065.                 icon3 = QtGui.QIcon()
  1066.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1067.                 self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1068.                
  1069.                 self.deck_2["play-status"] = "paused"
  1070.                 self.deck_2["paused-timestamp"] = time.time()
  1071.                
  1072.                 if self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  1073.                     icon3 = QtGui.QIcon()
  1074.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1075.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1076.                     self.general_deck["play-status"]="paused"
  1077.                     self.papinhio_player.general_deck["play-status"]="paused"
  1078.                 elif self.deck_1["play-status"]=="paused" and self.music_clip_deck["play-status"]=="paused":
  1079.                     icon3 = QtGui.QIcon()
  1080.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1081.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1082.                     self.general_deck["play-status"]="paused"
  1083.                     self.papinhio_player.general_deck["play-status"]="paused"
  1084.                 elif (self.deck_1["play-status"]=="paused" and self.music_clip_deck["play-status"]=="stopped") or (self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="paused"):
  1085.                     icon3 = QtGui.QIcon()
  1086.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1087.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1088.                     self.general_deck["play-status"]="paused"
  1089.                     self.papinhio_player.general_deck["play-status"]="paused"
  1090.                 elif self.deck_1["play-status"]=="playing" or self.music_clip_deck["play-status"]=="playing":
  1091.                     icon3 = QtGui.QIcon()
  1092.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1093.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1094.                     self.general_deck["play-status"]="playing"
  1095.                     self.papinhio_player.general_deck["play-status"]="playing" 
  1096.             else:
  1097.                 self.deck_2["play-status"] = "stopped"
  1098.                 icon3 = QtGui.QIcon()
  1099.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1100.                 self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1101.         elif new_status == "stopped":
  1102.             icon3 = QtGui.QIcon()
  1103.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1104.             self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1105.            
  1106.             self.deck_2["play-status"] = "stopped"
  1107.             self.deck_2["stopped-timestamp"] = time.time()
  1108.            
  1109.             if self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped":
  1110.                 icon3 = QtGui.QIcon()
  1111.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1112.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1113.                 self.general_deck["play-status"]="stopped"
  1114.                 self.papinhio_player.general_deck["play-status"]="stopped"
  1115.             elif self.deck_1["play-status"]=="paused" and self.music_clip_deck["play-status"]=="paused":
  1116.                 icon3 = QtGui.QIcon()
  1117.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1118.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1119.                 self.general_deck["play-status"]="paused"
  1120.                 self.papinhio_player.general_deck["play-status"]="paused"
  1121.             elif (self.deck_1["play-status"]=="paused" and self.music_clip_deck["play-status"]=="stopped") or (self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="paused"):
  1122.                 icon3 = QtGui.QIcon()
  1123.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1124.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1125.                 self.general_deck["play-status"]="paused"
  1126.                 self.papinhio_player.general_deck["play-status"]="paused"
  1127.             elif self.deck_1["play-status"]=="playing" or self.music_clip_deck["play-status"]=="playing":
  1128.                 icon3 = QtGui.QIcon()
  1129.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1130.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1131.                 self.general_deck["play-status"]="playing"
  1132.                 self.papinhio_player.general_deck["play-status"]="playing"
  1133.            
  1134.             if self.main_self.auto_dj==1:
  1135.                 #play deck 1
  1136.                 self.deck_1["play-status"] = "playing"
  1137.                 self.papinhio_player.deck_1["play-status"] = "playing"
  1138.                 self.deck_1_status_changed("playing")
  1139.                
  1140.                 #prepare next song to deck 2
  1141.                 counter = 0
  1142.                 for item in self.main_self.player_list_data:
  1143.                     if item["type"]!="greek time files":
  1144.                         counter = 1
  1145.                         player_list_number = item["player number"]
  1146.                         self.prepare_deck_2(player_list_number)
  1147.                         break
  1148.                 if counter == 0:
  1149.                     self.deck_2["player-list-item"] = None
  1150.                     self.deck_2["player-list-row"] = None
  1151.                     self.deck_2["player-status"] = "stopped"
  1152.                     self.deck_2["chunk-number"] = 0
  1153.                     self.deck_2["total-duration-human"] = "00:00:00"
  1154.                     self.deck_2["total-duration-milliseconds"] = 0
  1155.                     self.deck_2["current-duration-milliseconds"] = 0
  1156.  
  1157.                 if self.active_transmition == True:
  1158.                     if self.deck_1["play-status"]=="stopped" and self.music_clip_deck["play-status"]=="stopped" and len(self.main_self.player_list_data)==0:
  1159.                         self.reload_player_list_data()
  1160.        
  1161.     def deck_2_duration_changed(self,duration_in_milliseconds):
  1162.         self.main_self.main_ui.deck_2_timeline.blockSignals(True)
  1163.         self.main_self.main_ui.deck_2_timeline.setValue(int(duration_in_milliseconds))
  1164.         self.main_self.main_ui.deck_2_timeline.blockSignals(False)
  1165.        
  1166.         current_duration_human = self.convert_duration_from_milliseconds_to_human(duration_in_milliseconds)
  1167.         self.main_self.main_ui.deck_2_time.setText(str(current_duration_human)+"/"+str(self.deck_2["total-duration-human"]))
  1168.         self.main_self.main_ui.deck_2_duration.setText("Διάρκεια: "+str(current_duration_human)+"/"+str(self.deck_2["total-duration-human"]))
  1169.        
  1170.     def deck_2_volume_strength_changed(self,normalized_value):
  1171.         frame_width = self.main_self.main_ui.deck_2_pick.geometry().width()
  1172.         stop_red = 255
  1173.         stop_green = int(255*(1-normalized_value))
  1174.         if(stop_green>255):
  1175.             stop_green = 255
  1176.         normalized_value = int(frame_width*normalized_value)
  1177.         self.main_self.main_ui.deck_2_pick_strength.setGeometry(QtCore.QRect(0, 0, normalized_value, 16))
  1178.         self.main_self.main_ui.deck_2_pick_strength.setStyleSheet("QFrame{background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(255, 255, 0), stop:1 rgb("+str(stop_red)+", "+str(stop_green)+", 0))}")
  1179.         self.main_self.main_ui.deck_2_pick_strength.update()
  1180.        
  1181.     def music_clip_deck_status_changed(self,new_status):
  1182.         if new_status == "playing":
  1183.             if self.music_clip_deck["play-status"]!="paused":
  1184.                 now = datetime.now()
  1185.                 player_history_item = (now,now,self.music_clip_deck["player-list-item"]["type"],self.music_clip_deck["player-list-item"]["relative number"])
  1186.                 self.music_clip_deck["player-history-number"] = data.import_player_history(player_history_item)
  1187.         elif new_status == "stopped":
  1188.            
  1189.             if self.music_clip_deck["play-status"]!="stopped":
  1190.                 if self.music_clip_deck["player-history-number"] is not None:
  1191.                     now = datetime.now()
  1192.                     player_history_item = (now,self.music_clip_deck["player-history-number"])
  1193.                     data.edit_player_history(player_history_item)
  1194.                     self.music_clip_deck["player-history-number"] = None
  1195.        
  1196.         if(new_status=="playing"):
  1197.             if self.music_clip_deck["player-list-item"] is not None:
  1198.                 icon3 = QtGui.QIcon()
  1199.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1200.                 self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  1201.            
  1202.                 icon3 = QtGui.QIcon()
  1203.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1204.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1205.                 self.general_deck["play-status"]="playing"
  1206.                 self.papinhio_player.general_deck["play-status"]="playing"
  1207.                 self.papinhio_player.music_clip_deck["play-status"]="playing"
  1208.                 self.music_clip_deck["play-status"] = new_status
  1209.             else:
  1210.                 self.music_clip_deck["play-status"] = "stopped"
  1211.                 icon3 = QtGui.QIcon()
  1212.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1213.                 self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  1214.         elif new_status == "paused":
  1215.             if self.music_clip_deck["player-list-item"] is not None:
  1216.                 icon3 = QtGui.QIcon()
  1217.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1218.                 self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  1219.                
  1220.                 self.music_clip_deck["play-status"] = "paused"
  1221.                 self.music_clip_deck["paused-timestamp"] = time.time()
  1222.                
  1223.                 if self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="stopped":
  1224.                     icon3 = QtGui.QIcon()
  1225.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1226.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1227.                     self.general_deck["play-status"]="paused"
  1228.                     self.papinhio_player.general_deck["play-status"]="paused"
  1229.                 elif self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="paused":
  1230.                     icon3 = QtGui.QIcon()
  1231.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1232.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1233.                     self.general_deck["play-status"]="paused"
  1234.                     self.papinhio_player.general_deck["play-status"]="paused"
  1235.                 elif (self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="stopped") or (self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="paused"):
  1236.                     icon3 = QtGui.QIcon()
  1237.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1238.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1239.                     self.general_deck["play-status"]="paused"
  1240.                     self.papinhio_player.general_deck["play-status"]="paused"
  1241.                 elif self.deck_1["play-status"]=="playing" or self.deck_2["play-status"]=="playing":
  1242.                     icon3 = QtGui.QIcon()
  1243.                     icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1244.                     self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1245.                     self.general_deck["play-status"]="playing"
  1246.                     self.papinhio_player.general_deck["play-status"]="playing" 
  1247.             else:
  1248.                 self.music_clip_deck["play-status"] = "stopped"
  1249.                 icon3 = QtGui.QIcon()
  1250.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1251.                 self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  1252.         elif new_status == "stopped":
  1253.             if self.music_clip_deck["player-list-item"] is not None:
  1254.                 if self.music_clip_deck["player-list-item"]["type"]=="greek time files":
  1255.                     if self.deck_1["play-status"] != self.deck_1["previous-play-status"]:
  1256.                         self.deck_1_status_changed(self.deck_1["previous-play-status"])
  1257.                     if self.deck_2["play-status"] != self.deck_2["previous-play-status"]:
  1258.                         self.deck_2_status_changed(self.deck_2["previous-play-status"])
  1259.                    
  1260.             icon3 = QtGui.QIcon()
  1261.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1262.             self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  1263.            
  1264.             self.music_clip_deck["play-status"] = "stopped"
  1265.             self.music_clip_deck["stopped-timestamp"] = time.time()
  1266.            
  1267.             if self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="stopped":
  1268.                 icon3 = QtGui.QIcon()
  1269.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1270.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1271.                 self.general_deck["play-status"]="stopped"
  1272.                 self.papinhio_player.general_deck["play-status"]="stopped"
  1273.             elif self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="paused":
  1274.                 icon3 = QtGui.QIcon()
  1275.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1276.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1277.                 self.general_deck["play-status"]="paused"
  1278.                 self.papinhio_player.general_deck["play-status"]="paused"
  1279.             elif (self.deck_1["play-status"]=="paused" and self.deck_2["play-status"]=="stopped") or (self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="paused"):
  1280.                 icon3 = QtGui.QIcon()
  1281.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1282.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1283.                 self.general_deck["play-status"]="paused"
  1284.                 self.papinhio_player.general_deck["play-status"]="paused"
  1285.             elif self.deck_1["play-status"]=="playing" or self.deck_2["play-status"]=="playing":
  1286.                 icon3 = QtGui.QIcon()
  1287.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1288.                 self.main_self.main_ui.general_deck_play_or_pause.setIcon(icon3)
  1289.                 self.general_deck["play-status"]="playing"
  1290.                 self.papinhio_player.general_deck["play-status"]="playing"
  1291.                
  1292.             if self.active_transmition == True:
  1293.                     if self.deck_1["play-status"]=="stopped" and self.deck_2["play-status"]=="stopped" and len(self.main_self.player_list_data)==0:
  1294.                         self.reload_player_list_data()
  1295.    
  1296.     def music_clip_deck_duration_changed(self,duration_in_milliseconds):
  1297.         self.main_self.main_ui.music_clip_deck_timeline.blockSignals(True)
  1298.         self.main_self.main_ui.music_clip_deck_timeline.setValue(int(duration_in_milliseconds))
  1299.         self.main_self.main_ui.music_clip_deck_timeline.blockSignals(False)
  1300.        
  1301.         current_duration_human = self.convert_duration_from_milliseconds_to_human(duration_in_milliseconds)
  1302.         self.main_self.main_ui.music_clip_deck_time.setText(str(current_duration_human)+"/"+str(self.music_clip_deck["total-duration-human"]))
  1303.        
  1304.     def music_clip_deck_volume_strength_changed(self,normalized_value):
  1305.         frame_width = self.main_self.main_ui.music_clip_deck_pick.geometry().width()
  1306.         stop_red = 255
  1307.         stop_green = int(255*(1-normalized_value))
  1308.         if(stop_green>255):
  1309.             stop_green = 255
  1310.         normalized_value = int(frame_width*normalized_value)
  1311.         self.main_self.main_ui.music_clip_deck_pick_strength.setGeometry(QtCore.QRect(0, 0, normalized_value, 16))
  1312.         self.main_self.main_ui.music_clip_deck_pick_strength.setStyleSheet("QFrame{background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(255, 255, 0), stop:1 rgb("+str(stop_red)+", "+str(stop_green)+", 0))}")
  1313.         self.main_self.main_ui.music_clip_deck_pick_strength.update()
  1314.    
  1315.     def speackers_deck_duration_changed(self,duration_in_milliseconds):
  1316.         current_duration_human = self.convert_duration_from_milliseconds_to_human(duration_in_milliseconds)
  1317.         self.main_self.main_ui.speackers_deck_time.setText(str(current_duration_human))
  1318.        
  1319.     def speackers_deck_volume_strength_changed(self,normalized_value):
  1320.         frame_width = self.main_self.main_ui.speackers_deck_pick.geometry().width()
  1321.         stop_red = 255
  1322.         stop_green = int(255*(1-normalized_value))
  1323.         if(stop_green>255):
  1324.             stop_green = 255
  1325.         normalized_value = int(frame_width*normalized_value)
  1326.         self.main_self.main_ui.speackers_deck_pick_strength.setGeometry(QtCore.QRect(0, 0, normalized_value, 16))
  1327.         self.main_self.main_ui.speackers_deck_pick_strength.setStyleSheet("QFrame{background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgb(255, 255, 0), stop:1 rgb("+str(stop_red)+", "+str(stop_green)+", 0))}")
  1328.         self.main_self.main_ui.speackers_deck_pick_strength.update()
  1329.    
  1330.     def ip_call_1_deck_duration_changed(self,duration_in_milliseconds):
  1331.         pass
  1332.        
  1333.     def ip_call_1_deck_volume_strength_changed(self,normalized_value):
  1334.         pass
  1335.        
  1336.     def ip_call_2_deck_duration_changed(self,duration_in_milliseconds):
  1337.         pass
  1338.        
  1339.     def ip_call_2_deck_volume_strength_changed(self,normalized_value):
  1340.         pass
  1341.        
  1342.     def ip_call_3_deck_duration_changed(self,duration_in_milliseconds):
  1343.         pass
  1344.        
  1345.     def ip_call_3_deck_volume_strength_changed(self,normalized_value):
  1346.         pass
  1347.        
  1348.     def load_previous_song(self):
  1349.         if len(self.main_self.player_list_data)>0:
  1350.             self.general_deck_status_changed("stopped")
  1351.             player_list_number = self.main_self.player_list_data[-1]["player number"]
  1352.             self.prepare_and_play_deck_1(player_list_number)
  1353.    
  1354.     def general_deck_play_or_pause_clicked(self):
  1355.         if self.general_deck["play-status"]=="paused" or self.general_deck["play-status"]=="stopped":
  1356.             self.general_deck_status_changed("playing")
  1357.         else:
  1358.             self.general_deck_status_changed("paused")
  1359.                        
  1360.     def general_deck_stop_clicked(self):
  1361.         self.general_deck_status_changed("stopped")
  1362.        
  1363.     def load_next_song(self):
  1364.         if len(self.main_self.player_list_data)>0:
  1365.             self.general_deck_status_changed("stopped")
  1366.             player_list_number = self.main_self.player_list_data[0]["player number"]
  1367.             self.prepare_and_play_deck_1(player_list_number)
  1368.  
  1369.     def manage_auto_dj(self):
  1370.         if self.main_self.auto_dj == 1:
  1371.             self.main_self.auto_dj = 0
  1372.             self.main_self.main_ui.auto_dj.blockSignals(True)
  1373.             self.main_self.main_ui.auto_dj.setChecked(False)
  1374.             self.main_self.main_ui.auto_dj.blockSignals(False)
  1375.             self.main_self.main_ui.general_deck_auto_dj.setText("Ενεργοποίηση αυτόματου DJ")
  1376.             self.deactivate_auto_dj()
  1377.         else:
  1378.             self.main_self.auto_dj = 1
  1379.             self.main_self.main_ui.auto_dj.blockSignals(True)
  1380.             self.main_self.main_ui.auto_dj.setChecked(True)
  1381.             self.main_self.main_ui.auto_dj.blockSignals(False)
  1382.             self.main_self.main_ui.general_deck_auto_dj.setText("Απενεργοποίηση αυτόματου DJ")
  1383.             self.activate_auto_dj()
  1384.            
  1385.         #save setting
  1386.         data.update_setting({"keyword":"auto_dj","current value":str(self.main_self.auto_dj)})
  1387.    
  1388.     def activate_auto_dj(self,repeat=1):
  1389.         self.main_self.auto_dj = 1
  1390.         self.main_self.main_ui.auto_dj.blockSignals(True)
  1391.         self.main_self.main_ui.auto_dj.setChecked(True)
  1392.         self.main_self.main_ui.auto_dj.blockSignals(False)
  1393.        
  1394.         self.main_self.main_ui.general_deck_auto_dj.setText("Απενεργοποίηση αυτόματου DJ")
  1395.        
  1396.         #save setting
  1397.         data.update_setting({"keyword":"auto_dj","current value":"1"})
  1398.        
  1399.         #enable repeat playlist
  1400.         if repeat == 1:
  1401.             self.main_self.repeat_player_list_old = self.main_self.repeat_player_list
  1402.             self.main_self.repeat_player_list = 1
  1403.             data.update_setting({"keyword":"repeat player list","current value":"1"})
  1404.             self.main_self.main_ui.repeat_player_list_checkBox.setChecked(True)
  1405.             self.main_self.main_ui.general_deck_repeat_playlist_checkBox.setChecked(True)
  1406.         else:
  1407.             self.main_self.repeat_player_list_old = self.main_self.repeat_player_list
  1408.             self.main_self.repeat_player_list = 0
  1409.             data.update_setting({"keyword":"repeat player list","current value":"0"})
  1410.             self.main_self.main_ui.repeat_player_list_checkBox.setChecked(False)
  1411.             self.main_self.main_ui.general_deck_repeat_playlist_checkBox.setChecked(False)
  1412.        
  1413.         #disable buttons
  1414.         self.main_self.main_ui.general_deck_previous_song.setEnabled(False)
  1415.         self.main_self.main_ui.general_deck_play_or_pause.setEnabled(False)
  1416.         self.main_self.main_ui.general_deck_stop.setEnabled(False)
  1417.         self.main_self.main_ui.general_deck_next_song.setEnabled(False)
  1418.         self.main_self.main_ui.general_deck_repeat_playlist_checkBox.setEnabled(False)
  1419.        
  1420.         self.main_self.main_ui.deck_1_play_pause.setEnabled(False)
  1421.         self.main_self.main_ui.deck_1_stop.setEnabled(False)
  1422.         self.main_self.main_ui.deck_1_mute.setEnabled(False)
  1423.        
  1424.         self.main_self.main_ui.deck_2_play_pause.setEnabled(False)
  1425.         self.main_self.main_ui.deck_2_stop.setEnabled(False)
  1426.         self.main_self.main_ui.deck_2_mute.setEnabled(False)
  1427.        
  1428.         self.main_self.main_ui.music_clip_deck_play_pause.setEnabled(False)
  1429.         self.main_self.main_ui.music_clip_deck_stop.setEnabled(False)
  1430.         self.main_self.main_ui.music_clip_deck_mute.setEnabled(False)
  1431.        
  1432.         self.main_self.main_ui.repeat_player_list_checkBox.setEnabled(False)
  1433.        
  1434.         if self.deck_1["play-status"]!="playing" and self.deck_2["play-status"]!="playing" and self.music_clip_deck["play-status"]!="playing":
  1435.             #play first track in deck 1
  1436.             for item in self.main_self.player_list_data:
  1437.                 if item["type"]!="greek time files":
  1438.                     player_list_number = item["player number"]
  1439.                     self.prepare_and_play_deck_1(player_list_number)
  1440.                     break
  1441.            
  1442.             #prepare next song in deck 2
  1443.             for item in self.main_self.player_list_data:
  1444.                 if item["type"]!="greek time files":
  1445.                     player_list_number = item["player number"]
  1446.                     self.prepare_deck_2(player_list_number)
  1447.                     break
  1448.    
  1449.     def deactivate_auto_dj(self):
  1450.         self.main_self.auto_dj = 0
  1451.         self.main_self.main_ui.auto_dj.blockSignals(True)
  1452.         self.main_self.main_ui.auto_dj.setChecked(False)
  1453.         self.main_self.main_ui.auto_dj.blockSignals(False)
  1454.        
  1455.         self.main_self.main_ui.general_deck_auto_dj.setText("Ενεργοποίηση αυτόματου DJ")
  1456.        
  1457.         #save setting
  1458.         data.update_setting({"keyword":"auto_dj","current value":"0"})
  1459.        
  1460.         #enable repeat playlist
  1461.         self.main_self.repeat_player_list_old = self.main_self.repeat_player_list
  1462.         if self.main_self.repeat_player_list==1 or self.main_self.repeat_player_list==True or self.main_self.repeat_player_list:
  1463.             self.main_self.repeat_player_list = 1
  1464.             self.main_self.main_ui.repeat_player_list_checkBox.setChecked(True)
  1465.             self.main_self.main_ui.general_deck_repeat_playlist_checkBox.setChecked(True)
  1466.         else:
  1467.             self.main_self.repeat_player_list = 0
  1468.             self.main_self.main_ui.repeat_player_list_checkBox.setChecked(False)
  1469.             self.main_self.main_ui.general_deck_repeat_playlist_checkBox.setChecked(False)
  1470.         data.update_setting({"keyword":"repeat player list","current value":str(self.main_self.repeat_player_list)})
  1471.        
  1472.        
  1473.         #enable buttons
  1474.         self.main_self.main_ui.general_deck_previous_song.setEnabled(True)
  1475.         self.main_self.main_ui.general_deck_play_or_pause.setEnabled(True)
  1476.         self.main_self.main_ui.general_deck_stop.setEnabled(True)
  1477.         self.main_self.main_ui.general_deck_next_song.setEnabled(True)
  1478.         self.main_self.main_ui.general_deck_repeat_playlist_checkBox.setEnabled(True)
  1479.        
  1480.         self.main_self.main_ui.deck_1_play_pause.setEnabled(True)
  1481.         self.main_self.main_ui.deck_1_stop.setEnabled(True)
  1482.         self.main_self.main_ui.deck_1_mute.setEnabled(True)
  1483.        
  1484.         self.main_self.main_ui.deck_2_play_pause.setEnabled(True)
  1485.         self.main_self.main_ui.deck_2_stop.setEnabled(True)
  1486.         self.main_self.main_ui.deck_2_mute.setEnabled(True)
  1487.        
  1488.         self.main_self.main_ui.music_clip_deck_play_pause.setEnabled(True)
  1489.         self.main_self.main_ui.music_clip_deck_stop.setEnabled(True)
  1490.         self.main_self.main_ui.music_clip_deck_mute.setEnabled(True)
  1491.        
  1492.         self.main_self.main_ui.repeat_player_list_checkBox.setEnabled(True)
  1493.        
  1494.         self.general_deck_status_changed("stopped")
  1495.         self.deck_1_status_changed("stopped")
  1496.    
  1497.     def repeat_player_list_checkbox_changed(self):
  1498.         repeat = self.main_self.main_ui.general_deck_repeat_playlist_checkBox.isChecked()
  1499.         if(repeat):
  1500.             self.main_self.repeat_player_list = 1
  1501.             self.main_self.main_ui.repeat_player_list_checkBox.setChecked(True)
  1502.         else:
  1503.             self.main_self.repeat_player_list = 0
  1504.             self.main_self.main_ui.repeat_player_list_checkBox.setChecked(False)
  1505.        
  1506.         #save setting
  1507.         data.update_setting({"keyword":"repeat player list","current value":str(self.main_self.repeat_player_list)})
  1508.        
  1509.     def general_deck_signal_volume_changed(self):
  1510.         self.general_deck["volume"] = int(self.main_self.main_ui.general_deck_volume_control.value())  
  1511.         self.main_self.main_ui.general_deck_volume_label.setText(str(self.general_deck["volume"])+"/100")  
  1512.         self.papinhio_player.general_deck["volume"] = self.general_deck["volume"]
  1513.    
  1514.     def general_deck_reset_volume_signal(self):
  1515.         self.general_deck["volume"] = 100
  1516.         self.main_self.main_ui.general_deck_volume_label.setText("100/100")
  1517.         self.papinhio_player.general_deck["volume"] = 100
  1518.         self.main_self.main_ui.general_deck_volume_control.setValue(100)
  1519.        
  1520.     def general_deck_system_volume_changed(self):
  1521.         self.general_deck["system-volume"] = self.main_self.main_ui.general_deck_system_control.value()
  1522.         self.general_deck["system-volume"] = int(self.general_deck["system-volume"])
  1523.        
  1524.         if self.general_deck["system-volume"] % 2 == 1:
  1525.             self.general_deck["system-volume"] += 1
  1526.             self.main_self.main_ui.general_deck_system_control.setValue(self.general_deck["system-volume"])
  1527.            
  1528.         #save setting
  1529.         data.update_setting({"keyword":"system sound volume","current value":self.general_deck["system-volume"]})
  1530.        
  1531.         for i in range(50):
  1532.             self.keyboard.press(Key.media_volume_down)
  1533.             self.keyboard.release(Key.media_volume_down)
  1534.            
  1535.         for i in range(0,int(self.general_deck["system-volume"]/2)):
  1536.             self.keyboard.press(Key.media_volume_up)
  1537.             self.keyboard.release(Key.media_volume_up)
  1538.            
  1539.         self.main_self.main_ui.general_deck_volume_label_2.setText(str(self.general_deck["system-volume"])+"/100")
  1540.         self.papinhio_player.general_deck["system-volume"]=self.general_deck["system-volume"]
  1541.    
  1542.     def general_deck_reset_system_volume(self):
  1543.         self.general_deck["system-volume"] = 50
  1544.        
  1545.         self.main_self.main_ui.general_deck_system_control.setValue(50)
  1546.            
  1547.         #save setting
  1548.         data.update_setting({"keyword":"system sound volume","current value":self.general_deck["system-volume"]})
  1549.            
  1550.         for i in range(50):
  1551.             self.keyboard.press(Key.media_volume_down)
  1552.             self.keyboard.release(Key.media_volume_down)
  1553.            
  1554.         for i in range(0,int(self.general_deck["system-volume"]/2)):
  1555.             self.keyboard.press(Key.media_volume_up)
  1556.             self.keyboard.release(Key.media_volume_up)
  1557.            
  1558.         self.main_self.main_ui.general_deck_volume_label_2.setText("50/100")
  1559.         self.papinhio_player.general_deck["system-volume"]=50
  1560.    
  1561.     def general_deck_normalize_changed(self):
  1562.         self.general_deck["normalize"] = self.main_self.main_ui.general_deck_normalize_checkbox.isChecked()
  1563.         self.papinhio_player.general_deck["normalize"] = self.general_deck["normalize"]
  1564.            
  1565.     def general_deck_pan_changed(self):
  1566.         self.general_deck["pan"] = float(self.main_self.main_ui.general_deck_pan_control.value()/100)
  1567.         self.main_self.main_ui.general_deck_pan_label.setText(str(self.general_deck["pan"]))
  1568.         self.papinhio_player.general_deck["pan"] = self.general_deck["pan"]
  1569.    
  1570.     def general_deck_reset_pan(self):
  1571.         self.general_deck["pan"] = 0
  1572.         self.main_self.main_ui.general_deck_pan_control.setValue(0)
  1573.         self.main_self.main_ui.general_deck_pan_label.setText("0")
  1574.         self.papinhio_player.general_deck["pan"] = 0
  1575.        
  1576.     def general_deck_apply_filter(self):
  1577.         self.general_deck["low-frequency"] = self.main_self.main_ui.general_deck_low_frequency_input.text()
  1578.         self.general_deck["high-frequency"] = self.main_self.main_ui.general_deck_high_frequency_input.text()
  1579.         if self.RepresentsInt(self.general_deck["low-frequency"]) and self.RepresentsInt(self.general_deck["high-frequency"]):
  1580.             self.general_deck["low-frequency"] = int(self.general_deck["low-frequency"])
  1581.             self.general_deck["high-frequency"] = int(self.general_deck["high-frequency"])
  1582.             if self.general_deck["high-frequency"]>self.general_deck["low-frequency"] and self.general_deck["high-frequency"]<=20000 and self.general_deck["low-frequency"]>=20:
  1583.                 self.papinhio_player.general_deck["low-frequency"] = self.general_deck["low-frequency"]
  1584.                 self.papinhio_player.general_deck["high-frequency"] = self.general_deck["high-frequency"]
  1585.             else:
  1586.                 self.general_deck_reset_filter()
  1587.         else:
  1588.             self.general_deck_reset_filter()
  1589.    
  1590.     def general_deck_reset_filter(self):
  1591.         self.general_deck["low-frequency"] = 20
  1592.         self.general_deck["high-frequency"] = 20000
  1593.         self.main_self.main_ui.general_deck_low_frequency_input.setText("20")
  1594.         self.main_self.main_ui.general_deck_high_frequency_input.setText("20000")
  1595.         self.papinhio_player.general_deck["low-frequency"] = self.general_deck["low-frequency"]
  1596.         self.papinhio_player.general_deck["high-frequency"] = self.general_deck["high-frequency"]
  1597.        
  1598.     def open_records_folder(self):
  1599.         FILEBROWSER_PATH = os.path.join(os.getenv('WINDIR'), 'explorer.exe')
  1600.         path = os.path.abspath("../../disket_box/records/")
  1601.         os.startfile(path)
  1602.         return 1
  1603.    
  1604.     def create_player_history_report(self):
  1605.         self.main_self.player_history_report_instance.create_word()
  1606.    
  1607.     def deck_1_timeline_changed(self):
  1608.         if(self.deck_1["play-status"]=="playing" or self.deck_1["play-status"]=="paused"):
  1609.             new_current_duration = int(self.main_self.main_ui.deck_1_timeline.value())
  1610.             #calculate new chunk_number
  1611.             chunk_number = round(new_current_duration/self.papinhio_player.packet_time)
  1612.             self.papinhio_player.deck_1["chunk-number"] = chunk_number
  1613.             current_duration_milliseconds = chunk_number*self.papinhio_player.packet_time
  1614.             self.papinhio_player.deck_1["current-duration-milliseconds"] = current_duration_milliseconds
  1615.         else:
  1616.             self.main_self.main_ui.deck_1_timeline.setProperty("value", 0)
  1617.        
  1618.     def deck_1_play_or_pause_clicked(self):
  1619.         if self.deck_1["play-status"]=="playing":
  1620.             #pause deck 1
  1621.             self.deck_1_status_changed("paused")
  1622.             self.deck_1["play-status"] = "paused"
  1623.             self.papinhio_player.deck_1["play-status"] = "paused"
  1624.            
  1625.             icon3 = QtGui.QIcon()
  1626.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1627.             self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  1628.            
  1629.         elif self.deck_1["play-status"]=="paused" or self.deck_1["play-status"]=="stopped":
  1630.             icon3 = QtGui.QIcon()
  1631.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1632.             self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  1633.             self.deck_1_status_changed("playing")
  1634.    
  1635.     def deck_1_stop_clicked(self):
  1636.         self.deck_1_status_changed("stopped")
  1637.         self.deck_1["play-status"] = "stopped"
  1638.         self.papinhio_player.deck_1["play-status"] = "stopped"
  1639.         self.deck_1_duration_changed(0)
  1640.         icon3 = QtGui.QIcon()
  1641.         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1642.         self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  1643.         self.deck_1_status_changed("stopped")
  1644.    
  1645.     def deck_1_mute_clicked(self):
  1646.         if self.deck_1["player-list-row"] is not None:
  1647.             if self.deck_1["mute"]==False:
  1648.                 self.deck_1["mute"] = True
  1649.                 icon3 = QtGui.QIcon()
  1650.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/mute.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1651.                 self.main_self.main_ui.deck_1_mute.setIcon(icon3)
  1652.                
  1653.                 self.deck_1["previous-volume"] = self.deck_1["volume"]
  1654.                 self.deck_1["volume"] = 0
  1655.                 self.main_self.main_ui.deck_1_volume_label.setText(str(self.deck_1["volume"])+"/100")
  1656.                 if self.deck_1["player-list-item"] is not None:
  1657.                     self.deck_1["player-list-item"]["volume"] = self.deck_1["volume"]
  1658.  
  1659.                     counter = 0
  1660.                     row_found = False
  1661.                     for player_list_row in self.main_self.player_list_data:
  1662.                         if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1663.                             row = counter
  1664.                             row_found = True
  1665.                             break
  1666.                         counter +=1
  1667.                     if row_found == True:
  1668.                         self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1669.                         self.main_self.player_list_volume_changed(self.deck_1["player-list-item"]["player number"],False)
  1670.                
  1671.                 self.papinhio_player.deck_1["volume"] = self.deck_1["volume"]
  1672.             else:
  1673.                 self.deck_1["mute"] = False
  1674.                 icon3 = QtGui.QIcon()
  1675.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/volume.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1676.                 self.main_self.main_ui.deck_1_mute.setIcon(icon3)
  1677.                
  1678.                 self.deck_1["volume"] = self.deck_1["previous-volume"]
  1679.                 self.main_self.main_ui.deck_1_volume_label.setText(str(self.deck_1["volume"])+"/100")
  1680.                 if self.deck_1["player-list-item"] is not None:
  1681.                     self.deck_1["player-list-item"]["volume"] = self.deck_1["volume"]
  1682.                
  1683.                     counter = 0
  1684.                     row_found = False
  1685.                     for player_list_row in self.main_self.player_list_data:
  1686.                         if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1687.                             row = counter
  1688.                             row_found = True
  1689.                             break
  1690.                         counter +=1
  1691.                     if row_found == True:
  1692.                         self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1693.                         self.main_self.player_list_volume_changed(self.deck_1["player-list-item"]["player number"],False)
  1694.                
  1695.                 self.papinhio_player.deck_1["volume"] = self.deck_1["volume"]
  1696.    
  1697.     def deck_1_volume_changed(self):
  1698.         self.deck_1["volume"] = int(self.main_self.main_ui.deck_1_volume_control.value())  
  1699.         self.main_self.main_ui.deck_1_volume_label.setText(str(self.deck_1["volume"])+"/100")
  1700.         if self.deck_1["player-list-item"] is not None:
  1701.             self.deck_1["player-list-item"]["volume"] = self.deck_1["volume"]
  1702.             counter = 0
  1703.             row_found = False
  1704.             for player_list_row in self.main_self.player_list_data:
  1705.                 if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1706.                     row = counter
  1707.                     row_found = True
  1708.                     break
  1709.                 counter +=1
  1710.             if row_found == True:
  1711.                 self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1712.                 self.main_self.player_list_volume_changed(self.deck_1["player-list-item"]["player number"],False)
  1713.            
  1714.         self.papinhio_player.deck_1["volume"] = self.deck_1["volume"]
  1715.    
  1716.     def deck_1_normalize_changed(self):
  1717.         self.deck_1["normalize"] = self.main_self.main_ui.deck_1_normalize.isChecked()
  1718.         if self.deck_1["player-list-item"] is not None:
  1719.             if self.deck_1["normalize"]:
  1720.                 self.deck_1["player-list-item"]["normalize"] = 1
  1721.             else:
  1722.                 self.deck_1["player-list-item"]["normalize"] = 0
  1723.             counter = 0
  1724.             row_found = False
  1725.             for player_list_row in self.main_self.player_list_data:
  1726.                 if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1727.                     row = counter
  1728.                     row_found = True
  1729.                     break
  1730.                 counter +=1
  1731.             if row_found == True:
  1732.                 self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1733.                 self.main_self.change_player_list_normalize(self.deck_1["player-list-item"]["player number"],False)
  1734.            
  1735.         self.papinhio_player.deck_1["normalize"] = self.deck_1["normalize"]
  1736.        
  1737.     def deck_1_pan_changed(self):
  1738.         self.deck_1["pan"] = int(self.main_self.main_ui.deck_1_pan_control.value())/100
  1739.         self.main_self.main_ui.deck_1_pan_label.setText(str(self.deck_1["pan"]))   
  1740.         if self.deck_1["player-list-item"] is not None:
  1741.             self.deck_1["player-list-item"]["pan"] = self.deck_1["pan"]
  1742.             counter = 0
  1743.             row_found = False
  1744.             for player_list_row in self.main_self.player_list_data:
  1745.                 if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1746.                     row = counter
  1747.                     row_found = True
  1748.                     break
  1749.                 counter +=1
  1750.             if row_found == True:
  1751.                 self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1752.                 self.main_self.player_list_pan_changed(self.deck_1["player-list-item"]["player number"],False)
  1753.            
  1754.         self.papinhio_player.deck_1["pan"] = self.deck_1["pan"]
  1755.    
  1756.     def deck_1_apply_filter(self):
  1757.         self.deck_1["low-frequency"] = self.main_self.main_ui.deck_1_low_frequency_input.text()
  1758.         self.deck_1["high-frequency"] = self.main_self.main_ui.deck_1_high_frequency_input.text()
  1759.         if self.RepresentsInt(self.deck_1["low-frequency"]) and self.RepresentsInt(self.deck_1["high-frequency"]):
  1760.             self.deck_1["low-frequency"] = int(self.deck_1["low-frequency"])
  1761.             self.deck_1["high-frequency"] = int(self.deck_1["high-frequency"])
  1762.             if self.deck_1["high-frequency"]>self.deck_1["low-frequency"] and self.deck_1["high-frequency"]<=20000 and self.deck_1["low-frequency"]>=20:
  1763.                 self.papinhio_player.deck_1["low-frequency"] = self.deck_1["low-frequency"]
  1764.                 self.papinhio_player.deck_1["high-frequency"] = self.deck_1["high-frequency"]
  1765.                 if self.deck_1["player-list-item"] is not None:
  1766.                     self.deck_1["player-list-item"]["low frequency"] = self.deck_1["low-frequency"]
  1767.                     self.deck_1["player-list-item"]["high frequency"] = self.deck_1["high-frequency"]
  1768.                    
  1769.                     counter = 0
  1770.                     row_found = False
  1771.                     for player_list_row in self.main_self.player_list_data:
  1772.                         if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1773.                             row = counter
  1774.                             row_found = True
  1775.                             break
  1776.                         counter +=1
  1777.                     if row_found == True:
  1778.                         self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1779.                         self.main_self.player_list_apply_filter(self.deck_1["player-list-item"]["player number"],False)
  1780.             else:
  1781.                 self.deck_1_reset_filter()
  1782.         else:
  1783.             self.deck_1_reset_filter()
  1784.    
  1785.     def deck_1_reset_filter(self):
  1786.         self.deck_1["low-frequency"] = 20
  1787.         self.deck_1["high-frequency"] = 20000
  1788.         self.main_self.main_ui.deck_1_low_frequency_input.setText(str(self.deck_1["low-frequency"]))
  1789.         self.main_self.main_ui.deck_1_high_frequency_input.setText(str(self.deck_1["high-frequency"]))
  1790.         if self.deck_1["player-list-item"] is not None:
  1791.             self.deck_1["player-list-item"]["low frequency"] = self.deck_1["low-frequency"]
  1792.             self.deck_1["player-list-item"]["high frequency"] = self.deck_1["high-frequency"]
  1793.             counter = 0
  1794.             row_found = False
  1795.             for player_list_row in self.main_self.player_list_data:
  1796.                 if player_list_row["player number"]==self.deck_1["player-list-item"]["player number"]:
  1797.                     row = counter
  1798.                     row_found = True
  1799.                     break
  1800.                 counter +=1
  1801.             if row_found == True:
  1802.                 self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  1803.                 self.main_self.player_list_apply_filter(self.deck_1["player-list-item"]["player number"],False)
  1804.            
  1805.         self.papinhio_player.deck_1["low-frequency"] = self.deck_1["low-frequency"]
  1806.         self.papinhio_player.deck_1["high-frequency"] = self.deck_1["high-frequency"]
  1807.        
  1808.     def deck_2_timeline_changed(self):
  1809.         if(self.deck_2["play-status"]=="playing" or self.deck_2["play-status"]=="paused"):
  1810.             new_current_duration = int(self.main_self.main_ui.deck_2_timeline.value())
  1811.             #calculate new chunk_number
  1812.             chunk_number = round(new_current_duration/self.papinhio_player.packet_time)
  1813.             self.papinhio_player.deck_2["chunk-number"] = chunk_number
  1814.             current_duration_milliseconds = chunk_number*self.papinhio_player.packet_time
  1815.             self.papinhio_player.deck_2["current-duration-milliseconds"] = current_duration_milliseconds
  1816.         else:
  1817.             self.main_self.main_ui.deck_2_timeline.setProperty("value", 0)
  1818.        
  1819.     def deck_2_play_or_pause_clicked(self):
  1820.         if self.deck_2["play-status"]=="playing":
  1821.             #pause deck 1
  1822.             self.deck_2_status_changed("paused")
  1823.             self.deck_2["play-status"] = "paused"
  1824.             self.papinhio_player.deck_2["play-status"] = "paused"
  1825.            
  1826.             icon3 = QtGui.QIcon()
  1827.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1828.             self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1829.            
  1830.         elif self.deck_2["play-status"]=="paused" or self.deck_2["play-status"]=="stopped":
  1831.             self.deck_2_status_changed("playing")
  1832.             icon3 = QtGui.QIcon()
  1833.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1834.             self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1835.    
  1836.     def deck_2_stop_clicked(self):
  1837.         self.deck_2_status_changed("stopped")
  1838.         self.deck_2["play-status"] = "stopped"
  1839.         self.papinhio_player.deck_2["play-status"] = "stopped"
  1840.         self.deck_2_duration_changed(0)
  1841.         icon3 = QtGui.QIcon()
  1842.         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1843.         self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  1844.         self.deck_2_status_changed("stopped")
  1845.    
  1846.     def deck_2_mute_clicked(self):
  1847.         if self.deck_2["player-list-row"] is not None:
  1848.             if self.deck_2["mute"]==False:
  1849.                 self.deck_2["mute"] = True
  1850.                 icon3 = QtGui.QIcon()
  1851.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/mute.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1852.                 self.main_self.main_ui.deck_2_mute.setIcon(icon3)
  1853.                
  1854.                 self.deck_2["previous-volume"] = self.deck_2["volume"]
  1855.                 self.deck_2["volume"] = 0
  1856.                 self.main_self.main_ui.deck_2_volume_label.setText(str(self.deck_2["volume"])+"/100")
  1857.                 if self.deck_2["player-list-item"] is not None:
  1858.                     self.deck_2["player-list-item"]["volume"] = self.deck_2["volume"]
  1859.                     counter = 0
  1860.                     row_found = False
  1861.                     for player_list_row in self.main_self.player_list_data:
  1862.                         if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1863.                             row = counter
  1864.                             row_found = True
  1865.                             break
  1866.                         counter +=1
  1867.                     if row_found == True:
  1868.                         self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  1869.                         self.main_self.player_list_volume_changed(self.deck_2["player-list-item"]["player number"],False)
  1870.                    
  1871.                 self.papinhio_player.deck_2["volume"] = self.deck_2["volume"]
  1872.             else:
  1873.                 self.deck_2["mute"] = False
  1874.                 icon3 = QtGui.QIcon()
  1875.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/volume.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  1876.                 self.main_self.main_ui.deck_2_mute.setIcon(icon3)
  1877.                
  1878.                 self.deck_2["volume"] = self.deck_2["previous-volume"]
  1879.                 self.main_self.main_ui.deck_2_volume_label.setText(str(self.deck_2["volume"])+"/100")
  1880.                 if self.deck_2["player-list-item"] is not None:
  1881.                     self.deck_2["player-list-item"]["volume"] = self.deck_2["volume"]
  1882.                     counter = 0
  1883.                     row_found = False
  1884.                     for player_list_row in self.main_self.player_list_data:
  1885.                         if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1886.                             row = counter
  1887.                             row_found = True
  1888.                             break
  1889.                         counter +=1
  1890.                     if row_found == True:
  1891.                         self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  1892.                         self.main_self.player_list_volume_changed(self.deck_2["player-list-item"]["player number"],False)
  1893.                    
  1894.                 self.papinhio_player.deck_2["volume"] = self.deck_2["volume"]
  1895.    
  1896.     def deck_2_volume_changed(self):
  1897.         self.deck_2["volume"] = int(self.main_self.main_ui.deck_2_volume_control.value())  
  1898.         self.main_self.main_ui.deck_2_volume_label.setText(str(self.deck_2["volume"])+"/100")
  1899.         if self.deck_2["player-list-item"] is not None:
  1900.             self.deck_2["player-list-item"]["volume"] = self.deck_2["volume"]
  1901.             counter = 0
  1902.             row_found = False
  1903.             for player_list_row in self.main_self.player_list_data:
  1904.                 if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1905.                     row = counter
  1906.                     row_found = True
  1907.                     break
  1908.                 counter +=1
  1909.             if row_found == True:
  1910.                 self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  1911.                 self.main_self.player_list_volume_changed(self.deck_2["player-list-item"]["player number"],False)
  1912.            
  1913.         self.papinhio_player.deck_2["volume"] = self.deck_2["volume"]
  1914.    
  1915.     def deck_2_normalize_changed(self):
  1916.         self.deck_2["normalize"] = self.main_self.main_ui.deck_2_normalize.isChecked()
  1917.         if self.deck_2["player-list-item"] is not None:
  1918.             if self.deck_2["normalize"]:
  1919.                 self.deck_2["player-list-item"]["normalize"] = 1
  1920.             else:
  1921.                 self.deck_2["player-list-item"]["normalize"] = 0
  1922.             counter = 0
  1923.             row_found = False
  1924.             for player_list_row in self.main_self.player_list_data:
  1925.                 if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1926.                     row = counter
  1927.                     row_found = True
  1928.                     break
  1929.                 counter +=1
  1930.             if row_found == True:
  1931.                 self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  1932.                 self.main_self.change_player_list_normalize(self.deck_2["player-list-item"]["player number"],False)
  1933.            
  1934.         self.papinhio_player.deck_2["normalize"] = self.deck_2["normalize"]
  1935.        
  1936.     def deck_2_pan_changed(self):
  1937.         self.deck_2["pan"] = int(self.main_self.main_ui.deck_2_pan_control.value())/100
  1938.         self.main_self.main_ui.deck_2_pan_label.setText(str(self.deck_2["pan"]))   
  1939.         if self.deck_2["player-list-item"] is not None:
  1940.             self.deck_2["player-list-item"]["pan"] = self.deck_2["pan"]
  1941.             counter = 0
  1942.             row_found = False
  1943.             for player_list_row in self.main_self.player_list_data:
  1944.                 if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1945.                     row = counter
  1946.                     row_found = True
  1947.                     break
  1948.                 counter +=1
  1949.             if row_found == True:
  1950.                 self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  1951.                 self.main_self.player_list_pan_changed(self.deck_2["player-list-item"]["player number"],False)
  1952.            
  1953.         self.papinhio_player.deck_2["pan"] = self.deck_2["pan"]
  1954.    
  1955.     def deck_2_apply_filter(self):
  1956.         self.deck_2["low-frequency"] = self.main_self.main_ui.deck_2_low_frequency_input.text()
  1957.         self.deck_2["high-frequency"] = self.main_self.main_ui.deck_2_high_frequency_input.text()
  1958.         if self.RepresentsInt(self.deck_2["low-frequency"]) and self.RepresentsInt(self.deck_2["high-frequency"]):
  1959.             self.deck_2["low-frequency"] = int(self.deck_2["low-frequency"])
  1960.             self.deck_2["high-frequency"] = int(self.deck_2["high-frequency"])
  1961.             if self.deck_2["high-frequency"]>self.deck_2["low-frequency"] and self.deck_2["high-frequency"]<=20000 and self.deck_2["low-frequency"]>=20:
  1962.                 self.papinhio_player.deck_2["low-frequency"] = self.deck_2["low-frequency"]
  1963.                 self.papinhio_player.deck_2["high-frequency"] = self.deck_2["high-frequency"]
  1964.                 if self.deck_2["player-list-item"] is not None:
  1965.                     self.deck_2["player-list-item"]["low frequency"] = self.deck_2["low-frequency"]
  1966.                     self.deck_2["player-list-item"]["high frequency"] = self.deck_2["high-frequency"]
  1967.                    
  1968.                     counter = 0
  1969.                     row_found = False
  1970.                     for player_list_row in self.main_self.player_list_data:
  1971.                         if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1972.                             row = counter
  1973.                             row_found = True
  1974.                             break
  1975.                         counter +=1
  1976.                     if row_found == True:
  1977.                         self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  1978.                         self.main_self.player_list_apply_filter(self.deck_2["player-list-item"]["player number"],False)
  1979.             else:
  1980.                 self.deck_2_reset_filter()
  1981.         else:
  1982.             self.deck_2_reset_filter()
  1983.    
  1984.     def deck_2_reset_filter(self):
  1985.         self.deck_2["low-frequency"] = 20
  1986.         self.deck_2["high-frequency"] = 20000
  1987.         self.main_self.main_ui.deck_2_low_frequency_input.setText(str(self.deck_2["low-frequency"]))
  1988.         self.main_self.main_ui.deck_2_high_frequency_input.setText(str(self.deck_2["high-frequency"]))
  1989.         if self.deck_2["player-list-item"] is not None:
  1990.             self.deck_2["player-list-item"]["low frequency"] = self.deck_2["low-frequency"]
  1991.             self.deck_2["player-list-item"]["high frequency"] = self.deck_2["high-frequency"]
  1992.             counter = 0
  1993.             row_found = False
  1994.             for player_list_row in self.main_self.player_list_data:
  1995.                 if player_list_row["player number"]==self.deck_2["player-list-item"]["player number"]:
  1996.                     row = counter
  1997.                     row_found = True
  1998.                     break
  1999.                 counter +=1
  2000.             if row_found == True:
  2001.                 self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  2002.                 self.main_self.player_list_apply_filter(self.deck_2["player-list-item"]["player number"],False)
  2003.            
  2004.         self.papinhio_player.deck_2["low-frequency"] = self.deck_2["low-frequency"]
  2005.         self.papinhio_player.deck_2["high-frequency"] = self.deck_2["high-frequency"]
  2006.        
  2007.     def music_clip_deck_timeline_changed(self):
  2008.         if(self.music_clip_deck["play-status"]=="playing" or self.music_clip_deck["play-status"]=="paused"):
  2009.             new_current_duration = int(self.main_self.main_ui.music_clip_deck_timeline.value())
  2010.             #calculate new chunk_number
  2011.             chunk_number = round(new_current_duration/self.papinhio_player.packet_time)
  2012.             self.papinhio_player.music_clip_deck["chunk-number"] = chunk_number
  2013.             current_duration_milliseconds = chunk_number*self.papinhio_player.packet_time
  2014.             self.papinhio_player.music_clip_deck["current-duration-milliseconds"] = current_duration_milliseconds
  2015.         else:
  2016.             self.main_self.main_ui.music_clip_deck_timeline.setProperty("value", 0)
  2017.    
  2018.     def music_clip_deck_play_or_pause_clicked(self):
  2019.         if self.music_clip_deck["play-status"]=="playing":
  2020.             self.music_clip_deck_status_changed("paused")
  2021.             #pause deck 1
  2022.             self.music_clip_deck["play-status"] = "paused"
  2023.             self.papinhio_player.music_clip_deck["play-status"] = "paused"
  2024.            
  2025.             icon3 = QtGui.QIcon()
  2026.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2027.             self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  2028.            
  2029.         elif self.music_clip_deck["play-status"]=="paused" or self.music_clip_deck["play-status"]=="stopped":
  2030.             self.music_clip_deck_status_changed("playing")
  2031.             icon3 = QtGui.QIcon()
  2032.             icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/pause_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2033.             self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  2034.    
  2035.     def music_clip_deck_stop_clicked(self):
  2036.         self.music_clip_deck_status_changed("stopped")
  2037.         self.music_clip_deck["play-status"] = "stopped"
  2038.         self.papinhio_player.music_clip_deck["play-status"] = "stopped"
  2039.         self.music_clip_deck_duration_changed(0)
  2040.         icon3 = QtGui.QIcon()
  2041.         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2042.         self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  2043.         self.music_clip_deck_status_changed("stopped")
  2044.    
  2045.     def music_clip_deck_mute_clicked(self):
  2046.         if self.music_clip_deck["player-list-row"] is not None:
  2047.             if self.music_clip_deck["mute"]==False:
  2048.                 self.music_clip_deck["mute"] = True
  2049.                 icon3 = QtGui.QIcon()
  2050.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/mute.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2051.                 self.main_self.main_ui.music_clip_deck_mute.setIcon(icon3)
  2052.                
  2053.                 self.music_clip_deck["previous-volume"] = self.music_clip_deck["volume"]
  2054.                 self.music_clip_deck["volume"] = 0
  2055.                 self.main_self.main_ui.music_clip_deck_volume_label.setText(str(self.music_clip_deck["volume"])+"/100")
  2056.                 if self.music_clip_deck["player-list-item"] is not None:
  2057.                     self.music_clip_deck["player-list-item"]["volume"] = self.music_clip_deck["volume"]
  2058.                     counter = 0
  2059.                     row_found = False
  2060.                     for player_list_row in self.main_self.player_list_data:
  2061.                         if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2062.                             row = counter
  2063.                             row_found = True
  2064.                             break
  2065.                         counter +=1
  2066.                     if row_found == True:
  2067.                         self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2068.                         self.main_self.player_list_volume_changed(self.music_clip_deck["player-list-item"]["player number"],False)
  2069.                    
  2070.                 self.papinhio_player.music_clip_deck["volume"] = self.music_clip_deck["volume"]
  2071.             else:
  2072.                 self.music_clip_deck["mute"] = False
  2073.                 icon3 = QtGui.QIcon()
  2074.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/volume.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2075.                 self.main_self.main_ui.music_clip_deck_mute.setIcon(icon3)
  2076.                
  2077.                 self.music_clip_deck["volume"] = self.music_clip_deck["previous-volume"]
  2078.                 self.main_self.main_ui.music_clip_deck_volume_label.setText(str(self.music_clip_deck["volume"])+"/100")
  2079.                 if self.music_clip_deck["player-list-item"] is not None:
  2080.                     self.music_clip_deck["player-list-item"]["volume"] = self.music_clip_deck["volume"]
  2081.                     counter = 0
  2082.                     row_found = False
  2083.                     for player_list_row in self.main_self.player_list_data:
  2084.                         if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2085.                             row = counter
  2086.                             row_found = True
  2087.                             break
  2088.                         counter +=1
  2089.                     if row_found == True:
  2090.                         self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2091.                         self.main_self.player_list_volume_changed(self.music_clip_deck["player-list-item"]["player number"],False)
  2092.                    
  2093.                 self.papinhio_player.music_clip_deck["volume"] = self.music_clip_deck["volume"]
  2094.    
  2095.     def music_clip_deck_volume_changed(self):
  2096.         self.music_clip_deck["volume"] = int(self.main_self.main_ui.music_clip_deck_volume_control.value())
  2097.         self.main_self.main_ui.music_clip_deck_volume_label.setText(str(self.music_clip_deck["volume"])+"/100")
  2098.         if self.music_clip_deck["player-list-item"] is not None:
  2099.             self.music_clip_deck["player-list-item"]["volume"] = self.music_clip_deck["volume"]
  2100.             counter = 0
  2101.             row_found = False
  2102.             for player_list_row in self.main_self.player_list_data:
  2103.                 if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2104.                     row = counter
  2105.                     row_found = True
  2106.                     break
  2107.                 counter +=1
  2108.             if row_found == True:
  2109.                 self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2110.                 self.main_self.player_list_volume_changed(self.music_clip_deck["player-list-item"]["player number"],False)
  2111.            
  2112.         self.papinhio_player.music_clip_deck["volume"] = self.music_clip_deck["volume"]
  2113.    
  2114.     def music_clip_deck_normalize_changed(self):
  2115.         self.music_clip_deck["normalize"] = self.main_self.main_ui.music_clip_normalize.isChecked()
  2116.         if self.music_clip_deck["player-list-item"] is not None:
  2117.             if self.music_clip_deck["normalize"]:
  2118.                 self.music_clip_deck["player-list-item"]["normalize"] = 1
  2119.             else:
  2120.                 self.music_clip_deck["player-list-item"]["normalize"] = 0
  2121.             counter = 0
  2122.             row_found = False
  2123.             for player_list_row in self.main_self.player_list_data:
  2124.                 if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2125.                     row = counter
  2126.                     row_found = True
  2127.                     break
  2128.                 counter +=1
  2129.             if row_found == True:
  2130.                 self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2131.                 self.main_self.change_player_list_normalize(self.music_clip_deck["player-list-item"]["player number"],False)
  2132.            
  2133.         self.papinhio_player.music_clip_deck["normalize"] = self.music_clip_deck["normalize"]
  2134.        
  2135.     def music_clip_deck_pan_changed(self):
  2136.         self.music_clip_deck["pan"] = int(self.main_self.main_ui.music_clip_deck_pan_control.value())/100
  2137.         self.main_self.main_ui.music_clip_deck_pan_label.setText(str(self.music_clip_deck["pan"])) 
  2138.         if self.music_clip_deck["player-list-item"] is not None:
  2139.             self.music_clip_deck["player-list-item"]["pan"] = self.music_clip_deck["pan"]
  2140.             counter = 0
  2141.             row_found = False
  2142.             for player_list_row in self.main_self.player_list_data:
  2143.                 if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2144.                     row = counter
  2145.                     row_found = True
  2146.                     break
  2147.                 counter +=1
  2148.             if row_found == True:
  2149.                 self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2150.                 self.main_self.player_list_pan_changed(self.music_clip_deck["player-list-item"]["player number"],False)
  2151.            
  2152.         self.papinhio_player.music_clip_deck["pan"] = self.music_clip_deck["pan"]
  2153.    
  2154.     def music_clip_deck_apply_filter(self):
  2155.         self.music_clip_deck["low-frequency"] = self.main_self.main_ui.music_clip_deck_low_frequency_input.text()
  2156.         self.music_clip_deck["high-frequency"] = self.main_self.main_ui.music_clip_deck_high_frequency_input.text()
  2157.         if self.RepresentsInt(self.music_clip_deck["low-frequency"]) and self.RepresentsInt(self.music_clip_deck["high-frequency"]):
  2158.             self.music_clip_deck["low-frequency"] = int(self.music_clip_deck["low-frequency"])
  2159.             self.music_clip_deck["high-frequency"] = int(self.music_clip_deck["high-frequency"])
  2160.             if self.music_clip_deck["high-frequency"]>self.music_clip_deck["low-frequency"] and self.music_clip_deck["high-frequency"]<=20000 and self.music_clip_deck["low-frequency"]>=20:
  2161.                 self.papinhio_player.music_clip_deck["low-frequency"] = self.music_clip_deck["low-frequency"]
  2162.                 self.papinhio_player.music_clip_deck["high-frequency"] = self.music_clip_deck["high-frequency"]
  2163.                 if self.music_clip_deck["player-list-item"] is not None:
  2164.                     self.music_clip_deck["player-list-item"]["low frequency"] = self.music_clip_deck["low-frequency"]
  2165.                     self.music_clip_deck["player-list-item"]["high frequency"] = self.music_clip_deck["high-frequency"]
  2166.                    
  2167.                     counter = 0
  2168.                     row_found = False
  2169.                     for player_list_row in self.main_self.player_list_data:
  2170.                         if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2171.                             row = counter
  2172.                             row_found = True
  2173.                             break
  2174.                         counter +=1
  2175.                     if row_found == True:
  2176.                         self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2177.                         self.main_self.player_list_apply_filter(self.music_clip_deck["player-list-item"]["player number"],False)
  2178.             else:
  2179.                 self.music_clip_deck_reset_filter()
  2180.         else:
  2181.             self.music_clip_deck_reset_filter()
  2182.    
  2183.     def music_clip_deck_reset_filter(self):
  2184.         self.music_clip_deck["low-frequency"] = 20
  2185.         self.music_clip_deck["high-frequency"] = 20000
  2186.         self.main_self.main_ui.music_clip_deck_low_frequency_input.setText(str(self.music_clip_deck["low-frequency"]))
  2187.         self.main_self.main_ui.music_clip_deck_high_frequency_input.setText(str(self.music_clip_deck["high-frequency"]))
  2188.         if self.music_clip_deck["player-list-item"] is not None:
  2189.             self.music_clip_deck["player-list-item"]["low frequency"] = self.music_clip_deck["low-frequency"]
  2190.             self.music_clip_deck["player-list-item"]["high frequency"] = self.music_clip_deck["high-frequency"]
  2191.             counter = 0
  2192.             row_found = False
  2193.             for player_list_row in self.main_self.player_list_data:
  2194.                 if player_list_row["player number"]==self.music_clip_deck["player-list-item"]["player number"]:
  2195.                     row = counter
  2196.                     row_found = True
  2197.                     break
  2198.                 counter +=1
  2199.             if row_found == True:
  2200.                 self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2201.                 self.main_self.player_list_apply_filter(self.music_clip_deck["player-list-item"]["player number"],False)
  2202.            
  2203.         self.papinhio_player.music_clip_deck["low-frequency"] = self.music_clip_deck["low-frequency"]
  2204.         self.papinhio_player.music_clip_deck["high-frequency"] = self.music_clip_deck["high-frequency"]
  2205.        
  2206.     def speackers_deck_click_to_talk_clicked(self):
  2207.         play_status = self.speackers_deck["play-status"]
  2208.         if play_status == "stopped":
  2209.             self.speackers_deck["play-status"] = "playing"
  2210.             self.papinhio_player.speackers_deck["play-status"] = "playing"
  2211.             self.microphone_input.speackers_deck["play-status"] = "playing"
  2212.            
  2213.             now = datetime.now()
  2214.             player_history_item = (now,now,"microphone","")
  2215.             self.speackers_deck["player-history-number"] = data.import_player_history(player_history_item)
  2216.            
  2217.             self.main_self.main_ui.speakers_deck_open_or_close_microphone.setText("Πατήστε όταν σταματήσετε να μιλάτε")
  2218.             self.main_self.main_ui.speakers_deck_click_to_talk.setEnabled(False)
  2219.         elif play_status == "playing":
  2220.             self.speackers_deck["play-status"] = "stopped"
  2221.             self.papinhio_player.speackers_deck["play-status"] = "stopped"
  2222.             self.microphone_input.speackers_deck["play-status"] = "stopped"
  2223.            
  2224.             now = datetime.now()
  2225.             player_history_item = (now,self.speackers_deck["player-history-number"])
  2226.             data.edit_player_history(player_history_item)
  2227.            
  2228.             self.main_self.main_ui.speakers_deck_open_or_close_microphone.setText("Πατήστε μία φορά για να μιλήσετε")
  2229.             self.main_self.main_ui.speakers_deck_click_to_talk.setEnabled(True)
  2230.                
  2231.     def speackers_deck_click_to_talk_pressed(self):
  2232.        
  2233.         if self.speackers_deck["play-status"] == "stopped":
  2234.             now = datetime.now()
  2235.             player_history_item = (now,now,"microphone","")
  2236.             self.speackers_deck["player-history-number"] = data.import_player_history(player_history_item)
  2237.        
  2238.             self.main_self.main_ui.speakers_deck_open_or_close_microphone.setEnabled(False)
  2239.             self.speackers_deck["play-status"] = "playing"
  2240.             self.papinhio_player.speackers_deck["play-status"] = "playing"
  2241.             self.microphone_input.speackers_deck["play-status"] = "playing"
  2242.             self.main_self.main_ui.speakers_deck_click_to_talk.setText("Αφήστε το ποντίκι όταν σταματήσετε να μιλάτε")
  2243.    
  2244.     def speackers_deck_click_to_talk_released(self):
  2245.        
  2246.         if self.speackers_deck["play-status"] == "playing":
  2247.             now = datetime.now()
  2248.             player_history_item = (now,self.speackers_deck["player-history-number"])
  2249.             data.edit_player_history(player_history_item)
  2250.            
  2251.             self.main_self.main_ui.speakers_deck_open_or_close_microphone.setEnabled(True)
  2252.             self.speackers_deck["play-status"] = "stopped"
  2253.             self.papinhio_player.speackers_deck["play-status"] = "stopped"
  2254.             self.microphone_input.speackers_deck["play-status"] = "stopped"
  2255.             self.main_self.main_ui.speakers_deck_click_to_talk.setText("Πιέστε παρατεταμένα για να μιλήσετε")
  2256.        
  2257.     def speackers_deck_volume_changed(self):
  2258.         self.speackers_deck["volume"] = int(self.main_self.main_ui.speackers_deck_volume_control.value())  
  2259.         self.main_self.main_ui.speackers_deck_volume_label.setText(str(self.speackers_deck["volume"])+"/100")  
  2260.         self.papinhio_player.speackers_deck["volume"] = self.speackers_deck["volume"]
  2261.         self.microphone_input.speackers_deck["volume"] = self.speackers_deck["volume"]
  2262.    
  2263.     def speackers_deck_normalize_changed(self):
  2264.         self.speackers_deck["normalize"] = self.main_self.main_ui.speackers_deck_normalize.isChecked() 
  2265.         self.papinhio_player.speackers_deck["normalize"] = self.speackers_deck["normalize"]
  2266.         self.microphone_input.speackers_deck["normalize"] = self.speackers_deck["normalize"]
  2267.    
  2268.     def speackers_deck_pan_changed(self):
  2269.         self.speackers_deck["pan"] = int(self.main_self.main_ui.speackers_deck_pan_control.value())/100
  2270.         self.main_self.main_ui.speackers_deck_pan_label.setText(str(self.speackers_deck["pan"]))   
  2271.         self.papinhio_player.speackers_deck["pan"] = self.speackers_deck["pan"]
  2272.         self.microphone_input.speackers_deck["pan"] = self.speackers_deck["pan"]
  2273.    
  2274.     def speackers_deck_apply_filter(self):
  2275.         self.speackers_deck["low-frequency"] = self.main_self.main_ui.speackers_clip_deck_low_frequency_input.text()
  2276.         self.speackers_deck["high-frequency"] = self.main_self.main_ui.speackers_deck_high_frequency_input.text()
  2277.         if self.RepresentsInt(self.speackers_deck["low-frequency"]) and self.RepresentsInt(self.speackers_deck["high-frequency"]):
  2278.             self.speackers_deck["low-frequency"] = int(self.speackers_deck["low-frequency"])
  2279.             self.speackers_deck["high-frequency"] = int(self.speackers_deck["high-frequency"])
  2280.             if self.speackers_deck["high-frequency"]>self.speackers_deck["low-frequency"] and self.speackers_deck["high-frequency"]<=20000 and self.speackers_deck["low-frequency"]>=20:
  2281.                 self.papinhio_player.speackers_deck["low-frequency"] = self.speackers_deck["low-frequency"]
  2282.                 self.microphone_input.speackers_deck["low-frequency"] = self.speackers_deck["low-frequency"]
  2283.                 self.papinhio_player.speackers_deck["high-frequency"] = self.speackers_deck["high-frequency"]
  2284.                 self.microphone_input.speackers_deck["high-frequency"] = self.speackers_deck["high-frequency"]
  2285.             else:
  2286.                 self.speackers_deck_reset_filter()
  2287.         else:
  2288.             self.speackers_deck_reset_filter()
  2289.        
  2290.     def speackers_deck_reset_filter(self):
  2291.         self.speackers_deck["low-frequency"] = 20
  2292.         self.speackers_deck["high-frequency"] = 20000
  2293.         self.main_self.main_ui.speackers_clip_deck_low_frequency_input.setText(str(self.speackers_deck["low-frequency"]))
  2294.         self.main_self.main_ui.speackers_deck_high_frequency_input.setText(str(self.speackers_deck["high-frequency"])) 
  2295.         self.papinhio_player.speackers_deck["low-frequency"] = self.speackers_deck["low-frequency"]
  2296.         self.microphone_input.speackers_deck["low-frequency"] = self.speackers_deck["low-frequency"]
  2297.         self.papinhio_player.speackers_deck["high-frequency"] = self.speackers_deck["high-frequency"]
  2298.         self.microphone_input.speackers_deck["high-frequency"] = self.speackers_deck["high-frequency"]
  2299.    
  2300.     def ip_call_1_deck_answer(self):
  2301.         pass
  2302.    
  2303.     def ip_call_1_deck_reject(self):
  2304.         pass
  2305.    
  2306.     def ip_call_1_transmit_call(self):
  2307.         pass
  2308.    
  2309.     def ip_call_1_deck_volume_changed(self):
  2310.         pass
  2311.    
  2312.     def ip_call_1_deck_normalize_changed(self):
  2313.         pass
  2314.    
  2315.     def ip_call_1_deck_pan_changed(self):
  2316.         pass
  2317.    
  2318.     def ip_call_1_deck_apply_filter(self):
  2319.         pass
  2320.    
  2321.     def ip_call_1_deck_reset_filter(self):
  2322.         pass
  2323.        
  2324.     def ip_call_2_deck_answer(self):
  2325.         pass
  2326.    
  2327.     def ip_call_2_deck_reject(self):
  2328.         pass
  2329.    
  2330.     def ip_call_2_transmit_call(self):
  2331.         pass
  2332.    
  2333.     def ip_call_2_deck_volume_changed(self):
  2334.         pass
  2335.    
  2336.     def ip_call_2_deck_normalize_changed(self):
  2337.         pass
  2338.    
  2339.     def ip_call_2_deck_pan_changed(self):
  2340.         pass
  2341.    
  2342.     def ip_call_2_deck_apply_filter(self):
  2343.         pass
  2344.    
  2345.     def ip_call_2_deck_reset_filter(self):
  2346.         pass
  2347.        
  2348.     def ip_call_3_deck_answer(self):
  2349.         pass
  2350.    
  2351.     def ip_call_3_deck_reject(self):
  2352.         pass
  2353.    
  2354.     def ip_call_3_transmit_call(self):
  2355.         pass
  2356.    
  2357.     def ip_call_3_deck_volume_changed(self):
  2358.         pass
  2359.    
  2360.     def ip_call_3_deck_normalize_changed(self):
  2361.         pass
  2362.    
  2363.     def ip_call_3_deck_pan_changed(self):
  2364.         pass
  2365.    
  2366.     def ip_call_3_deck_apply_filter(self):
  2367.         pass
  2368.    
  2369.     def ip_call_3_deck_reset_filter(self):
  2370.         pass
  2371.        
  2372.     def prepare_deck_1(self,player_list_number):
  2373.         if self.deck_1["play-status"]!="stopped":
  2374.             self.deck_1["play-status"] = "stopped"
  2375.             self.deck_1_status_changed("stopped")
  2376.             self.papinhio_player.deck_1["play-status"] = "stopped"
  2377.            
  2378.         counter = 0
  2379.         for player_list_row_1 in self.main_self.player_list_data:
  2380.             if player_list_row_1["player number"]==player_list_number:
  2381.                 self.deck_1["player-list-item"] = player_list_row_1
  2382.                 self.deck_1["player-list-row"] = counter
  2383.                 break
  2384.             counter +=1
  2385.        
  2386.         #set data to deck_1_details
  2387.        
  2388.         if "image path" not in self.deck_1["player-list-item"]:
  2389.             self.deck_1["player-list-item"]["image path"] = ""
  2390.            
  2391.         if os.path.exists(self.deck_1["player-list-item"]["image path"]):
  2392.             pixmap = QtGui.QPixmap(self.deck_1["player-list-item"]["image path"]).scaledToHeight(230)
  2393.             self.main_self.main_ui.deck_1_image.setPixmap(pixmap)
  2394.             self.main_self.main_ui.deck_1_image.setScaledContents(True)
  2395.             self.main_self.main_ui.deck_1_image.resize(230, 230)
  2396.             self.main_self.main_ui.deck_1_image.update()
  2397.         else:
  2398.             self.main_self.main_ui.deck_1_image.setPixmap(QtGui.QPixmap(":/main_program_icons/media/images/deck_image.png"))
  2399.             self.main_self.main_ui.deck_1_image.setScaledContents(True)
  2400.             self.main_self.main_ui.deck_1_image.resize(230, 230)
  2401.             self.main_self.main_ui.deck_1_image.update()
  2402.        
  2403.         if "image title" not in self.deck_1["player-list-item"]:
  2404.             self.deck_1["player-list-item"]["image title"] = ""
  2405.         self.main_self.main_ui.deck_1_image_title.setText(str(self.deck_1["player-list-item"]["image title"]))
  2406.    
  2407.         self.main_self.main_ui.deck_1_title_in_details.setText("Τίτλος: "+str(self.deck_1["player-list-item"]["title"]))
  2408.         if "artist" not in self.deck_1["player-list-item"]:
  2409.             self.deck_1["player-list-item"]["artist"] = ""
  2410.         self.main_self.main_ui.deck_1_artist.setText("Καλλιτέχνης: "+str(self.deck_1["player-list-item"]["artist"]))
  2411.         if "composer" not in self.deck_1["player-list-item"]:
  2412.             self.deck_1["player-list-item"]["composer"] = ""
  2413.         self.main_self.main_ui.deck_1_composer.setText("Συνθέτης: "+str(self.deck_1["player-list-item"]["composer"]))
  2414.         if "author" not in self.deck_1["player-list-item"]:
  2415.             self.deck_1["player-list-item"]["author"] = ""
  2416.         self.main_self.main_ui.deck_1_author.setText("Στιχουργός: "+str(self.deck_1["player-list-item"]["author"]))
  2417.         if "album" not in self.deck_1["player-list-item"]:
  2418.             self.deck_1["player-list-item"]["album"] = ""
  2419.         self.main_self.main_ui.deck_1_album.setText("Λεύκωμα: "+str(self.deck_1["player-list-item"]["album"]))
  2420.         if "year" not in self.deck_1["player-list-item"]:
  2421.             self.deck_1["player-list-item"]["year"] = ""
  2422.         self.main_self.main_ui.deck_1_year.setText("Έτος κυκλοφορίας: "+str(self.deck_1["player-list-item"]["year"]))
  2423.  
  2424.         rating = int(self.deck_1["player-list-item"]["rating"])
  2425.         self.display_rating("Clic",self.deck_1["player-list-item"]["player number"],rating,"deck 1")
  2426.        
  2427.        
  2428.         self.deck_1["total-duration-milliseconds"] = int(self.deck_1["player-list-item"]["duration milliseconds"])
  2429.         self.deck_1["total-duration-human"] = self.deck_1["player-list-item"]["duration human"]
  2430.         self.main_self.main_ui.deck_1_duration.setText("Διάρκεια: 00:00:00/"+str(self.deck_1["total-duration-human"]))
  2431.        
  2432.         self.main_self.main_ui.deck_1_repeats.setText("Υπολειπόμενες επαναλήψεις: "+str(self.deck_1["player-list-item"]["repeats"]))
  2433.         self.deck_1["player-list-item"]["repeats"] -= 1
  2434.        
  2435.         #3. Update deck_1
  2436.         self.main_self.main_ui.deck_1_title.setText("Deck 1: "+str(self.deck_1["player-list-item"]["title"]))
  2437.        
  2438.         self.main_self.main_ui.deck_1_time.setText("00:00:00/"+str(self.deck_1["total-duration-human"]))
  2439.         self.main_self.main_ui.deck_1_timeline.setMaximum(self.deck_1["total-duration-milliseconds"])
  2440.         self.main_self.main_ui.deck_1_timeline.setSingleStep(500)
  2441.         self.main_self.main_ui.deck_1_timeline.setPageStep(1000)
  2442.         self.main_self.main_ui.deck_1_timeline.setProperty("value", 0)
  2443.         self.main_self.main_ui.deck_1_timeline.setEnabled(True)
  2444.         if self.deck_1["player-list-item"]["type"]!="retransmitions":
  2445.             self.main_self.main_ui.deck_1_timeline.show()
  2446.         else:
  2447.             self.main_self.main_ui.deck_1_timeline.hide()
  2448.        
  2449.         self.deck_1["volume"] = int(self.deck_1["player-list-item"]["volume"])
  2450.         self.main_self.main_ui.deck_1_volume_label.setText(str(self.deck_1["volume"])+"/100")
  2451.         self.main_self.main_ui.deck_1_volume_control.setValue(self.deck_1["volume"])
  2452.        
  2453.         self.deck_1["normalize"] = int(self.deck_1["player-list-item"]["normalize"])
  2454.         if self.deck_1["normalize"]==1 or self.deck_1["normalize"]==True:
  2455.             self.main_self.main_ui.deck_1_normalize.setChecked(True)
  2456.         else:
  2457.             self.main_self.main_ui.deck_1_normalize.setChecked(False)
  2458.            
  2459.         self.deck_1["pan"] = int(self.deck_1["player-list-item"]["pan"])
  2460.         self.main_self.main_ui.deck_1_pan_label.setText(str(self.deck_1["pan"]))
  2461.         self.main_self.main_ui.deck_1_pan_control.setValue(self.deck_1["pan"])
  2462.        
  2463.         self.deck_1["low-frequency"] = int(float(self.deck_1["player-list-item"]["low frequency"]))
  2464.         self.main_self.main_ui.deck_1_low_frequency_input.setText(str(self.deck_1["low-frequency"]))
  2465.         self.deck_1["high-frequency"] = int(float(self.deck_1["player-list-item"]["high frequency"]))
  2466.         self.main_self.main_ui.deck_1_high_frequency_input.setText(str(self.deck_1["high-frequency"]))
  2467.        
  2468.         #Remove or update playerlist item
  2469.         if self.deck_1["player-list-item"]["repeats"]<0:
  2470.             #remove item
  2471.             self.main_self.delete_player_list_item(player_list_number)
  2472.             #if player list is checked insert the deleted row in the endswith
  2473.             if self.main_self.repeat_player_list:
  2474.                 if self.deck_1["player-list-item"]["type"]!="retransmitions" and self.deck_1["player-list-item"]["type"]!="greek time files":
  2475.                     data.add_to_player_list_bottom(self.deck_1["player-list-item"]["type"],self.deck_1["player-list-item"]["relative number"])
  2476.                 elif self.deck_1["player-list-item"]["type"]=="retransmitions":
  2477.                     data.add_retransmition_to_player_list_bottom(self.deck_1["player-list-item"]["relative number"],self.deck_1["player-list-item"]["duration milliseconds"])
  2478.                 elif self.deck_1["player-list-item"]["type"]=="greek time files":
  2479.                     data.add_greek_time_to_player_list(self.deck_1["player-list-item"]["group title"])
  2480.                    
  2481.                 new_row = len(self.main_self.player_list_data)-1
  2482.                 self.main_self.display_player_list_row(new_row,self.deck_1["player-list-item"],True)
  2483.                 self.main_self.player_list_data.append(self.deck_1["player-list-item"])
  2484.                
  2485.         else:
  2486.             #update item
  2487.             counter = 0
  2488.             row_found = False
  2489.             for player_list_row in self.main_self.player_list_data:
  2490.                 if player_list_row["player number"]==player_list_number:
  2491.                     row = counter
  2492.                     row_found = True
  2493.                     break
  2494.                 counter +=1
  2495.             if row_found == True:
  2496.                 self.main_self.display_player_list_row(row,self.deck_1["player-list-item"])
  2497.         self.deck_1["chunk-number"] = 0
  2498.         self.deck_1["current-duration-milliseconds"] = 0
  2499.    
  2500.         icon3 = QtGui.QIcon()
  2501.         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2502.         self.main_self.main_ui.deck_1_play_pause.setIcon(icon3)
  2503.        
  2504.         #if type is retransmition check radio url
  2505.         if self.deck_1["player-list-item"]["type"]=="retransmitions":
  2506.             self.deck_1["radio-url"] = None
  2507.             self.papinhio_player.prepare_deck_1(self.deck_1)
  2508.             self.check_url(self.deck_1["player-list-item"],"deck 1")
  2509.         else:
  2510.             self.papinhio_player.prepare_deck_1(self.deck_1)
  2511.                
  2512.     def check_url(self,retransmition,deck):
  2513.         url = retransmition["url"]
  2514.         url_option = retransmition["url option"]
  2515.         self.javascript_code = retransmition["javascript code"]
  2516.         radio_url_check = retransmition["radio url"]
  2517.         if(url_option=="const"):
  2518.             radio_url_exists = self.check_radio_url(url)
  2519.             if(radio_url_exists==True):
  2520.                 self.radio_url = url
  2521.                 if deck == "deck 1":
  2522.                     self.papinhio_player.deck_1["radio-url"] = url
  2523.                
  2524.                 if deck == "deck 2":
  2525.                     self.papinhio_player.deck_2["radio-url"] = url
  2526.             else:
  2527.                 if deck == "deck 1":
  2528.                     self.papinhio_player.deck_1["radio-url"] = None
  2529.                     self.deck_1["play-status"] = "stopped"
  2530.                     self.papinhio_player.deck_1["play-status"] = "stopped"
  2531.                     #display error message
  2532.                    
  2533.                 if deck == "deck 2":
  2534.                     self.papinhio_player.deck_2["radio-url"] = None
  2535.                     self.deck_2["play-status"] = "stopped"
  2536.                     self.papinhio_player.deck_2["play-status"] = "stopped"
  2537.                     #display error message
  2538.         else:
  2539.             radio_url_exists = self.check_radio_url(radio_url_check)
  2540.             if(radio_url_exists==True):
  2541.                 self.radio_url = radio_url_check
  2542.                 if deck == "deck 1":
  2543.                     self.papinhio_player.deck_1["radio_url"] = radio_url_check
  2544.                     if self.deck_1["play-status"]=="prepare-and-play":
  2545.                         self.deck_1["play-status"] = "playing"
  2546.                         self.papinhio_player.deck_1["play-status"] = "playing"
  2547.                        
  2548.                 if deck == "deck 2":
  2549.                     self.papinhio_player.deck_2["radio_url"] = radio_url_check
  2550.                     if self.deck_2["play-status"]=="prepare-and-play":
  2551.                         self.deck_2["play-status"] = "playing"
  2552.                         self.papinhio_player.deck_2["play-status"] = "playing"
  2553.             else:
  2554.                 self.main_page_loaded = False
  2555.                 self.browser = QWebView()
  2556.                 self.main_page = QWebPage()
  2557.                
  2558.                 self.browser.setPage(self.main_page)
  2559.                 self.browser.setUrl(QUrl(url))
  2560.                 self.browser.loadFinished.connect(lambda ok:self.main_page_loaded_finished(ok))
  2561.            
  2562.     def check_radio_url(self,radio_url):
  2563.         packets = 10
  2564.         try:
  2565.             self.client = miniaudio.IceCastClient(radio_url)
  2566.             try:
  2567.                 self.pcm_stream = MiniaudioDecoderPcmStream(self.client.audio_format,self.client)
  2568.             except Exception as e:
  2569.                 return e
  2570.             for i in range(0,packets):
  2571.                 try:
  2572.                     audio = self.pcm_stream.read(1024)
  2573.                    
  2574.                 except Exception as e:
  2575.                     return e
  2576.                
  2577.             return True
  2578.         except Exception as e:
  2579.             return e
  2580.            
  2581.         return True
  2582.        
  2583.     def main_page_loaded_finished(self,ok):
  2584.         if(self.main_page_loaded==False):
  2585.             if(ok):
  2586.                 self.main_page_loaded = True
  2587.                
  2588.                 radio_url_retrieved = str(self.browser.page().currentFrame().evaluateJavaScript(self.javascript_code)).strip()
  2589.                 self.main_page.deleteLater()
  2590.                 self.main_page = None
  2591.                 self.browser.stop()
  2592.                 self.browser.close()
  2593.                 self.browser.hide()
  2594.                 self.browser.deleteLater()
  2595.                 self.browser = None
  2596.                
  2597.                
  2598.                 radio_url_exists = self.check_radio_url(radio_url_retrieved)
  2599.                 if(radio_url_exists==True):
  2600.                     self.radio_url = radio_url_retrieved
  2601.                    
  2602.                     if deck == "deck 1":
  2603.                         self.papinhio_player.deck_1["radio-url"] = radio_url_retrieved
  2604.                            
  2605.                     if deck == "deck 2":
  2606.                         self.papinhio_player.deck_2["radio-url"] = radio_url_retrieved
  2607.                 else:
  2608.                     if deck == "deck 1":
  2609.                         self.radio_url = False
  2610.                         self.papinhio_player.deck_1["radio-url"] = None
  2611.                         self.deck_1["play_status"] = "stopped"
  2612.                         self.papinhio_player.deck_1["play-status"] = "stopped"
  2613.                        
  2614.                     if deck == "deck 2":
  2615.                         self.radio_url = False
  2616.                         self.papinhio_player.deck_1["radio-url"] = None
  2617.                         self.deck_2["play_status"] = "stopped"
  2618.                         self.papinhio_player.deck_2["play-status"] = "stopped"
  2619.  
  2620.     def prepare_and_play_deck_1(self,player_list_number):
  2621.         self.prepare_deck_1(player_list_number)
  2622.         self.deck_1["play-status"] = "playing"
  2623.         self.papinhio_player.deck_1["play-status"] = "playing"
  2624.         self.deck_1_status_changed("playing")
  2625.    
  2626.     def prepare_deck_2(self,player_list_number):
  2627.         if self.deck_2["play-status"]!="stopped":
  2628.             self.deck_2["play-status"] = "stopped"
  2629.             self.deck_2_status_changed("stopped")
  2630.             self.papinhio_player.deck_2["play-status"] = "stopped"
  2631.            
  2632.         counter = 0
  2633.         for player_list_row_1 in self.main_self.player_list_data:
  2634.             if player_list_row_1["player number"]==player_list_number:
  2635.                 self.deck_2["player-list-item"] = player_list_row_1
  2636.                 self.deck_2["player-list-row"] = counter
  2637.                 break
  2638.             counter +=1
  2639.        
  2640.         #set data to deck_2_details
  2641.        
  2642.         if "image path" not in self.deck_2["player-list-item"]:
  2643.             self.deck_2["player-list-item"]["image path"] = ""
  2644.            
  2645.         if os.path.exists(self.deck_2["player-list-item"]["image path"]):
  2646.             pixmap = QtGui.QPixmap(self.deck_2["player-list-item"]["image path"]).scaledToHeight(230)
  2647.             self.main_self.main_ui.deck_2_image.setPixmap(pixmap)
  2648.             self.main_self.main_ui.deck_2_image.setScaledContents(True)
  2649.             self.main_self.main_ui.deck_2_image.resize(230, 230)
  2650.             self.main_self.main_ui.deck_2_image.update()
  2651.         else:
  2652.             self.main_self.main_ui.deck_2_image.setPixmap(QtGui.QPixmap(":/main_program_icons/media/images/deck_image.png"))
  2653.             self.main_self.main_ui.deck_2_image.setScaledContents(True)
  2654.             self.main_self.main_ui.deck_2_image.resize(230, 230)
  2655.             self.main_self.main_ui.deck_2_image.update()
  2656.        
  2657.         if "image title" not in self.deck_2["player-list-item"]:
  2658.             self.deck_2["player-list-item"]["image title"] = ""
  2659.         self.main_self.main_ui.deck_2_image_title.setText(str(self.deck_2["player-list-item"]["image title"]))
  2660.    
  2661.         self.main_self.main_ui.deck_2_title_in_details.setText("Τίτλος: "+str(self.deck_2["player-list-item"]["title"]))
  2662.         if "artist" not in self.deck_2["player-list-item"]:
  2663.             self.deck_2["player-list-item"]["artist"] = ""
  2664.         self.main_self.main_ui.deck_2_artist.setText("Καλλιτέχνης: "+str(self.deck_2["player-list-item"]["artist"]))
  2665.         if "composer" not in self.deck_2["player-list-item"]:
  2666.             self.deck_2["player-list-item"]["composer"] = ""
  2667.         self.main_self.main_ui.deck_2_composer.setText("Συνθέτης: "+str(self.deck_2["player-list-item"]["composer"]))
  2668.         if "author" not in self.deck_2["player-list-item"]:
  2669.             self.deck_2["player-list-item"]["author"] = ""
  2670.         self.main_self.main_ui.deck_2_author.setText("Στιχουργός: "+str(self.deck_2["player-list-item"]["author"]))
  2671.         if "album" not in self.deck_2["player-list-item"]:
  2672.             self.deck_2["player-list-item"]["album"] = ""
  2673.         self.main_self.main_ui.deck_2_album.setText("Λεύκωμα: "+str(self.deck_2["player-list-item"]["album"]))
  2674.         if "year" not in self.deck_2["player-list-item"]:
  2675.             self.deck_2["player-list-item"]["year"] = ""
  2676.         self.main_self.main_ui.deck_2_year.setText("Έτος κυκλοφορίας: "+str(self.deck_2["player-list-item"]["year"]))
  2677.  
  2678.         rating = int(self.deck_2["player-list-item"]["rating"])
  2679.         self.display_rating("Clic",self.deck_2["player-list-item"]["player number"],rating,"deck 2")
  2680.        
  2681.        
  2682.         self.deck_2["total-duration-milliseconds"] = int(self.deck_2["player-list-item"]["duration milliseconds"])
  2683.         self.deck_2["total-duration-human"] = self.deck_2["player-list-item"]["duration human"]
  2684.         self.main_self.main_ui.deck_2_duration.setText("Διάρκεια: 00:00:00/"+str(self.deck_2["total-duration-human"]))
  2685.        
  2686.         self.main_self.main_ui.deck_2_repeats.setText("Υπολειπόμενες επαναλήψεις: "+str(self.deck_2["player-list-item"]["repeats"]))
  2687.         self.deck_2["player-list-item"]["repeats"] -= 1
  2688.        
  2689.         #3. Update deck_2
  2690.         self.main_self.main_ui.deck_2_title.setText("Deck 2: "+str(self.deck_2["player-list-item"]["title"]))
  2691.        
  2692.         self.main_self.main_ui.deck_2_time.setText("00:00:00/"+str(self.deck_2["total-duration-human"]))
  2693.         self.main_self.main_ui.deck_2_timeline.setMaximum(self.deck_2["total-duration-milliseconds"])
  2694.         self.main_self.main_ui.deck_2_timeline.setSingleStep(500)
  2695.         self.main_self.main_ui.deck_2_timeline.setPageStep(1000)
  2696.         self.main_self.main_ui.deck_2_timeline.setProperty("value", 0)
  2697.         self.main_self.main_ui.deck_2_timeline.setEnabled(True)
  2698.         if self.deck_2["player-list-item"]["type"]!="retransmitions":
  2699.             self.main_self.main_ui.deck_2_timeline.show()
  2700.         else:
  2701.             self.main_self.main_ui.deck_2_timeline.hide()
  2702.        
  2703.         self.deck_2["volume"] = int(self.deck_2["player-list-item"]["volume"])
  2704.         self.main_self.main_ui.deck_2_volume_label.setText(str(self.deck_2["volume"])+"/100")
  2705.         self.main_self.main_ui.deck_2_volume_control.setValue(self.deck_2["volume"])
  2706.        
  2707.         self.deck_2["normalize"] = int(self.deck_2["player-list-item"]["normalize"])
  2708.         if self.deck_2["normalize"]==1 or self.deck_2["normalize"]==True:
  2709.             self.main_self.main_ui.deck_2_normalize.setChecked(True)
  2710.         else:
  2711.             self.main_self.main_ui.deck_2_normalize.setChecked(False)
  2712.            
  2713.         self.deck_2["pan"] = int(self.deck_2["player-list-item"]["pan"])
  2714.         self.main_self.main_ui.deck_2_pan_label.setText(str(self.deck_2["pan"]))
  2715.         self.main_self.main_ui.deck_2_pan_control.setValue(self.deck_2["pan"])
  2716.        
  2717.         self.deck_2["low-frequency"] = int(float(self.deck_2["player-list-item"]["low frequency"]))
  2718.         self.main_self.main_ui.deck_2_low_frequency_input.setText(str(self.deck_2["low-frequency"]))
  2719.         self.deck_2["high-frequency"] = int(float(self.deck_2["player-list-item"]["high frequency"]))
  2720.         self.main_self.main_ui.deck_2_high_frequency_input.setText(str(self.deck_2["high-frequency"]))
  2721.        
  2722.         #Remove or update playerlist item
  2723.            
  2724.         if self.deck_2["player-list-item"]["repeats"]<0:
  2725.             #remove item
  2726.             self.main_self.delete_player_list_item(player_list_number)
  2727.             #if player list is checked insert the deleted row in the endswith
  2728.             if self.main_self.repeat_player_list:
  2729.                 if self.deck_2["player-list-item"]["type"]!="retransmitions" and self.deck_2["player-list-item"]["type"]!="greek time files":
  2730.                     data.add_to_player_list_bottom(self.deck_2["player-list-item"]["type"],self.deck_2["player-list-item"]["relative number"])
  2731.                 elif self.deck_2["player-list-item"]["type"]=="retransmitions":
  2732.                     data.add_retransmition_to_player_list_bottom(self.deck_2["player-list-item"]["relative number"],self.deck_2["player-list-item"]["duration milliseconds"])
  2733.                 elif self.deck_1["player-list-item"]["type"]=="greek time files":
  2734.                     data.add_greek_time_to_player_list(self.deck_2["player-list-item"]["group title"])
  2735.                    
  2736.                 new_row = len(self.main_self.player_list_data)-1
  2737.                 self.main_self.display_player_list_row(new_row,self.deck_2["player-list-item"],True)
  2738.         else:
  2739.             #update item
  2740.             counter = 0
  2741.             row_found = False
  2742.             for player_list_row in self.main_self.player_list_data:
  2743.                 if player_list_row["player number"]==player_list_number:
  2744.                     row = counter
  2745.                     row_found = True
  2746.                     break
  2747.                 counter +=1
  2748.             if row_found == True:
  2749.                 self.main_self.display_player_list_row(row,self.deck_2["player-list-item"])
  2750.         self.deck_2["chunk-number"] = 0
  2751.         self.deck_2["current-duration-milliseconds"] = 0
  2752.    
  2753.         icon3 = QtGui.QIcon()
  2754.         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2755.         self.main_self.main_ui.deck_2_play_pause.setIcon(icon3)
  2756.        
  2757.         #if type is retransmition check radio url
  2758.         if self.deck_2["player-list-item"]["type"]=="retransmitions":
  2759.             self.deck_2["radio-url"] = None
  2760.             self.papinhio_player.prepare_deck_2(self.deck_2)
  2761.             self.check_url(self.deck_2["player-list-item"],"deck 2")
  2762.         else:
  2763.             self.papinhio_player.prepare_deck_2(self.deck_2)
  2764.        
  2765.     def prepare_and_play_deck_2(self,player_list_number):
  2766.         self.prepare_deck_2(player_list_number)
  2767.         self.deck_2["play-status"] = "playing"
  2768.         self.papinhio_player.deck_2["play-status"] = "playing"
  2769.         self.deck_2_status_changed("playing")
  2770.    
  2771.     def prepare_music_clip_deck(self,player_list_number):
  2772.         if self.music_clip_deck["play-status"]!="stopped":
  2773.             self.music_clip_deck["play-status"] = "stopped"
  2774.             self.music_clip_deck_status_changed("stopped")
  2775.             self.papinhio_player.music_clip_deck["play-status"] = "stopped"
  2776.            
  2777.         counter = 0
  2778.         for player_list_row_1 in self.main_self.player_list_data:
  2779.             if player_list_row_1["player number"]==player_list_number:
  2780.                 self.music_clip_deck["player-list-item"] = player_list_row_1
  2781.                 self.music_clip_deck["player-list-row"] = counter
  2782.                 break
  2783.             counter +=1
  2784.            
  2785.         self.music_clip_deck["total-duration-milliseconds"] = int(self.music_clip_deck["player-list-item"]["duration"])
  2786.         self.music_clip_deck["total-duration-human"] = self.convert_duration_from_milliseconds_to_human(self.music_clip_deck["total-duration-milliseconds"])
  2787.        
  2788.         self.music_clip_deck["player-list-item"]["repeats"] -= 1
  2789.        
  2790.         #Update music clip deck
  2791.         self.main_self.main_ui.music_clip_deck_title.setText("Music clip deck: "+str(self.music_clip_deck["player-list-item"]["title"]))
  2792.        
  2793.         self.main_self.main_ui.music_clip_deck_time.setText("00:00:00/"+str(self.music_clip_deck["total-duration-human"]))
  2794.         self.main_self.main_ui.music_clip_deck_timeline.setMaximum(self.music_clip_deck["total-duration-milliseconds"])
  2795.         self.main_self.main_ui.music_clip_deck_timeline.setSingleStep(500)
  2796.         self.main_self.main_ui.music_clip_deck_timeline.setPageStep(1000)
  2797.         self.main_self.main_ui.music_clip_deck_timeline.setProperty("value", 0)
  2798.         self.main_self.main_ui.music_clip_deck_timeline.setEnabled(True)
  2799.        
  2800.         self.music_clip_deck["volume"] = int(self.music_clip_deck["player-list-item"]["volume"])
  2801.         self.main_self.main_ui.music_clip_deck_volume_label.setText(str(self.music_clip_deck["volume"])+"/100")
  2802.         self.main_self.main_ui.music_clip_deck_volume_control.setValue(self.music_clip_deck["volume"])
  2803.        
  2804.         self.music_clip_deck["normalize"] = int(self.music_clip_deck["player-list-item"]["normalize"])
  2805.         if self.music_clip_deck["normalize"]==1 or self.music_clip_deck["normalize"]==True:
  2806.             self.main_self.main_ui.music_clip_normalize.setChecked(True)
  2807.         else:
  2808.             self.main_self.main_ui.music_clip_normalize.setChecked(False)
  2809.            
  2810.         self.music_clip_deck["pan"] = int(self.music_clip_deck["player-list-item"]["pan"])
  2811.         self.main_self.main_ui.music_clip_deck_pan_label.setText(str(self.music_clip_deck["pan"]))
  2812.         self.main_self.main_ui.music_clip_deck_pan_control.setValue(self.music_clip_deck["pan"])
  2813.        
  2814.         self.music_clip_deck["low-frequency"] = int(float(self.music_clip_deck["player-list-item"]["low frequency"]))
  2815.         self.main_self.main_ui.music_clip_deck_low_frequency_input.setText(str(self.music_clip_deck["low-frequency"]))
  2816.         self.music_clip_deck["high-frequency"] = int(float(self.music_clip_deck["player-list-item"]["high frequency"]))
  2817.         self.main_self.main_ui.music_clip_deck_high_frequency_input.setText(str(self.music_clip_deck["high-frequency"]))
  2818.        
  2819.         #Remove or update playerlist item
  2820.            
  2821.         if self.music_clip_deck["player-list-item"]["repeats"]<0:
  2822.             #remove item
  2823.             self.main_self.delete_player_list_item(player_list_number)
  2824.             #if player list is checked insert the deleted row in the endswith
  2825.             if self.main_self.repeat_player_list:
  2826.                 data.add_to_player_list_bottom(self.music_clip_deck["player-list-item"]["type"],self.music_clip_deck["player-list-item"]["relative number"])       
  2827.                 new_row = len(self.main_self.player_list_data)-1
  2828.                 self.main_self.display_player_list_row(new_row,self.music_clip_deck["player-list-item"],True)
  2829.         else:
  2830.             #update item
  2831.             counter = 0
  2832.             row_found = False
  2833.             for player_list_row in self.main_self.player_list_data:
  2834.                 if player_list_row["player number"]==player_list_number:
  2835.                     row = counter
  2836.                     row_found = True
  2837.                     break
  2838.                 counter +=1
  2839.             if row_found == True:
  2840.                 self.main_self.display_player_list_row(row,self.music_clip_deck["player-list-item"])
  2841.         self.music_clip_deck["chunk-number"] = 0
  2842.         self.music_clip_deck["current-duration-milliseconds"] = 0
  2843.    
  2844.         icon3 = QtGui.QIcon()
  2845.         icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  2846.         self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  2847.        
  2848.         self.papinhio_player.prepare_music_clip_deck(self.music_clip_deck)
  2849.        
  2850.     def prepare_and_play_music_clip_deck(self,player_list_number):
  2851.         self.prepare_music_clip_deck(player_list_number)
  2852.         self.music_clip_deck["play-status"] = "playing"
  2853.         self.papinhio_player.music_clip_deck["play-status"] = "playing"
  2854.         self.music_clip_deck_status_changed("playing")
  2855.    
  2856.     def RepresentsInt(self,s):
  2857.         try:
  2858.             int(s)
  2859.             return True
  2860.         except ValueError:
  2861.             return False
  2862.            
  2863.     def display_rating(self,action,player_list_number,rating,deck,loop=False):
  2864.         preview_rating_frame = QtWidgets.QFrame()
  2865.         sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
  2866.         sizePolicy.setHorizontalStretch(0)
  2867.         sizePolicy.setVerticalStretch(0)
  2868.         sizePolicy.setHeightForWidth(preview_rating_frame.sizePolicy().hasHeightForWidth())
  2869.         preview_rating_frame.setSizePolicy(sizePolicy)
  2870.         preview_rating_frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
  2871.         preview_rating_frame.setFrameShadow(QtWidgets.QFrame.Raised)
  2872.         horizontalLayout = QtWidgets.QHBoxLayout(preview_rating_frame)
  2873.         rating_label = QtWidgets.QLabel()
  2874.         rating_label.setText("Αξιολόγηση: ")
  2875.         horizontalLayout.addWidget(rating_label)
  2876.        
  2877.         rest_rating = 10 - rating
  2878.        
  2879.         for i in range(0,rating):
  2880.             star_label = QLabelClickable(preview_rating_frame)
  2881.             star_label.setMinimumSize(QtCore.QSize(16, 16))
  2882.             star_label.setMaximumSize(QtCore.QSize(16, 16))
  2883.             star_label.setText("")
  2884.             star_label.setPixmap(QtGui.QPixmap(":/main_program_icons/media/images/star_yellow.png"))
  2885.             star_label.setScaledContents(True)
  2886.             #star_label.setCursor(QtGui.QCursor(Qt.PointingHandCursor))
  2887.             #star_label.clicked.connect(lambda action,player_list_number=player_list_number,rating=i+1:self.display_rating(action,player_list_number,rating,deck))
  2888.             horizontalLayout.addWidget(star_label)     
  2889.            
  2890.         for i in range(0,rest_rating):
  2891.             star_label = QLabelClickable()
  2892.             star_label.setMinimumSize(QtCore.QSize(16, 16))
  2893.             star_label.setMaximumSize(QtCore.QSize(16, 16))
  2894.             star_label.setText("")
  2895.             star_label.setPixmap(QtGui.QPixmap(":/main_program_icons/media/images/star.png"))
  2896.             star_label.setScaledContents(True)
  2897.             #star_label.setCursor(QtGui.QCursor(Qt.PointingHandCursor))
  2898.             #star_label.clicked.connect(lambda action,player_list_number=player_list_number,rating=rating+i+1:self.display_rating(action,player_list_number,rating,deck))
  2899.             horizontalLayout.addWidget(star_label)
  2900.        
  2901.                            
  2902.         horizontalLayout.setContentsMargins(0, 0, 0, 0)
  2903.         horizontalLayout.setSpacing(0)
  2904.         preview_rating_frame.setStyleSheet("QFrame{border:0px;}")
  2905.         if deck == "deck 1":
  2906.             self.main_self.main_ui.verticalLayout_23.replaceWidget(self.main_self.main_ui.deck_1_rating_frame, preview_rating_frame)
  2907.             self.main_self.main_ui.deck_1_rating_frame = preview_rating_frame
  2908.         else:
  2909.             self.main_self.main_ui.verticalLayout_24.replaceWidget(self.main_self.main_ui.deck_2_rating_frame, preview_rating_frame)
  2910.             self.main_self.main_ui.deck_2_rating_frame = preview_rating_frame
  2911.        
  2912.        
  2913.         if deck=="deck 1":
  2914.             self.deck_1["player-list-item"]["rating"] = rating                 
  2915.            
  2916.            
  2917.         elif deck=="deck 2":
  2918.             self.deck_2["player-list-item"]["rating"] = rating
  2919.            
  2920.         '''
  2921.         #save rating edit
  2922.         if deck=="deck 1":
  2923.             relative_type = self.deck_1["player-list-item"]["type"]
  2924.             relative_number = self.deck_1["player-list-item"]["relative number"]
  2925.         elif deck=="deck 2":
  2926.             relative_type = self.deck_2["player-list-item"]["type"]
  2927.             relative_number = self.deck_2["player-list-item"]["relative number"]
  2928.         item = data.read_items_by_type_and_relative_number(relative_type,relative_number)[0]
  2929.         item["rating"] = rating
  2930.         if relative_type=="sound files":
  2931.             data.edit_sound_file(item)
  2932.         elif relative_type=="sound clips":
  2933.             data.edit_sound_clip(item)
  2934.         elif relative_type=="retransmitions":
  2935.             data.edit_retransmition(item)
  2936.         elif relative_type=="weather news":
  2937.             data.edit_weather_news(item)
  2938.         elif relative_type=="church news":
  2939.             data.edit_church_news(item)
  2940.         elif relative_type=="greek time files":
  2941.             data.edit_greek_time_rating(rating,relative_number)
  2942.         '''
  2943.  
  2944.     def convert_duration_from_milliseconds_to_human(self,duration_milliseconds):
  2945.         total_seconds = int(duration_milliseconds/1000)
  2946.         #1. find how much hours total_seconds are
  2947.         hours = int(total_seconds/(60*60))
  2948.         #2. calculate seconds remaining
  2949.         seconds_remaining = total_seconds-(hours*60*60)
  2950.         #3. find how much minutes seconds_remaining are
  2951.         minutes = int(seconds_remaining/60)
  2952.         #4. recalculate seconds remaining
  2953.         seconds = seconds_remaining-(minutes*60)
  2954.        
  2955.         #add leading zero
  2956.         if(seconds<10):
  2957.             seconds = "0"+str(seconds)
  2958.         if(minutes<10):
  2959.             minutes = "0"+str(minutes)
  2960.         if(hours<10):
  2961.             hours = "0"+str(hours)
  2962.        
  2963.         return str(hours)+":"+str(minutes)+":"+str(seconds)
  2964.        
  2965.     def display_music_clips(self):
  2966.         sound_clips = data.read_sound_clips(10)
  2967.        
  2968.         for i in reversed(range(self.main_self.main_ui.gridLayout_35.count())):
  2969.             self.main_self.main_ui.gridLayout_35.itemAt(i).widget().setParent(None)
  2970.        
  2971.         counter = 0
  2972.         for sound_clip in sound_clips:
  2973.             self.sound_clip_button = QtWidgets.QPushButton()
  2974.             font = QtGui.QFont()
  2975.             font.setPointSize(7)
  2976.             self.sound_clip_button.setFont(font)
  2977.             #self.sound_clip_button.setWordWrap(True)
  2978.             title = sound_clip["title"]#.replace(" ", "\n")
  2979.             self.sound_clip_button.setText(title)
  2980.             self.sound_clip_button.clicked.connect(lambda state,sound_clip_number=sound_clip["number"]:self.play_sound_clip(sound_clip_number))
  2981.             if counter<=4:
  2982.                 self.main_self.main_ui.gridLayout_35.addWidget(self.sound_clip_button,0,counter,1,1)
  2983.             if counter>4:
  2984.                 self.main_self.main_ui.gridLayout_35.addWidget(self.sound_clip_button,1,counter-5,1,1)
  2985.             self.sound_clip_button.setStyleSheet("QPushButton{width:100px;height:30px;}")
  2986.            
  2987.             counter +=1
  2988.        
  2989.     def play_sound_clip(self,sound_clip_number):
  2990.         if self.music_clip_deck["play-status"]!="stopped":
  2991.             self.music_clip_deck["play-status"] = "stopped"
  2992.             self.music_clip_deck_status_changed("stopped")
  2993.             self.papinhio_player.music_clip_deck["play-status"] = "stopped"
  2994.            
  2995.         self.music_clip_deck["player-list-item"] = None
  2996.         self.music_clip_deck["player-list-row"] = None
  2997.        
  2998.         counter = -1
  2999.         for sound_clip in self.papinhio_player.sound_clips:
  3000.             counter = 0
  3001.             if sound_clip["number"] == sound_clip_number:
  3002.                 title = sound_clip["title"]
  3003.                 self.music_clip_deck["total-duration-milliseconds"] = sound_clip["total-duration-milliseconds"]
  3004.                 self.music_clip_deck["total-duration-human"] = self.convert_duration_from_milliseconds_to_human(self.music_clip_deck["total-duration-milliseconds"])
  3005.        
  3006.                 #Update music clip deck
  3007.                 self.main_self.main_ui.music_clip_deck_title.setText("Music clip deck: "+str(title))
  3008.        
  3009.                 self.main_self.main_ui.music_clip_deck_time.setText("00:00:00/"+str(self.music_clip_deck["total-duration-human"]))
  3010.                 self.main_self.main_ui.music_clip_deck_timeline.setMaximum(self.music_clip_deck["total-duration-milliseconds"])
  3011.                 self.main_self.main_ui.music_clip_deck_timeline.setSingleStep(500)
  3012.                 self.main_self.main_ui.music_clip_deck_timeline.setPageStep(1000)
  3013.                 self.main_self.main_ui.music_clip_deck_timeline.setProperty("value", 0)
  3014.                 self.main_self.main_ui.music_clip_deck_timeline.setEnabled(True)
  3015.        
  3016.                 self.music_clip_deck["volume"] = self.main_self.main_ui.music_clip_deck_volume_control.value()
  3017.        
  3018.                 self.music_clip_deck["normalize"] = self.main_self.main_ui.music_clip_normalize.isChecked()
  3019.            
  3020.                 self.music_clip_deck["pan"] = self.main_self.main_ui.music_clip_deck_pan_control.value()
  3021.        
  3022.                 self.music_clip_deck["low-frequency"] = self.main_self.main_ui.music_clip_deck_low_frequency_input.text()
  3023.        
  3024.                 self.music_clip_deck["high-frequency"] = self.main_self.main_ui.music_clip_deck_high_frequency_input.text()
  3025.        
  3026.    
  3027.                 icon3 = QtGui.QIcon()
  3028.                 icon3.addPixmap(QtGui.QPixmap(":/main_program_icons/media/images/play_song.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
  3029.                 self.main_self.main_ui.music_clip_deck_play_pause.setIcon(icon3)
  3030.        
  3031.        
  3032.                 self.papinhio_player.load_sound_clip(sound_clip_number)
  3033.                
  3034.                 return 1
  3035.        
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041. class Microphone(QThread):
  3042.     microphone_segment_ready = pyqtSignal(AudioSegment)
  3043.     def __init__(self):
  3044.         super().__init__()
  3045.        
  3046.         #self.microphone_queue = queue.Queue()
  3047.        
  3048.         #QoS settings
  3049.         self.packet_time = 744
  3050.         self.packet_size = 4104
  3051.         self.new_sample_rate = 44100
  3052.        
  3053.         self.format = pyaudio.paInt16
  3054.         self.channels = 2
  3055.        
  3056.         self.input_device_name = data.read_setting("input device name")[0]["current value"]
  3057.         self.input_device_number = int(data.read_setting("input device number")[0]["current value"])
  3058.        
  3059.         self.p = pyaudio.PyAudio()
  3060.        
  3061.         self.info = self.p.get_host_api_info_by_index(0)
  3062.         self.numdevices = self.info.get('deviceCount')
  3063.        
  3064.         self.input_devices = [[0,0,"Καμία συσκευή μικροφώνου"]]
  3065.                
  3066.         counter = 1
  3067.         for i in range (0,self.numdevices):
  3068.             if self.p.get_device_info_by_host_api_device_index(0,i).get('maxInputChannels')>0:
  3069.                 self.input_devices.append([counter,i,self.p.get_device_info_by_host_api_device_index(0,i).get('name')])
  3070.                 counter += 1
  3071.        
  3072.         self.speackers_deck = {
  3073.             "play-status":"stopped",
  3074.             "volume":100,
  3075.             "normalize":0,
  3076.             "pan":0,
  3077.             "low-frequency":20,
  3078.             "high-frequency":20000
  3079.         }
  3080.  
  3081.     def run(self)
  3082.         for input_device in self.input_devices:
  3083.             if(self.input_device_name==input_device[2]):
  3084.                 self.input_device_index = input_device[1]
  3085.                                        
  3086.                 self.microphone_input_stream = self.p.open(format=pyaudio.paInt16,channels=1,rate=44100,input=True,input_device_index=self.input_device_index)
  3087.                 self.microphone_input_stream.start_stream()
  3088.  
  3089.                 while(True):   
  3090.                     #t1 = time.time()
  3091.                     #speackers deck
  3092.                     if self.speackers_deck["play-status"]=="playing":
  3093.                         microphone_data = self.microphone_input_stream.read(8*int(self.packet_size))#744msec
  3094.                         microphone_slice = AudioSegment(microphone_data, sample_width=2, frame_rate=44100, channels=1)
  3095.                         microphone_slice = AudioSegment.from_mono_audiosegments(microphone_slice, microphone_slice)
  3096.                        
  3097.                         if self.speackers_deck["pan"]!=0:
  3098.                             microphone_slice = microphone_slice.pan(self.speackers_deck["pan"])
  3099.                         if self.speackers_deck["low-frequency"]>20:
  3100.                             microphone_slice = effects.high_pass_filter(microphone_slice, self.speackers_deck["low-frequency"])
  3101.                         if self.speackers_deck["high-frequency"]>20000:
  3102.                             microphone_slice = effects.low_pass_filter(microphone_slice, self.speackers_deck["high-frequency"])
  3103.                         if(self.speackers_deck["volume"]==0):
  3104.                             self.db_volume = -200
  3105.                         else:  
  3106.                             self.db_volume =  20*math.log10(self.speackers_deck["volume"]/100)
  3107.                         microphone_slice = microphone_slice+self.db_volume
  3108.                         #normalize
  3109.                         if(self.speackers_deck["normalize"]==True or self.speackers_deck["normalize"]==1):
  3110.                             microphone_slice = self.normalize_method(microphone_slice,0.1)
  3111.                         self.microphone_segment_ready.emit(microphone_slice)
  3112.                         #self.microphone_queue.put(microphone_slice)
  3113.                     else:
  3114.                         self.speackers_deck["chunk-number"] = 0
  3115.                         self.speackers_deck["current-duration-milliseconds"] = 0
  3116.                         microphone_slice = AudioSegment.empty()
  3117.                         #with self.microphone_queue.mutex:
  3118.                         #   self.microphone_queue.queue.clear()
  3119.                     #t2 = time.time()
  3120.                     #total_time = (t2 - t1)*1000
  3121.                     #if total_time<self.packet_time:
  3122.                     #   time.sleep(total_time/1000)
  3123.                     time.sleep(0.015)
  3124.                    
  3125.                        
  3126.     def normalize_method(self,seg, headroom):
  3127.         peak_sample_val = seg.max
  3128.  
  3129.         # if the max is 0, this audio segment is silent, and can't be normalized
  3130.         if peak_sample_val == 0:
  3131.             return seg
  3132.  
  3133.         target_peak = seg.max_possible_amplitude * utils.db_to_float(-headroom)
  3134.         #target_peak = seg.max_possible_amplitude * (percent_headroom)
  3135.  
  3136.         needed_boost = utils.ratio_to_db(target_peak / peak_sample_val)
  3137.         return seg.apply_gain(needed_boost)
  3138.  
  3139.  
  3140.        
  3141. class Papinhio_Player(QThread):
  3142.     general_deck_status_signal = pyqtSignal(str)
  3143.     general_deck_volume_signal = pyqtSignal(float)
  3144.    
  3145.     deck_1_status_signal = pyqtSignal(str)
  3146.     deck_1_duration_signal = pyqtSignal(int)
  3147.     deck_1_volume_signal = pyqtSignal(float)
  3148.    
  3149.     deck_2_status_signal = pyqtSignal(str)
  3150.     deck_2_duration_signal = pyqtSignal(int)
  3151.     deck_2_volume_signal = pyqtSignal(float)
  3152.    
  3153.     music_clip_deck_status_signal = pyqtSignal(str)
  3154.     music_clip_deck_duration_signal = pyqtSignal(int)
  3155.     music_clip_deck_volume_signal = pyqtSignal(float)
  3156.    
  3157.     speackers_deck_duration_signal = pyqtSignal(int)
  3158.     speackers_deck_volume_signal = pyqtSignal(float)
  3159.    
  3160.     ip_call_1_deck_duration_signal = pyqtSignal(int)
  3161.     ip_call_1_deck_volume_signal = pyqtSignal(float)
  3162.  
  3163.     ip_call_2_deck_duration_signal = pyqtSignal(int)
  3164.     ip_call_2_deck_volume_signal = pyqtSignal(float)
  3165.  
  3166.     ip_call_3_deck_duration_signal = pyqtSignal(int)
  3167.     ip_call_3_deck_volume_signal = pyqtSignal(float)
  3168.    
  3169.     final_slice_ready = pyqtSignal(AudioSegment)
  3170.    
  3171.     def __init__(self,general_deck_dict):
  3172.         super().__init__()
  3173.        
  3174.         #QoS settings
  3175.         self.bit_rate = 128*1024 #128 kb/sec
  3176.         self.packet_time = 744
  3177.         #self.packet_size = int(16384/4)
  3178.         self.packet_size = 4104
  3179.         #self.new_sample_rate = 32768
  3180.         self.new_sample_rate = 44100
  3181.        
  3182.         self.format = pyaudio.paInt16
  3183.         self.channels = 2
  3184.        
  3185.         self.primary_output_device_name = data.read_setting("primary output device name")[0]["current value"]
  3186.         self.primary_output_device_number = int(data.read_setting("primary output device number")[0]["current value"])
  3187.        
  3188.         self.input_device_name = data.read_setting("input device name")[0]["current value"]
  3189.         self.input_device_number = int(data.read_setting("input device number")[0]["current value"])
  3190.        
  3191.         self.p = pyaudio.PyAudio()
  3192.        
  3193.         self.info = self.p.get_host_api_info_by_index(0)
  3194.         self.numdevices = self.info.get('deviceCount')
  3195.        
  3196.         self.output_devices = [[0,0,"Καμία συσκευή αναπαραγωγής ήχου"]]
  3197.         self.input_devices = [[0,0,"Καμία συσκευή μικροφώνου"]]
  3198.        
  3199.         counter = 1
  3200.         for i in range (0,self.numdevices):
  3201.             if self.p.get_device_info_by_host_api_device_index(0,i).get('maxOutputChannels')>0:
  3202.                 self.output_devices.append([counter,i,str(self.p.get_device_info_by_host_api_device_index(0,i).get('name'))])
  3203.                 counter += 1
  3204.                
  3205.         counter = 1
  3206.         for i in range (0,self.numdevices):
  3207.             if self.p.get_device_info_by_host_api_device_index(0,i).get('maxInputChannels')>0:
  3208.                 self.input_devices.append([counter,i,self.p.get_device_info_by_host_api_device_index(0,i).get('name')])
  3209.                 counter += 1
  3210.        
  3211.         sine_segment = generators.Sine(1000).to_audio_segment()
  3212.         sine_segment = sine_segment.set_frame_rate(self.new_sample_rate)
  3213.         sine_segment = sine_segment[500-int(125)-1:500+int(125)]
  3214.         self.silent_segment = sine_segment-200
  3215.        
  3216.         self.general_deck = general_deck_dict
  3217.         self.deck_1 = {
  3218.             "player-list-item":None,
  3219.             "player-list-row":None,
  3220.             "play-status":"stopped",
  3221.             "chunk-number":0,
  3222.             "total-duration-human":"00:00:00",
  3223.             "total-duration-milliseconds":0,
  3224.             "current-duration-milliseconds":0,
  3225.             "muted":False,
  3226.             "volume":100,
  3227.             "normalize":0,
  3228.             "pan":0,
  3229.             "low-frequency":20,
  3230.             "high-frequency":20000,
  3231.             "client":None,
  3232.             "pcm_stream":None
  3233.         }
  3234.        
  3235.         self.deck_2 = {
  3236.             "player-list-item":None,
  3237.             "player-list-row":None,
  3238.             "play-status":"stopped",
  3239.             "chunk-number":0,
  3240.             "total-duration-human":"00:00:00",
  3241.             "total-duration-milliseconds":0,
  3242.             "current-duration-milliseconds":0,
  3243.             "muted":False,
  3244.             "volume":100,
  3245.             "normalize":0,
  3246.             "pan":0,
  3247.             "low-frequency":20,
  3248.             "high-frequency":20000,
  3249.             "client":None,
  3250.             "pcm_stream":None
  3251.         }
  3252.        
  3253.         self.music_clip_deck = {
  3254.             "player-list-item":None,
  3255.             "player-list-row":None,
  3256.             "play-status":"stopped",
  3257.             "chunk-number":0,
  3258.             "total-duration-human":"00:00:00",
  3259.             "total-duration-milliseconds":0,
  3260.             "current-duration-milliseconds":0,
  3261.             "muted":False,
  3262.             "volume":100,
  3263.             "normalize":0,
  3264.             "pan":0,
  3265.             "low-frequency":20,
  3266.             "high-frequency":20000
  3267.         }
  3268.        
  3269.         self.speackers_deck = {
  3270.             "play-status":"stopped",
  3271.             "volume":100,
  3272.             "normalize":0,
  3273.             "pan":0,
  3274.             "low-frequency":20,
  3275.             "high-frequency":20000
  3276.         }
  3277.        
  3278.         self.microphone_queue = queue.Queue()
  3279.        
  3280.         self.ip_call_1 = {
  3281.             "call-status":"stopped",
  3282.             "volume":100,
  3283.             "normalize":0,
  3284.             "pan":0,
  3285.             "low-frequency":20,
  3286.             "high-frequency":20000,
  3287.         }
  3288.        
  3289.         self.ip_call_2 = {
  3290.             "call-status":"stopped",
  3291.             "volume":100,
  3292.             "normalize":0,
  3293.             "pan":0,
  3294.             "low-frequency":20,
  3295.             "high-frequency":20000
  3296.         }
  3297.        
  3298.         self.ip_call_3 = {
  3299.             "call-status":"stopped",
  3300.             "volume":100,
  3301.             "normalize":0,
  3302.             "pan":0,
  3303.             "low-frequency":20,
  3304.             "high-frequency":20000
  3305.         }
  3306.        
  3307.         self.record_status = "stopped"
  3308.        
  3309.         self.prepare_sound_clips()
  3310.                
  3311.     def prepare_sound_clips(self):
  3312.         self.sound_clips = []
  3313.         sound_clips_items = data.read_sound_clips(10)
  3314.         for sound_clip in sound_clips_items:
  3315.             saved_path = sound_clip["saved path"]
  3316.             self.sound_clip_dict = {}
  3317.             self.sound_clip_dict["audio-segment"] = AudioSegment.from_file(saved_path,format="mp3",frame_rate=44100, channels=2, sample_width=2)
  3318.             self.sound_clip_dict["total-duration-milliseconds"] = sound_clip["duration milliseconds"]
  3319.             self.sound_clip_dict["audio-segment-normalized"] = self.normalize_method(self.sound_clip_dict["audio-segment"],0.1)
  3320.  
  3321.             self.sound_clip_dict["audio-segment"] = self.sound_clip_dict["audio-segment"].set_frame_rate(self.new_sample_rate)
  3322.             self.sound_clip_dict["audio-segment-normalized"] = self.sound_clip_dict["audio-segment-normalized"].set_frame_rate(self.new_sample_rate)
  3323.  
  3324.        
  3325.             #self.sound_clip_dict["chunk-number"] = 0
  3326.             #self.sound_clip_dict["current-duration-milliseconds"] = 0
  3327.             self.sound_clip_dict["number"] = sound_clip["number"]
  3328.             self.sound_clip_dict["title"] = sound_clip["title"]
  3329.             self.sound_clips.append(self.sound_clip_dict)
  3330.            
  3331.     def load_sound_clip(self,sound_clip_number):
  3332.         for sound_clip in self.sound_clips:
  3333.             if sound_clip["number"]==sound_clip_number:
  3334.                 self.music_clip_deck["play-status"] = "stopped"
  3335.                 self.music_clip_deck["chunk-number"] = 0
  3336.                 self.music_clip_deck["current-duration-milliseconds"] = 0
  3337.                 self.music_clip_deck["audio-segment"] = sound_clip["audio-segment"]
  3338.                 self.music_clip_deck["total-duration-milliseconds"] = sound_clip["total-duration-milliseconds"]
  3339.                 self.music_clip_deck["audio-segment-normalized"] = self.normalize_method(self.music_clip_deck["audio-segment"],0.1)
  3340.                 self.music_clip_deck["play-status"] = "playing"
  3341.                 break
  3342.                            
  3343.     def run(self)
  3344.         for output_device in self.output_devices:
  3345.             if(self.primary_output_device_name==output_device[2]):
  3346.                 self.output_device_index = output_device[1]
  3347.                 for input_device in self.input_devices:
  3348.                     if(self.input_device_name==input_device[2]):
  3349.                         self.input_device_index = input_device[1]
  3350.                        
  3351.                         self.stream = self.p.open(format=pyaudio.paInt16,channels=2,rate=self.new_sample_rate,output=True,output_device_index=self.output_device_index,frames_per_buffer=self.packet_size)
  3352.                         self.stream.start_stream()
  3353.                        
  3354.                         self.microphone_input_stream = self.p.open(format=pyaudio.paInt16,channels=1,rate=44100,input=True,input_device_index=self.input_device_index)
  3355.                         self.microphone_input_stream.start_stream()
  3356.  
  3357.         while(True):   
  3358.             #t1 = time.time()
  3359.             deck_1_slice = AudioSegment.empty()
  3360.             if self.deck_1["play-status"]=="playing":
  3361.                 if self.deck_1["current-duration-milliseconds"]>self.deck_1["total-duration-milliseconds"]:
  3362.                     self.deck_1["play-status"] = "stopped"
  3363.                     self.deck_1_status_signal.emit("stopped")
  3364.                     self.deck_1["chunk-number"] = 0
  3365.                     self.deck_1["current-duration-milliseconds"] = 0
  3366.                 if self.deck_1["play-status"]=="playing":
  3367.                     if self.deck_1["player-list-item"]["type"] != "retransmitions":
  3368.                         if(self.deck_1["normalize"]==False or self.deck_1["normalize"]==0):
  3369.                             if((self.deck_1["chunk-number"]+1)*(self.packet_time)<=self.deck_1["total-duration-milliseconds"]):
  3370.                                 deck_1_slice = self.deck_1["audio-segment"][self.deck_1["chunk-number"]*(self.packet_time):(self.deck_1["chunk-number"]+1)*(self.packet_time)]
  3371.                             else:
  3372.                                 if((self.deck_1["chunk-number"])*(self.packet_time)<self.deck_1["total-duration-milliseconds"]):
  3373.                                     deck_1_slice = self.deck_1["audio-segment"][self.deck_1["chunk-number"]*(self.packet_time):]
  3374.                                 else:
  3375.                                     deck_1_slice = AudioSegment.empty()
  3376.                         else:
  3377.                             if((self.deck_1["chunk-number"]+1)*(self.packet_time)<=self.deck_1["total-duration-milliseconds"]):
  3378.                                 deck_1_slice = self.deck_1["audio-segment-normalized"][self.deck_1["chunk-number"]*(self.packet_time):(self.deck_1["chunk-number"]+1)*(self.packet_time)]
  3379.                             else:
  3380.                                 if((self.deck_1["chunk-number"])*(self.packet_time)<self.deck_1["total-duration-milliseconds"]):
  3381.                                     deck_1_slice = self.deck_1["audio-segment-normalized"][self.deck_1["chunk-number"]*(self.packet_time):]
  3382.                                 else:
  3383.                                     deck_1_slice = AudioSegment.empty()
  3384.                     else:
  3385.                         if "radio-url" in self.deck_1:
  3386.                             if self.deck_1["radio-url"] is not None:
  3387.                                 if self.deck_1["client"] is None and self.deck_1["pcm_stream"] is None:
  3388.                                     self.deck_1["client"] = miniaudio.IceCastClient(self.deck_1["radio-url"])
  3389.                                     self.deck_1["pcm_stream"] = MiniaudioDecoderPcmStream(self.deck_1["client"].audio_format,self.deck_1["client"])
  3390.                                
  3391.                                 deck_1_slice = AudioSegment.empty()
  3392.                                 for i in range(0,8):
  3393.                                     audio = self.deck_1["pcm_stream"].read(int(self.packet_size))
  3394.                                     deck_1_slice_part = AudioSegment(audio, sample_width=2, frame_rate=self.new_sample_rate, channels=2)
  3395.                                     deck_1_slice = deck_1_slice+deck_1_slice_part
  3396.                                
  3397.                                 #audio = self.deck_1["pcm_stream"].read(int(self.packet_size))
  3398.                                 #deck_1_slice = AudioSegment(audio, sample_width=2, frame_rate=self.new_sample_rate, channels=2)
  3399.                                 #print(len(deck_1_slice))
  3400.                                 deck_1_slice.set_frame_rate(self.new_sample_rate)
  3401.                            
  3402.                     if self.deck_1["pan"]!=0:
  3403.                         deck_1_slice = deck_1_slice.pan(self.deck_1["pan"])
  3404.                     if self.deck_1["low-frequency"]>20:
  3405.                         deck_1_slice = effects.high_pass_filter(deck_1_slice, self.deck_1["low-frequency"])
  3406.                     if self.deck_1["high-frequency"]>20000:
  3407.                         deck_1_slice = effects.low_pass_filter(deck_1_slice, self.deck_1["high-frequency"])
  3408.                     if(self.deck_1["volume"]==0):
  3409.                         self.db_volume = -200
  3410.                     else:  
  3411.                         self.db_volume =  20*math.log10(self.deck_1["volume"]/100)
  3412.                     deck_1_slice = deck_1_slice+self.db_volume
  3413.                 else:
  3414.                     self.deck_1["chunk-number"] = 0
  3415.                     deck_1_slice = AudioSegment.empty()
  3416.             elif self.deck_1["play-status"] == "stopped":
  3417.                     self.deck_1["chunk-number"] = 0
  3418.                     self.deck_1["current-duration-milliseconds"] = 0
  3419.                     deck_1_slice = AudioSegment.empty()
  3420.            
  3421.             #deck_1_volume_strength
  3422.             average_data_value = deck_1_slice.max
  3423.             normalized_value = abs(average_data_value)/deck_1_slice.max_possible_amplitude
  3424.             if normalized_value>1:
  3425.                 normalized_value = 1
  3426.             self.deck_1_volume_signal.emit(normalized_value)
  3427.            
  3428.            
  3429.             #deck 2
  3430.             deck_2_slice = AudioSegment.empty()
  3431.             if self.deck_2["play-status"]=="playing":
  3432.