mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Move player bar to separate widget
This commit is contained in:
parent
f16a27e343
commit
232faa6a2f
8 changed files with 261 additions and 141 deletions
|
|
@ -21,15 +21,19 @@ mod imp {
|
|||
impl MusicusPlayer {
|
||||
pub fn set_current_index(&self, index: u32) {
|
||||
let playlist = self.playlist.get().unwrap();
|
||||
|
||||
|
||||
if let Some(item) = playlist.item(self.current_index.get()) {
|
||||
item.downcast::<PlaylistItem>().unwrap().set_is_playing(false);
|
||||
item.downcast::<PlaylistItem>()
|
||||
.unwrap()
|
||||
.set_is_playing(false);
|
||||
}
|
||||
|
||||
self.current_index.set(index);
|
||||
|
||||
|
||||
if let Some(item) = playlist.item(index) {
|
||||
item.downcast::<PlaylistItem>().unwrap().set_is_playing(true);
|
||||
item.downcast::<PlaylistItem>()
|
||||
.unwrap()
|
||||
.set_is_playing(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +64,7 @@ impl MusicusPlayer {
|
|||
|
||||
pub fn append(&self, tracks: Vec<PlaylistItem>) {
|
||||
let playlist = self.playlist();
|
||||
|
||||
|
||||
for track in tracks {
|
||||
playlist.append(&track);
|
||||
}
|
||||
|
|
@ -75,6 +79,15 @@ impl MusicusPlayer {
|
|||
pub fn pause(&self) {
|
||||
self.set_playing(false)
|
||||
}
|
||||
|
||||
pub fn current_item(&self) -> Option<PlaylistItem> {
|
||||
let imp = self.imp();
|
||||
imp.playlist
|
||||
.get()
|
||||
.unwrap()
|
||||
.item(imp.current_index.get())
|
||||
.and_downcast::<PlaylistItem>()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MusicusPlayer {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue