2024-10-30 09:06:10 +00:00
|
|
|
mod song;
|
|
|
|
pub use song::Song;
|
|
|
|
|
2024-10-30 11:45:50 +00:00
|
|
|
mod state;
|
|
|
|
pub use state::State;
|
|
|
|
|
2024-10-30 09:06:10 +00:00
|
|
|
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;
|
2024-10-30 11:59:16 +00:00
|
|
|
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);
|
2024-10-30 12:09:22 +00:00
|
|
|
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);
|
2024-10-30 12:25:27 +00:00
|
|
|
pub fn audrey_playbin_seek(self_: *mut AudreyPlaybin, position: f64);
|
2024-10-30 09:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
use gtk::glib;
|
|
|
|
|
|
|
|
glib::wrapper! {
|
|
|
|
pub struct Playbin(Object<ffi::AudreyPlaybin, ffi::AudreyPlaybinClass>);
|
|
|
|
|
|
|
|
match fn {
|
|
|
|
type_ => || ffi::audrey_playbin_get_type(),
|
|
|
|
}
|
|
|
|
}
|
2024-10-30 11:59:16 +00:00
|
|
|
|
|
|
|
impl Playbin {
|
|
|
|
pub fn get_state(&self) -> State {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
unsafe { glib::translate::from_glib(ffi::audrey_playbin_get_state(self.to_glib_none().0)) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn pause(&self) {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
unsafe { ffi::audrey_playbin_pause(self.to_glib_none().0) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn play(&self) {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
unsafe { ffi::audrey_playbin_play(self.to_glib_none().0) }
|
|
|
|
}
|
2024-10-30 12:09:22 +00:00
|
|
|
|
|
|
|
pub fn get_volume(&self) -> i32 {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
unsafe { ffi::audrey_playbin_get_volume(self.to_glib_none().0) }
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_volume(&self, value: i32) {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
unsafe { ffi::audrey_playbin_set_volume(self.to_glib_none().0, value) }
|
|
|
|
}
|
2024-10-30 12:25:27 +00:00
|
|
|
|
|
|
|
pub fn seek(&self, position: f64) {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
unsafe { ffi::audrey_playbin_seek(self.to_glib_none().0, position) }
|
|
|
|
}
|
2024-10-30 11:59:16 +00:00
|
|
|
}
|