Compare commits
5 Commits
cb2017e953
...
dcab21bdde
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dcab21bdde | ||
|
|
cd04ec6339 | ||
|
|
a0a2903706 | ||
|
|
da267562ea | ||
|
|
2ca1d30609 |
@ -79,7 +79,6 @@ class Config(object):
|
|||||||
SCROLL_TOP_MARGIN = 3
|
SCROLL_TOP_MARGIN = 3
|
||||||
TEXT_NO_TRACK_NO_NOTE = "[Section header]"
|
TEXT_NO_TRACK_NO_NOTE = "[Section header]"
|
||||||
TOD_TIME_FORMAT = "%H:%M:%S"
|
TOD_TIME_FORMAT = "%H:%M:%S"
|
||||||
TIMER_MS = 10
|
|
||||||
TRACK_TIME_FORMAT = "%H:%M:%S"
|
TRACK_TIME_FORMAT = "%H:%M:%S"
|
||||||
VOLUME_VLC_DEFAULT = 75
|
VOLUME_VLC_DEFAULT = 75
|
||||||
VOLUME_VLC_DROP3db = 65
|
VOLUME_VLC_DROP3db = 65
|
||||||
|
|||||||
@ -59,7 +59,7 @@ from dbconfig import (
|
|||||||
scoped_session,
|
scoped_session,
|
||||||
)
|
)
|
||||||
import helpers
|
import helpers
|
||||||
import icons_rc
|
import icons_rc # noqa F401
|
||||||
import music
|
import music
|
||||||
from models import Base, Carts, Playdates, PlaylistRows, Playlists, Settings, Tracks
|
from models import Base, Carts, Playdates, PlaylistRows, Playlists, Settings, Tracks
|
||||||
from config import Config
|
from config import Config
|
||||||
@ -319,8 +319,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.setupUi(self)
|
self.setupUi(self)
|
||||||
|
|
||||||
self.timer: QTimer = QTimer()
|
self.timer10: QTimer = QTimer()
|
||||||
self.clock_counter: int = 0
|
self.timer500: QTimer = QTimer()
|
||||||
|
self.timer1000: QTimer = QTimer()
|
||||||
|
|
||||||
self.music: music.Music = music.Music()
|
self.music: music.Music = music.Music()
|
||||||
self.playing: bool = False
|
self.playing: bool = False
|
||||||
@ -360,7 +361,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.carts_init()
|
self.carts_init()
|
||||||
self.enable_play_next_controls()
|
self.enable_play_next_controls()
|
||||||
self.clock_counter = 0
|
self.clock_counter = 0
|
||||||
self.timer.start(Config.TIMER_MS)
|
self.timer10.start(10)
|
||||||
|
self.timer500.start(500)
|
||||||
|
self.timer1000.start(1000)
|
||||||
self.connect_signals_slots()
|
self.connect_signals_slots()
|
||||||
|
|
||||||
def about(self) -> None:
|
def about(self) -> None:
|
||||||
@ -671,7 +674,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.tabBar.tabMoved.connect(self.move_tab)
|
self.tabBar.tabMoved.connect(self.move_tab)
|
||||||
self.txtSearch.returnPressed.connect(self.search_playlist_return)
|
self.txtSearch.returnPressed.connect(self.search_playlist_return)
|
||||||
|
|
||||||
self.timer.timeout.connect(self.tick)
|
self.timer10.timeout.connect(self.tick_10ms)
|
||||||
|
self.timer500.timeout.connect(self.tick_500ms)
|
||||||
|
self.timer1000.timeout.connect(self.tick_1000ms)
|
||||||
|
|
||||||
def create_playlist(
|
def create_playlist(
|
||||||
self, session: scoped_session, playlist_name: Optional[str] = None
|
self, session: scoped_session, playlist_name: Optional[str] = None
|
||||||
@ -812,8 +817,8 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
- Enable controls
|
- Enable controls
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Set flag to say we're not playing a track so that tick()
|
# Set flag to say we're not playing a track so that timer ticks
|
||||||
# doesn't see player=None and kick off end-of-track actions
|
# don't see player=None and kick off end-of-track actions
|
||||||
self.playing = False
|
self.playing = False
|
||||||
|
|
||||||
# Tell playlist_tab track has finished
|
# Tell playlist_tab track has finished
|
||||||
@ -831,8 +836,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# Reset clocks
|
# Reset clocks
|
||||||
self.frame_fade.setStyleSheet("")
|
self.frame_fade.setStyleSheet("")
|
||||||
self.frame_silent.setStyleSheet("")
|
self.frame_silent.setStyleSheet("")
|
||||||
self.label_elapsed_timer.setText("00:00")
|
self.label_elapsed_timer.setText("00:00 / 00:00")
|
||||||
self.label_end_timer.setText("00:00")
|
|
||||||
self.label_fade_timer.setText("00:00")
|
self.label_fade_timer.setText("00:00")
|
||||||
self.label_silent_timer.setText("00:00")
|
self.label_silent_timer.setText("00:00")
|
||||||
|
|
||||||
@ -1395,6 +1399,12 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
)
|
)
|
||||||
self.play_next(self.previous_track_position)
|
self.play_next(self.previous_track_position)
|
||||||
|
|
||||||
|
# Adjust track info so that clocks and graph are correct.
|
||||||
|
# Easiest way is to fake the start time.
|
||||||
|
if self.current_track.start_time and self.current_track.duration:
|
||||||
|
elapsed_ms = self.current_track.duration * self.previous_track_position
|
||||||
|
self.current_track.start_time -= timedelta(milliseconds=elapsed_ms)
|
||||||
|
|
||||||
# If a track was playing when we were called, get details to
|
# If a track was playing when we were called, get details to
|
||||||
# set it as the next track
|
# set it as the next track
|
||||||
if playing_track:
|
if playing_track:
|
||||||
@ -1668,24 +1678,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
self.next_track.playlist_tab, QColor(Config.COLOUR_NEXT_TAB)
|
self.next_track.playlist_tab, QColor(Config.COLOUR_NEXT_TAB)
|
||||||
)
|
)
|
||||||
|
|
||||||
def tick(self) -> None:
|
|
||||||
"""
|
|
||||||
Called every Config.TIMER_MS milliseconds. Call periodic functions
|
|
||||||
as required.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Get current number of milliseconds
|
|
||||||
self.clock_counter += Config.TIMER_MS
|
|
||||||
self.clock_counter %= 1000
|
|
||||||
|
|
||||||
# Call periodic functions
|
|
||||||
if self.clock_counter % 10 == 0:
|
|
||||||
self.tick_10ms()
|
|
||||||
if self.clock_counter % 500 == 0:
|
|
||||||
self.tick_500ms()
|
|
||||||
if self.clock_counter == 0:
|
|
||||||
self.tick_1000ms()
|
|
||||||
|
|
||||||
def tick_10ms(self) -> None:
|
def tick_10ms(self) -> None:
|
||||||
"""
|
"""
|
||||||
Called every 10ms
|
Called every 10ms
|
||||||
@ -1716,6 +1708,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
Called every 1000ms
|
Called every 1000ms
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Ensure preview button is reset if preview finishes playing
|
||||||
|
self.btnPreview.setChecked(mixer.music.get_busy())
|
||||||
|
|
||||||
# Only update play clocks once a second so that their updates
|
# Only update play clocks once a second so that their updates
|
||||||
# are synchronised (otherwise it looks odd)
|
# are synchronised (otherwise it looks odd)
|
||||||
|
|
||||||
@ -1739,7 +1734,6 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
playtime = self.get_playtime()
|
playtime = self.get_playtime()
|
||||||
time_to_fade = self.current_track.fade_at - playtime
|
time_to_fade = self.current_track.fade_at - playtime
|
||||||
time_to_silence = self.current_track.silence_at - playtime
|
time_to_silence = self.current_track.silence_at - playtime
|
||||||
time_to_end = self.current_track.duration - playtime
|
|
||||||
|
|
||||||
# Elapsed time
|
# Elapsed time
|
||||||
self.label_elapsed_timer.setText(
|
self.label_elapsed_timer.setText(
|
||||||
@ -1754,15 +1748,15 @@ class Window(QMainWindow, Ui_MainWindow):
|
|||||||
# If silent in the next 5 seconds, put warning colour on
|
# If silent in the next 5 seconds, put warning colour on
|
||||||
# time to silence box and enable play controls
|
# time to silence box and enable play controls
|
||||||
if time_to_silence <= 5500:
|
if time_to_silence <= 5500:
|
||||||
self.frame_silent.setStyleSheet(
|
css_silence = f"background: {Config.COLOUR_ENDING_TIMER}"
|
||||||
f"background: {Config.COLOUR_ENDING_TIMER}"
|
if self.frame_silent.styleSheet() != css_silence:
|
||||||
)
|
self.frame_silent.setStyleSheet(css_silence)
|
||||||
self.enable_play_next_controls()
|
self.enable_play_next_controls()
|
||||||
# Set warning colour on time to silence box when fade starts
|
# Set warning colour on time to silence box when fade starts
|
||||||
elif time_to_fade <= 500:
|
elif time_to_fade <= 500:
|
||||||
self.frame_silent.setStyleSheet(
|
css_fade = f"background: {Config.COLOUR_WARNING_TIMER}"
|
||||||
f"background: {Config.COLOUR_WARNING_TIMER}"
|
if self.frame_silent.styleSheet() != css_fade:
|
||||||
)
|
self.frame_silent.setStyleSheet(css_fade)
|
||||||
# Five seconds before fade starts, set warning colour on
|
# Five seconds before fade starts, set warning colour on
|
||||||
# time to silence box and enable play controls
|
# time to silence box and enable play controls
|
||||||
elif time_to_fade <= 5500:
|
elif time_to_fade <= 5500:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user