diff --git a/wobuzz/command_line.py b/wobuzz/command_line.py new file mode 100644 index 0000000..d234407 --- /dev/null +++ b/wobuzz/command_line.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 + +import sys +import argparse +from main import Wobuzz + + +description = "A music player made by The Wobbler." + +parser = argparse.ArgumentParser(description=description) + +parser.add_argument("track", nargs="*", help="Plays audio files the from given paths.", metavar="TRACKS") +parser.add_argument("-p", "--playlist", help="Imports a playlist from the given path.", metavar="PLAYLIST_PATH") + +arguments = parser.parse_args() + +app = Wobuzz() + +if arguments.playlist: + print(arguments.playlist) + app.player.current_playlist.load_from_m3u(arguments.playlist) + +if arguments.track: + print(arguments.track) + app.player.current_playlist.load_from_paths(arguments.track) + +sys.exit(app.qt_app.exec()) + diff --git a/wobuzz/gui_communication/track_control.py b/wobuzz/gui_communication/track_control.py index d6b96d9..79995d7 100644 --- a/wobuzz/gui_communication/track_control.py +++ b/wobuzz/gui_communication/track_control.py @@ -43,6 +43,7 @@ class TrackControl: def stop(self): if self.app.player.current_playlist.has_tracks(): self.app.player.stop() + self.track_control.toggle_play_button.setIcon(self.play_icon) def next_track(self): if self.app.player.current_playlist.has_tracks(): diff --git a/wobuzz/main.py b/wobuzz/main.py index 829f1a6..ba226d9 100644 --- a/wobuzz/main.py +++ b/wobuzz/main.py @@ -23,11 +23,6 @@ class Wobuzz: self.gui = GUI(self) self.gui_communication = GUICommunication(self) - track_paths = sys.argv[1:] - - if track_paths: - self.player.load_tracks_from_paths(track_paths) - def on_settings_change(self, key, value): self.gui_communication.on_settings_change(key, value) diff --git a/wobuzz/player/player.py b/wobuzz/player/player.py index 8fd2bf6..39cdda2 100644 --- a/wobuzz/player/player.py +++ b/wobuzz/player/player.py @@ -27,17 +27,6 @@ class Player: self.current_sound = None self.current_sound_duration = 0 - def load_tracks_from_paths(self, track_paths: list[str]): - """ - Load tracks from list of paths. - """ - - self.current_playlist = Playlist(self.app) - self.current_playlist.load_from_paths(track_paths) - - self.current_sound = self.current_playlist.current_track.sound - self.current_sound_duration = self.current_playlist.current_track.duration - def play(self): self.music_channel.play(self.current_sound) @@ -61,6 +50,7 @@ class Player: self.play() self.track_progress.start() + self.app.gui_communication.on_track_start() def pause(self): self.music_channel.pause() diff --git a/wobuzz/player/playlist.py b/wobuzz/player/playlist.py index afb2f62..477e7b0 100644 --- a/wobuzz/player/playlist.py +++ b/wobuzz/player/playlist.py @@ -43,6 +43,8 @@ class Playlist: i += 1 + self.current_track = self.tracks[0] + def load_from_wbz(self, path): pass