Port configured in settings
This commit is contained in:
@@ -119,6 +119,9 @@ class LibremsonicApp(Gtk.Application):
|
||||
'value-changed', self.on_volume_change)
|
||||
self.window.connect('key-press-event', self.on_window_key_press)
|
||||
|
||||
self.window.show_all()
|
||||
self.window.present()
|
||||
|
||||
# Load the configuration and update the UI with the curent server, if
|
||||
# it exists.
|
||||
self.state.load()
|
||||
@@ -505,5 +508,5 @@ class LibremsonicApp(Gtk.Application):
|
||||
CacheManager.save_play_queue,
|
||||
id=self.state.play_queue,
|
||||
current=self.state.current_song.id,
|
||||
position=math.floor(position * 1000),
|
||||
position=math.floor(position * 1000) if position else None,
|
||||
)
|
||||
|
@@ -337,7 +337,6 @@ class CacheManager(metaclass=Singleton):
|
||||
force: bool = False,
|
||||
) -> Future:
|
||||
def do_get_artist() -> Union[ArtistWithAlbumsID3, Child]:
|
||||
# TODO: implement the non-ID3 version
|
||||
cache_name = self.id3ify('artist_details')
|
||||
server_fn = (self.server.get_artist if self.browse_by_tags else
|
||||
self.server.get_music_directory)
|
||||
@@ -446,7 +445,6 @@ class CacheManager(metaclass=Singleton):
|
||||
force: bool = False,
|
||||
) -> Future:
|
||||
def do_get_album() -> Union[AlbumWithSongsID3, Child]:
|
||||
# TODO: implement the non-ID3 version
|
||||
cache_name = self.id3ify('album_details')
|
||||
server_fn = (self.server.get_album if self.browse_by_tags else
|
||||
self.server.get_music_directory)
|
||||
@@ -492,9 +490,8 @@ class CacheManager(metaclass=Singleton):
|
||||
before_download: Callable[[], None],
|
||||
on_song_download_complete: Callable[[int], None],
|
||||
) -> Future:
|
||||
# TODO handle application close somehow. I think we will need to
|
||||
# raise some sort of an exception, not sure.
|
||||
def do_download_song(song_id):
|
||||
# Prevents further songs from being downloaded.
|
||||
if CacheManager.should_exit:
|
||||
return
|
||||
|
||||
|
@@ -44,6 +44,7 @@ class AppConfiguration:
|
||||
download_on_stream: bool = True # also download when streaming a song
|
||||
prefetch_amount: int = 3
|
||||
concurrent_download_limit: int = 5
|
||||
port_number: int = 8080
|
||||
|
||||
def to_json(self):
|
||||
# TODO can we simplify?
|
||||
@@ -57,6 +58,7 @@ class AppConfiguration:
|
||||
'download_on_stream': self.download_on_stream,
|
||||
'prefetch_amount': self.prefetch_amount,
|
||||
'concurrent_download_limit': self.concurrent_download_limit,
|
||||
'port_number': self.port_number,
|
||||
}
|
||||
|
||||
@property
|
||||
|
@@ -230,8 +230,19 @@ class ChromecastPlayer(Player):
|
||||
self.chromecast.wait()
|
||||
print(f'Using: {self.chromecast.device.friendly_name}')
|
||||
|
||||
def __init__(self, *args):
|
||||
super().__init__(*args)
|
||||
def __init__(
|
||||
self,
|
||||
on_timepos_change: Callable[[float], None],
|
||||
on_track_end: Callable[[], None],
|
||||
on_player_event: Callable[[PlayerEvent], None],
|
||||
config: AppConfiguration,
|
||||
):
|
||||
super().__init__(
|
||||
on_timepos_change,
|
||||
on_track_end,
|
||||
on_player_event,
|
||||
config,
|
||||
)
|
||||
self._timepos = None
|
||||
self.time_incrementor_running = False
|
||||
self._can_hotswap_source = False
|
||||
@@ -250,8 +261,9 @@ class ChromecastPlayer(Player):
|
||||
except OSError:
|
||||
self.host_ip = None
|
||||
|
||||
# TODO make the port come from the app config
|
||||
self.server_thread = ChromecastPlayer.ServerThread('0.0.0.0', 8080)
|
||||
self.port = config.port_number
|
||||
self.server_thread = ChromecastPlayer.ServerThread(
|
||||
'0.0.0.0', self.port)
|
||||
self.server_thread.start()
|
||||
|
||||
def on_new_cast_status(self, status):
|
||||
@@ -289,7 +301,7 @@ class ChromecastPlayer(Player):
|
||||
while True:
|
||||
if not self.playing:
|
||||
self.time_incrementor_running = False
|
||||
raise Exception()
|
||||
return
|
||||
|
||||
self._timepos += 0.5
|
||||
self.on_timepos_change(self._timepos)
|
||||
@@ -320,7 +332,7 @@ class ChromecastPlayer(Player):
|
||||
def play_media(self, file_or_url: str, progress: float, song: Child):
|
||||
stream_scheme = urlparse(file_or_url).scheme
|
||||
if not stream_scheme:
|
||||
file_or_url = f'http://{self.host_ip}:8080/song/{song.id}'
|
||||
file_or_url = f'http://{self.host_ip}:{self.port}/song/{song.id}'
|
||||
|
||||
cover_art_url = CacheManager.get_cover_art_url(song.id, 1000)
|
||||
self.chromecast.media_controller.play_media(
|
||||
|
@@ -327,10 +327,11 @@ class PlayerControls(Gtk.ActionBar):
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
# Device button (for chromecast)
|
||||
play_queue_button = util.button_with_icon(
|
||||
# TODO need icon
|
||||
device_button = util.button_with_icon(
|
||||
'view-list-symbolic', icon_size=Gtk.IconSize.LARGE_TOOLBAR)
|
||||
play_queue_button.connect('clicked', self.on_device_click)
|
||||
box.pack_start(play_queue_button, False, True, 5)
|
||||
device_button.connect('clicked', self.on_device_click)
|
||||
box.pack_start(device_button, False, True, 5)
|
||||
|
||||
self.device_popover = Gtk.PopoverMenu(name='device-popover')
|
||||
|
||||
|
@@ -8,7 +8,9 @@ from .common.edit_form_dialog import EditFormDialog
|
||||
class SettingsDialog(EditFormDialog):
|
||||
title: str = 'Settings'
|
||||
initial_size = (450, 250)
|
||||
text_fields = []
|
||||
text_fields = [
|
||||
('Port Number (will take effect on restart)', 'port_number', False),
|
||||
]
|
||||
boolean_fields = [
|
||||
('Show headers on song lists', 'show_headers'),
|
||||
('Always stream songs', 'always_stream'),
|
||||
|
Reference in New Issue
Block a user