Skip to content

Commit

Permalink
fix playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
kamiyaa committed Sep 10, 2024
1 parent f133f8e commit d5efbb2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 7 additions & 0 deletions src/bin/server/audio/symphonia/player/impl_audio_player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ impl AudioPlayer for SymphoniaPlayer {
}

fn play_again(&mut self) -> DiziResult {
let playlist = self.playlist_context.current_playlist_ref();

if let Some(entry) = playlist.current_entry() {
if let DiziSongEntry::Loaded(audio_file) = entry.entry {
self.play(&audio_file)?;
}
}
Ok(())
}

Expand Down
14 changes: 5 additions & 9 deletions src/bin/server/server_commands/playlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,7 @@ pub fn playlist_load(context: &mut AppContext, cwd: &Path, path: &Path) -> DiziR
}

pub fn playlist_clear(context: &mut AppContext) -> DiziResult {
context
.player
.playlist_context_mut()
.current_playlist_mut()
.clear();
context.player.playlist_context_mut().file_playlist.clear();
Ok(())
}

Expand All @@ -56,7 +52,7 @@ pub fn playlist_append(context: &mut AppContext, path: &Path) -> DiziResult<Vec<
context
.player
.playlist_context_mut()
.current_playlist_mut()
.file_playlist
.push(entry);
}
Ok(audio_files)
Expand All @@ -67,7 +63,7 @@ pub fn playlist_append(context: &mut AppContext, path: &Path) -> DiziResult<Vec<
context
.player
.playlist_context_mut()
.current_playlist_mut()
.file_playlist
.push(entry);
Ok(vec![audio_file])
} else {
Expand All @@ -80,8 +76,8 @@ pub fn playlist_remove(context: &mut AppContext, index: usize) -> DiziResult {
if index <= len {
context
.player
.playlist_context
.current_playlist_mut()
.playlist_context_mut()
.file_playlist
.remove(index);
}
Ok(())
Expand Down

0 comments on commit d5efbb2

Please sign in to comment.