119 lines
3.8 KiB
Rust
119 lines
3.8 KiB
Rust
pub mod song;
|
|
pub use song::Song;
|
|
|
|
mod state;
|
|
pub use state::State;
|
|
|
|
pub mod ffi {
|
|
use gtk::glib;
|
|
|
|
#[repr(C)]
|
|
pub struct AudreyPlaybin {
|
|
parent_instance: glib::gobject_ffi::GObject,
|
|
}
|
|
|
|
#[repr(C)]
|
|
pub struct AudreyPlaybinClass {
|
|
parent_class: glib::gobject_ffi::GObjectClass,
|
|
}
|
|
|
|
extern "C" {
|
|
pub fn audrey_playbin_get_type() -> glib::ffi::GType;
|
|
pub fn audrey_playbin_get_state(self_: *mut AudreyPlaybin) -> super::state::ffi::State;
|
|
pub fn audrey_playbin_pause(self_: *mut AudreyPlaybin);
|
|
pub fn audrey_playbin_play(self_: *mut AudreyPlaybin);
|
|
pub fn audrey_playbin_get_volume(self_: *mut AudreyPlaybin) -> std::ffi::c_int;
|
|
pub fn audrey_playbin_set_volume(self_: *mut AudreyPlaybin, volume: std::ffi::c_int);
|
|
pub fn audrey_playbin_seek(self_: *mut AudreyPlaybin, position: f64);
|
|
pub fn audrey_playbin_go_to_next_track(self_: *mut AudreyPlaybin);
|
|
pub fn audrey_playbin_go_to_prev_track(self_: *mut AudreyPlaybin);
|
|
pub fn audrey_playbin_get_position(self_: *mut AudreyPlaybin) -> f64;
|
|
pub fn audrey_playbin_get_duration(self_: *mut AudreyPlaybin) -> f64;
|
|
pub fn audrey_playbin_get_mute(self_: *mut AudreyPlaybin) -> glib::ffi::gboolean;
|
|
pub fn audrey_playbin_set_mute(self_: *mut AudreyPlaybin, mute: glib::ffi::gboolean);
|
|
pub fn audrey_playbin_get_play_queue_position(
|
|
self_: *mut AudreyPlaybin,
|
|
) -> std::ffi::c_uint;
|
|
pub fn audrey_playbin_move_track(
|
|
self_: *mut AudreyPlaybin,
|
|
from: std::ffi::c_uint,
|
|
to: std::ffi::c_uint,
|
|
);
|
|
pub fn audrey_playbin_remove_track(self_: *mut AudreyPlaybin, position: std::ffi::c_uint);
|
|
}
|
|
}
|
|
|
|
use glib::translate::from_glib;
|
|
use glib::translate::IntoGlib;
|
|
use glib::translate::ToGlibPtr;
|
|
use gtk::glib;
|
|
|
|
glib::wrapper! {
|
|
pub struct Playbin(Object<ffi::AudreyPlaybin, ffi::AudreyPlaybinClass>);
|
|
|
|
match fn {
|
|
type_ => || ffi::audrey_playbin_get_type(),
|
|
}
|
|
}
|
|
|
|
impl Playbin {
|
|
pub fn state(&self) -> State {
|
|
unsafe { glib::translate::from_glib(ffi::audrey_playbin_get_state(self.to_glib_none().0)) }
|
|
}
|
|
|
|
pub fn pause(&self) {
|
|
unsafe { ffi::audrey_playbin_pause(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn play(&self) {
|
|
unsafe { ffi::audrey_playbin_play(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn volume(&self) -> i32 {
|
|
unsafe { ffi::audrey_playbin_get_volume(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn set_volume(&self, value: i32) {
|
|
unsafe { ffi::audrey_playbin_set_volume(self.to_glib_none().0, value) }
|
|
}
|
|
|
|
pub fn seek(&self, position: f64) {
|
|
unsafe { ffi::audrey_playbin_seek(self.to_glib_none().0, position) }
|
|
}
|
|
|
|
pub fn go_to_next_track(&self) {
|
|
unsafe { ffi::audrey_playbin_go_to_next_track(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn go_to_prev_track(&self) {
|
|
unsafe { ffi::audrey_playbin_go_to_prev_track(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn position(&self) -> f64 {
|
|
unsafe { ffi::audrey_playbin_get_position(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn duration(&self) -> f64 {
|
|
unsafe { ffi::audrey_playbin_get_duration(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn mute(&self) -> bool {
|
|
unsafe { from_glib(ffi::audrey_playbin_get_mute(self.to_glib_none().0)) }
|
|
}
|
|
|
|
pub fn set_mute(&self, mute: bool) {
|
|
unsafe { ffi::audrey_playbin_set_mute(self.to_glib_none().0, mute.into_glib()) }
|
|
}
|
|
|
|
pub fn play_queue_position(&self) -> u32 {
|
|
unsafe { ffi::audrey_playbin_get_play_queue_position(self.to_glib_none().0) }
|
|
}
|
|
|
|
pub fn move_track(&self, from: u32, to: u32) {
|
|
unsafe { ffi::audrey_playbin_move_track(self.to_glib_none().0, from, to) }
|
|
}
|
|
|
|
pub fn remove_track(&self, position: u32) {
|
|
unsafe { ffi::audrey_playbin_remove_track(self.to_glib_none().0, position) }
|
|
}
|
|
}
|