Added command_line.py to control the player via command line.
This commit is contained in:
parent
94269fdae4
commit
10c36b37a1
5 changed files with 32 additions and 16 deletions
28
wobuzz/command_line.py
Normal file
28
wobuzz/command_line.py
Normal file
|
@ -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())
|
||||
|
|
@ -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():
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -43,6 +43,8 @@ class Playlist:
|
|||
|
||||
i += 1
|
||||
|
||||
self.current_track = self.tracks[0]
|
||||
|
||||
def load_from_wbz(self, path):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue