Manual player updated to handle the new file structure.
This commit is contained in:
1 parent
a1ce9eab9f
commit
cd48d9071c
1 file changed
+42
-13
+42
-13
@@ -688,19 +688,43 @@ class AudioManualDialog(QDialog):
|
||||
|
||||
def populateManuals(self):
|
||||
"""Populate manual selection combo box"""
|
||||
manualDirs = sorted([d for d in self.manualPath.iterdir() if d.is_dir()])
|
||||
self.manualCombo.addItems([m.name for m in manualDirs])
|
||||
items = []
|
||||
# Add all directories
|
||||
for item in sorted(self.manualPath.iterdir()):
|
||||
if item.is_dir():
|
||||
items.append(item.name)
|
||||
# Add standalone MP3 files at root level (like "08 - Special Thanks and Shoutouts.mp3")
|
||||
for item in sorted(self.manualPath.iterdir()):
|
||||
if item.is_file() and item.suffix.lower() == '.mp3':
|
||||
items.append(item.name)
|
||||
self.manualCombo.addItems(items)
|
||||
|
||||
def populateTracks(self):
|
||||
"""Populate track selection combo box"""
|
||||
self.trackCombo.clear()
|
||||
selectedManual = self.manualPath / self.manualCombo.currentText()
|
||||
if selectedManual.exists():
|
||||
tracks = sorted(selectedManual.glob('*.mp3'))
|
||||
self.trackCombo.addItem("Play All")
|
||||
self.trackCombo.addItems([t.stem for t in tracks])
|
||||
# Update button states after populating tracks
|
||||
self.updateButtonStates()
|
||||
|
||||
if not selectedManual.exists():
|
||||
return
|
||||
|
||||
# Check if selected item is a standalone MP3 file
|
||||
if selectedManual.is_file() and selectedManual.suffix.lower() == '.mp3':
|
||||
# For standalone MP3s, just add the file itself
|
||||
self.trackCombo.addItem(selectedManual.stem)
|
||||
else:
|
||||
# For directories, recursively find all MP3 files
|
||||
tracks = sorted(selectedManual.rglob('*.mp3'))
|
||||
if tracks:
|
||||
self.trackCombo.addItem("Play All")
|
||||
# Use relative path from selected manual for better readability
|
||||
for track in tracks:
|
||||
relative_path = track.relative_to(selectedManual)
|
||||
# Store the display name (remove .mp3 extension for cleaner look)
|
||||
display_name = str(relative_path.with_suffix(''))
|
||||
self.trackCombo.addItem(display_name)
|
||||
|
||||
# Update button states after populating tracks
|
||||
self.updateButtonStates()
|
||||
|
||||
def playAudio(self):
|
||||
"""Start audio playback"""
|
||||
@@ -714,15 +738,20 @@ class AudioManualDialog(QDialog):
|
||||
self.audioPlayer.stop()
|
||||
self.audioPlayer.playAllMode = selectedTrack == "Play All"
|
||||
|
||||
if selectedTrack == "Play All":
|
||||
# Get sorted list of MP3 files
|
||||
tracks = sorted(selectedManual.glob('*.mp3'))
|
||||
# Handle standalone MP3 file
|
||||
if selectedManual.is_file() and selectedManual.suffix.lower() == '.mp3':
|
||||
tracks = [selectedManual]
|
||||
self.audioPlayer.loadTracks([str(t) for t in tracks])
|
||||
elif selectedTrack == "Play All":
|
||||
# Get sorted list of all MP3 files recursively
|
||||
tracks = sorted(selectedManual.rglob('*.mp3'))
|
||||
print(f"Loading {len(tracks)} tracks for Play All")
|
||||
self.audioPlayer.loadTracks([str(t) for t in tracks])
|
||||
else:
|
||||
# Handle nested paths - selectedTrack now contains relative path like "Doom Monsters and Shootables/01 - Monsters and Shootables Intro"
|
||||
print("Loading single track")
|
||||
tracks = [selectedManual / f"{selectedTrack}.mp3"]
|
||||
self.audioPlayer.loadTracks([str(t) for t in tracks])
|
||||
trackPath = selectedManual / f"{selectedTrack}.mp3"
|
||||
self.audioPlayer.loadTracks([str(trackPath)])
|
||||
|
||||
# Start playback
|
||||
if self.audioPlayer.play():
|
||||
|
||||
Reference in new issue
Block a user