refactor(expanded_player): reuse mmss formatter
This commit is contained in:
1 file changed
+2
-9
@@ -12,6 +12,7 @@ from fabric.widgets.wayland import WaylandWindow as Window
|
|||||||
|
|
||||||
from services.mpris import PlayerManager, PlayerService
|
from services.mpris import PlayerManager, PlayerService
|
||||||
from shared.widgets.player_box_stack import BasePlayerBoxStack
|
from shared.widgets.player_box_stack import BasePlayerBoxStack
|
||||||
|
from utils.functions import format_mmss
|
||||||
from utils.gtk_utils import svg_file
|
from utils.gtk_utils import svg_file
|
||||||
from window.controlcenter.player import (
|
from window.controlcenter.player import (
|
||||||
PLAYER_FALLBACK_ART,
|
PLAYER_FALLBACK_ART,
|
||||||
@@ -408,15 +409,7 @@ class PlayerBox(Box):
|
|||||||
def length_str(self, length):
|
def length_str(self, length):
|
||||||
if length is None or length <= 0:
|
if length is None or length <= 0:
|
||||||
return "0:00"
|
return "0:00"
|
||||||
length_seconds = length / 1000000
|
return format_mmss(length / 1000000)
|
||||||
hours = int(length_seconds // 3600)
|
|
||||||
minutes = int((length_seconds % 3600) // 60)
|
|
||||||
seconds = int(length_seconds % 60)
|
|
||||||
return (
|
|
||||||
f"{hours}:{minutes:02d}:{seconds:02d}"
|
|
||||||
if hours > 0
|
|
||||||
else f"{minutes}:{seconds:02d}"
|
|
||||||
)
|
|
||||||
|
|
||||||
def _on_metadata(self, *args):
|
def _on_metadata(self, *args):
|
||||||
if self.exit or self.player is None:
|
if self.exit or self.player is None:
|
||||||
|
|||||||
Reference in new issue
Block a user