volume slider works again
This commit is contained in:
parent
0f2351ae01
commit
bf8b02de12
2 changed files with 31 additions and 2 deletions
|
@ -22,6 +22,8 @@ mod ffi {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,4 +55,16 @@ impl Playbin {
|
|||
|
||||
unsafe { ffi::audrey_playbin_play(self.to_glib_none().0) }
|
||||
}
|
||||
|
||||
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) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ mod imp {
|
|||
#[property(get, set, default = true)]
|
||||
show_cover_art: Cell<bool>,
|
||||
|
||||
#[property(get, set)]
|
||||
volume: Cell<i32>,
|
||||
#[property(get = Self::get_volume, set = Self::set_volume)]
|
||||
volume: i32,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
@ -166,6 +166,21 @@ mod imp {
|
|||
//this.playbin.mute = !this.playbin.mute;
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_volume(&self) -> i32 {
|
||||
let playbin = self.playbin.borrow();
|
||||
|
||||
match playbin.as_ref() {
|
||||
None => 100,
|
||||
Some(playbin) => playbin.get_volume(),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_volume(&self, value: i32) {
|
||||
let playbin = self.playbin.borrow();
|
||||
let playbin = playbin.as_ref().unwrap();
|
||||
playbin.set_volume(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue