Skip to content

Commit

Permalink
add transcode progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiko2k committed Apr 12, 2019
1 parent 93c3ff0 commit 08d5f9a
Showing 1 changed file with 72 additions and 19 deletions.
91 changes: 72 additions & 19 deletions tauon.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import pickle
import shutil

t_version = "v4.1.0"
t_version = "v4.1.1"
t_title = 'Tauon Music Box'
t_id = 'tauonmb'

Expand Down Expand Up @@ -532,6 +532,8 @@ def _(message):

loading_in_progress = False

core_use = 0

random_mode = False
repeat_mode = False

Expand Down Expand Up @@ -1073,6 +1075,9 @@ def __init__(self):

self.auto_play_import = False

self.transcoding_batch_total = 0
self.transcoding_bach_done = 0


gui = GuiVar()

Expand Down Expand Up @@ -13035,8 +13040,6 @@ def toggle_playlist_break():

# ---------------------------------------------------------------------------------------

core_use = 0


def transcode_single(item, manual_directroy=None, manual_name=None):
global core_use
Expand Down Expand Up @@ -13128,7 +13131,11 @@ def transcode_single(item, manual_directroy=None, manual_name=None):
os.rename(target_out, output + out_line + "." + codec)
else:
os.rename(target_out, output + manual_name + "." + codec)


gui.transcoding_bach_done += 1
core_use -= 1
gui.update += 1


# ---------------------
Expand Down Expand Up @@ -14544,6 +14551,9 @@ def cache_paths():
cores = os.cpu_count()

total = len(folder_items)
gui.transcoding_batch_total = total
gui.transcoding_bach_done = 0

q = 0
while True:

Expand All @@ -14555,12 +14565,14 @@ def cache_paths():
loaderThread.start()
# transcode_single([folder_items[q], folder_name])
q += 1
time.sleep(0.5)
gui.update += 1
time.sleep(0.05)
if gui.tc_cancel:
while core_use > 0:
time.sleep(1)
break
if q == len(folder_items) and core_use == 0:
gui.update += 1
break

# else:
Expand Down Expand Up @@ -17086,23 +17098,26 @@ def render(self):
elif plex.scanning:
text = "Accessing PLEX library..."
bg = [229, 160, 13, 255]
elif transcode_list:
# if key_ctrl_down and key_c_press:
# del transcode_list[1:]
# gui.tc_cancel = True
if right_click and coll([x, y, 180 * gui.scale, 18 * gui.scale]):
cancel_menu.activate(position=(x + 20 * gui.scale, y + 23 * gui.scale))

text = "Transcoding... " + str(len(transcode_list)) + " Folder Remaining " + transcode_state
if len(transcode_list) > 1:
text = "Transcoding... " + str(len(transcode_list)) + " Folders Remaining " + transcode_state
if not gui.tc_cancel:
bg = colours.status_info_text
else:
text = "Stopping transcode..."
# elif transcode_list:
# # if key_ctrl_down and key_c_press:
# # del transcode_list[1:]
# # gui.tc_cancel = True
# if right_click and coll([x, y, 180 * gui.scale, 18 * gui.scale]):
# cancel_menu.activate(position=(x + 20 * gui.scale, y + 23 * gui.scale))
#
# text = "Transcoding... " + str(len(transcode_list)) + " Folder Remaining " + transcode_state
# if len(transcode_list) > 1:
# text = "Transcoding... " + str(len(transcode_list)) + " Folders Remaining " + transcode_state
# if not gui.tc_cancel:
# bg = colours.status_info_text
# else:
# text = "Stopping transcode..."
# elif pctl.join_broadcast and pctl.broadcast_active:
# text = "Streaming Synced"
# bg = [60, 75, 220, 255] # colours.streaming_text
elif transcode_list and gui.tc_cancel:
bg = [150, 150, 150, 255]
text = "Stopping transcode..."
elif pctl.encoder_pause == 1 and pctl.broadcast_active:
text = "Streaming Paused"
bg = colours.streaming_text
Expand All @@ -17117,6 +17132,44 @@ def render(self):
x += ddt.draw_text((x, y), text, bg, 311)
# x += ddt.get_text_w(text, 11)

elif transcode_list:
bg = colours.status_info_text
# if key_ctrl_down and key_c_press:
# del transcode_list[1:]
# gui.tc_cancel = True
if right_click and coll([x, y, 180 * gui.scale, 18 * gui.scale]):
cancel_menu.activate(position=(x + 20 * gui.scale, y + 23 * gui.scale))


w = 100 * gui.scale
x += ddt.draw_text((x, y), "Transcoding", bg, 311) + 8 * gui.scale


if gui.transcoding_batch_total:

yy = y + 4 * gui.scale
h = 9 * gui.scale
box = [x, yy, w, h]
ddt.rect_r(box, [100, 100, 100, 255])

done = round(gui.transcoding_bach_done / gui.transcoding_batch_total * 100)
doing = round(core_use / gui.transcoding_batch_total * 100)

ddt.rect_r([x, yy, done, h], [80, 80, 80, 255], True)

ddt.rect_r([x + done, yy, doing, h], [69, 69, 69, 100], True)

x += w + 8 * gui.scale


text = str(len(transcode_list)) + " Folder Remaining " + transcode_state
if len(transcode_list) > 1:
text = str(len(transcode_list)) + " Folders Remaining " + transcode_state

x += ddt.draw_text((x, y), text, bg, 311) + 8 * gui.scale



elif pctl.broadcast_active:
text = "Now Streaming:"
ddt.draw_text((x, y), text, [95, 110, 230, 255], 311) # [70, 85, 230, 255]
Expand Down Expand Up @@ -23179,7 +23232,7 @@ def test_show_add_home_music():
SDL_Delay(3)
power = 1000

if mouse_wheel or k_input or gui.pl_update or gui.update or top_panel.adds: # or mouse_moved:
if mouse_wheel or k_input or gui.pl_update or gui.update or top_panel.adds or transcode_list: # or mouse_moved:
power = 1000

if mouse_down:
Expand Down

0 comments on commit 08d5f9a

Please sign in to comment.