de-warn
This commit is contained in:
parent
fd88c54809
commit
6483f3dd17
8 changed files with 65 additions and 32 deletions
|
@ -45,11 +45,11 @@ impl MetadataMap {
|
||||||
}),
|
}),
|
||||||
length: Some(song.duration() * MICROSECONDS as i64),
|
length: Some(song.duration() * MICROSECONDS as i64),
|
||||||
//art_url: Some(song.cover_art_url()), // FIXME: this would leak credentials
|
//art_url: Some(song.cover_art_url()), // FIXME: this would leak credentials
|
||||||
album: Some(song.album().into()),
|
album: Some(song.album()),
|
||||||
artist: Some(vec![song.artist().into()]),
|
artist: Some(vec![song.artist()]),
|
||||||
//content_created: song.year().map(|year| chrono::NaiveDate::from_yo_opt(year, 1).unwrap()), // FIXME: replace this unwrap with Some(Err) -> None
|
//content_created: song.year().map(|year| chrono::NaiveDate::from_yo_opt(year, 1).unwrap()), // FIXME: replace this unwrap with Some(Err) -> None
|
||||||
//genre: Some(song.genre.iter().collect()),
|
//genre: Some(song.genre.iter().collect()),
|
||||||
title: Some(song.title().into()),
|
title: Some(song.title()),
|
||||||
//track_number: song.track().map(|u| u as i32),
|
//track_number: song.track().map(|u| u as i32),
|
||||||
//user_rating: Some(if song.starred().is_none() { 0.0 } else { 1.0 }),
|
//user_rating: Some(if song.starred().is_none() { 0.0 } else { 1.0 }),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
@ -273,6 +273,46 @@ impl Player {
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn previous(&self) -> zbus::fdo::Result<()> {
|
||||||
|
self.with_local(move |local| async move { local.previous() })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn pause(&self) -> zbus::fdo::Result<()> {
|
||||||
|
self.with_local(move |local| async move { local.pause() })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn play_pause(&self) -> zbus::fdo::Result<()> {
|
||||||
|
self.with_local(move |local| async move { local.play_pause() })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn stop(&self) -> zbus::fdo::Result<()> {
|
||||||
|
self.with_local(move |local| async move { local.stop() })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn play(&self) -> zbus::fdo::Result<()> {
|
||||||
|
self.with_local(move |local| async move { local.play() })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn seek(&self, offset: i64) -> zbus::fdo::Result<()> {
|
||||||
|
self.with_local(move |local| async move { local.seek(offset) })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn set_position(&self, track_id: ObjectPath<'_>, position: i64) -> zbus::fdo::Result<()> {
|
||||||
|
let track_id = track_id.to_owned();
|
||||||
|
self.with_local(move |local| async move { local.set_position(track_id, position) })
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn open_uri(&self, _s: String) -> zbus::fdo::Result<()> {
|
||||||
|
Err(zbus::fdo::Error::NotSupported("OpenUri".into()))
|
||||||
|
}
|
||||||
|
|
||||||
#[zbus(property)]
|
#[zbus(property)]
|
||||||
async fn playback_status(&self) -> zbus::fdo::Result<String> {
|
async fn playback_status(&self) -> zbus::fdo::Result<String> {
|
||||||
self.with_local(|local| async move { local.playback_status() })
|
self.with_local(|local| async move { local.playback_status() })
|
||||||
|
@ -473,14 +513,14 @@ impl LocalPlayer {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_position(&self, _track_id: ObjectPath<'_>, _position: i64) -> zbus::fdo::Result<()> {
|
fn set_position(
|
||||||
|
&self,
|
||||||
|
_track_id: ObjectPath<'static>,
|
||||||
|
_position: i64,
|
||||||
|
) -> zbus::fdo::Result<()> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open_uri(&self, _s: &str) -> zbus::fdo::Result<()> {
|
|
||||||
Err(zbus::fdo::Error::NotSupported("OpenUri".into()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn playback_status(&self) -> zbus::fdo::Result<String> {
|
fn playback_status(&self) -> zbus::fdo::Result<String> {
|
||||||
match self.playbin()?.paused() {
|
match self.playbin()?.paused() {
|
||||||
//crate::playbin::State::Stopped => Ok("Stopped".into()),
|
//crate::playbin::State::Stopped => Ok("Stopped".into()),
|
||||||
|
@ -532,10 +572,6 @@ impl LocalPlayer {
|
||||||
// we don't play anything that can't be seeked
|
// we don't play anything that can't be seeked
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_control(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Player {
|
impl Drop for Player {
|
||||||
|
|
|
@ -137,7 +137,7 @@ where
|
||||||
entries.push(entry);
|
entries.push(entry);
|
||||||
|
|
||||||
drop(entries);
|
drop(entries);
|
||||||
self.entry_inserted.emit(self, index as usize);
|
self.entry_inserted.emit(self, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_entry(&self, index: usize, entry: E) {
|
pub fn insert_entry(&self, index: usize, entry: E) {
|
||||||
|
@ -145,7 +145,7 @@ where
|
||||||
self.mpv
|
self.mpv
|
||||||
.command(["loadfile", entry.url().as_str(), "insert-at-play"])
|
.command(["loadfile", entry.url().as_str(), "insert-at-play"])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
entries.insert(index as usize, entry);
|
entries.insert(index, entry);
|
||||||
|
|
||||||
drop(entries);
|
drop(entries);
|
||||||
self.entry_inserted.emit(self, index);
|
self.entry_inserted.emit(self, index);
|
||||||
|
@ -166,7 +166,7 @@ where
|
||||||
self.mpv
|
self.mpv
|
||||||
.command(["playlist-remove", &index.to_string()])
|
.command(["playlist-remove", &index.to_string()])
|
||||||
.unwrap();
|
.unwrap();
|
||||||
entries.remove(index as usize);
|
entries.remove(index);
|
||||||
|
|
||||||
drop(entries);
|
drop(entries);
|
||||||
self.entry_removed.emit(self, index);
|
self.entry_removed.emit(self, index);
|
||||||
|
|
|
@ -102,7 +102,6 @@ impl<E, T> SignalEmitter<E, T> {
|
||||||
handlers.append(self.just_connected.borrow_mut().as_mut());
|
handlers.append(self.just_connected.borrow_mut().as_mut());
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
let mut skip = 0;
|
|
||||||
// FIXME: does not preserve ordering
|
// FIXME: does not preserve ordering
|
||||||
while i < handlers.len() {
|
while i < handlers.len() {
|
||||||
if handlers[i](emitter, f()) {
|
if handlers[i](emitter, f()) {
|
||||||
|
|
|
@ -4,8 +4,8 @@ pub use song::Song;
|
||||||
mod imp {
|
mod imp {
|
||||||
use crate::{Playbin, PlaybinSong};
|
use crate::{Playbin, PlaybinSong};
|
||||||
use adw::{gio, glib, prelude::*, subclass::prelude::*};
|
use adw::{gio, glib, prelude::*, subclass::prelude::*};
|
||||||
use glib::{subclass::InitializingObject, WeakRef};
|
use glib::subclass::InitializingObject;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::RefCell;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||||
|
@ -134,13 +134,13 @@ impl PlayQueue {
|
||||||
});
|
});
|
||||||
playbin
|
playbin
|
||||||
.stopped()
|
.stopped()
|
||||||
.connect_object(self, |playbin, play_queue, ()| {
|
.connect_object(self, |_playbin, play_queue, ()| {
|
||||||
play_queue.model().unwrap().remove_all();
|
play_queue.model().unwrap().remove_all();
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
playbin
|
playbin
|
||||||
.entry_removed()
|
.entry_removed()
|
||||||
.connect_object(self, |playbin, play_queue, index| {
|
.connect_object(self, |_playbin, play_queue, index| {
|
||||||
play_queue.model().unwrap().remove(index as u32);
|
play_queue.model().unwrap().remove(index as u32);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
mod imp {
|
mod imp {
|
||||||
use crate::signal::SignalHandler;
|
use crate::signal::SignalHandler;
|
||||||
use crate::{Playbin, PlaybinSong};
|
use crate::{Playbin, PlaybinSong};
|
||||||
use glib::{subclass::InitializingObject, WeakRef};
|
use glib::subclass::InitializingObject;
|
||||||
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
|
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
@ -166,7 +166,6 @@ mod imp {
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::{Playbin, PlaybinSong};
|
use crate::{Playbin, PlaybinSong};
|
||||||
use adw::prelude::*;
|
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use glib::Object;
|
use glib::Object;
|
||||||
use gtk::glib;
|
use gtk::glib;
|
||||||
|
|
|
@ -3,7 +3,6 @@ mod imp {
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use glib::subclass::InitializingObject;
|
use glib::subclass::InitializingObject;
|
||||||
use glib::{gformat, GString, WeakRef};
|
|
||||||
use gtk::{gdk, glib};
|
use gtk::{gdk, glib};
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
|
|
||||||
|
@ -86,8 +85,8 @@ mod imp {
|
||||||
fn on_play_position_seek(
|
fn on_play_position_seek(
|
||||||
&self,
|
&self,
|
||||||
_scroll_type: gtk::ScrollType,
|
_scroll_type: gtk::ScrollType,
|
||||||
value: f64,
|
_value: f64,
|
||||||
range: >k::Range,
|
_range: >k::Range,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
/*
|
/*
|
||||||
let playbin = self.playbin.upgrade().unwrap();
|
let playbin = self.playbin.upgrade().unwrap();
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
mod imp {
|
mod imp {
|
||||||
use crate::signal::SignalEmitter;
|
use crate::signal::SignalEmitter;
|
||||||
use adw::{glib, prelude::*, subclass::prelude::*};
|
use adw::{glib, prelude::*, subclass::prelude::*};
|
||||||
use glib::subclass::{InitializingObject, Signal};
|
use glib::subclass::InitializingObject;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::OnceLock;
|
|
||||||
|
|
||||||
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
|
||||||
#[template(resource = "/eu/callcc/audrey/setup.ui")]
|
#[template(resource = "/eu/callcc/audrey/setup.ui")]
|
||||||
|
|
|
@ -140,7 +140,7 @@ mod imp {
|
||||||
self.setup.present(Some(self.obj().as_ref()));
|
self.setup.present(Some(self.obj().as_ref()));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn now_playing(&self, _song: PlaybinSong) {
|
pub(super) fn now_playing(&self, _song: &PlaybinSong) {
|
||||||
/*
|
/*
|
||||||
this.song = song;
|
this.song = song;
|
||||||
// api.scrobble.begin (this.song.id); TODO
|
// api.scrobble.begin (this.song.id); TODO
|
||||||
|
@ -177,10 +177,9 @@ mod imp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::PlaybinSong;
|
|
||||||
use adw::prelude::*;
|
use adw::prelude::*;
|
||||||
use adw::subclass::prelude::*;
|
use adw::subclass::prelude::*;
|
||||||
use gtk::{gdk, gio, glib};
|
use gtk::{gio, glib};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
|
@ -274,8 +273,10 @@ impl Window {
|
||||||
.imp()
|
.imp()
|
||||||
.playbin2
|
.playbin2
|
||||||
.file_started()
|
.file_started()
|
||||||
.connect_object(&window, |_playbin, _window, ()| {
|
.connect_object(&window, |playbin, window, ()| {
|
||||||
// TODO window.imp().now_playing(song);
|
window
|
||||||
|
.imp()
|
||||||
|
.now_playing(&playbin.entries()[playbin.current_entry().unwrap()]);
|
||||||
true
|
true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue