use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVAudioPlayer;
);
extern_conformance!(
unsafe impl NSObjectProtocol for AVAudioPlayer {}
);
impl AVAudioPlayer {
extern_methods!(
#[unsafe(method(initWithContentsOfURL:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithContentsOfURL_error(
this: Allocated<Self>,
url: &NSURL,
) -> Result<Retained<Self>, Retained<NSError>>;
#[unsafe(method(initWithData:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithData_error(
this: Allocated<Self>,
data: &NSData,
) -> Result<Retained<Self>, Retained<NSError>>;
#[unsafe(method(initWithContentsOfURL:fileTypeHint:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithContentsOfURL_fileTypeHint_error(
this: Allocated<Self>,
url: &NSURL,
uti_string: Option<&NSString>,
) -> Result<Retained<Self>, Retained<NSError>>;
#[unsafe(method(initWithData:fileTypeHint:error:_))]
#[unsafe(method_family = init)]
pub unsafe fn initWithData_fileTypeHint_error(
this: Allocated<Self>,
data: &NSData,
uti_string: Option<&NSString>,
) -> Result<Retained<Self>, Retained<NSError>>;
#[unsafe(method(prepareToPlay))]
#[unsafe(method_family = none)]
pub unsafe fn prepareToPlay(&self) -> bool;
#[unsafe(method(play))]
#[unsafe(method_family = none)]
pub unsafe fn play(&self) -> bool;
#[unsafe(method(playAtTime:))]
#[unsafe(method_family = none)]
pub unsafe fn playAtTime(&self, time: NSTimeInterval) -> bool;
#[unsafe(method(pause))]
#[unsafe(method_family = none)]
pub unsafe fn pause(&self);
#[unsafe(method(stop))]
#[unsafe(method_family = none)]
pub unsafe fn stop(&self);
#[unsafe(method(isPlaying))]
#[unsafe(method_family = none)]
pub unsafe fn isPlaying(&self) -> bool;
#[unsafe(method(numberOfChannels))]
#[unsafe(method_family = none)]
pub unsafe fn numberOfChannels(&self) -> NSUInteger;
#[unsafe(method(duration))]
#[unsafe(method_family = none)]
pub unsafe fn duration(&self) -> NSTimeInterval;
#[unsafe(method(currentDevice))]
#[unsafe(method_family = none)]
pub unsafe fn currentDevice(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setCurrentDevice:))]
#[unsafe(method_family = none)]
pub unsafe fn setCurrentDevice(&self, current_device: Option<&NSString>);
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn AVAudioPlayerDelegate>>>;
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn AVAudioPlayerDelegate>>,
);
#[unsafe(method(url))]
#[unsafe(method_family = none)]
pub unsafe fn url(&self) -> Option<Retained<NSURL>>;
#[unsafe(method(data))]
#[unsafe(method_family = none)]
pub unsafe fn data(&self) -> Option<Retained<NSData>>;
#[unsafe(method(pan))]
#[unsafe(method_family = none)]
pub unsafe fn pan(&self) -> c_float;
#[unsafe(method(setPan:))]
#[unsafe(method_family = none)]
pub unsafe fn setPan(&self, pan: c_float);
#[unsafe(method(volume))]
#[unsafe(method_family = none)]
pub unsafe fn volume(&self) -> c_float;
#[unsafe(method(setVolume:))]
#[unsafe(method_family = none)]
pub unsafe fn setVolume(&self, volume: c_float);
#[unsafe(method(setVolume:fadeDuration:))]
#[unsafe(method_family = none)]
pub unsafe fn setVolume_fadeDuration(&self, volume: c_float, duration: NSTimeInterval);
#[unsafe(method(enableRate))]
#[unsafe(method_family = none)]
pub unsafe fn enableRate(&self) -> bool;
#[unsafe(method(setEnableRate:))]
#[unsafe(method_family = none)]
pub unsafe fn setEnableRate(&self, enable_rate: bool);
#[unsafe(method(rate))]
#[unsafe(method_family = none)]
pub unsafe fn rate(&self) -> c_float;
#[unsafe(method(setRate:))]
#[unsafe(method_family = none)]
pub unsafe fn setRate(&self, rate: c_float);
#[unsafe(method(currentTime))]
#[unsafe(method_family = none)]
pub unsafe fn currentTime(&self) -> NSTimeInterval;
#[unsafe(method(setCurrentTime:))]
#[unsafe(method_family = none)]
pub unsafe fn setCurrentTime(&self, current_time: NSTimeInterval);
#[unsafe(method(deviceCurrentTime))]
#[unsafe(method_family = none)]
pub unsafe fn deviceCurrentTime(&self) -> NSTimeInterval;
#[unsafe(method(numberOfLoops))]
#[unsafe(method_family = none)]
pub unsafe fn numberOfLoops(&self) -> NSInteger;
#[unsafe(method(setNumberOfLoops:))]
#[unsafe(method_family = none)]
pub unsafe fn setNumberOfLoops(&self, number_of_loops: NSInteger);
#[unsafe(method(settings))]
#[unsafe(method_family = none)]
pub unsafe fn settings(&self) -> Retained<NSDictionary<NSString, AnyObject>>;
#[cfg(feature = "AVAudioFormat")]
#[unsafe(method(format))]
#[unsafe(method_family = none)]
pub unsafe fn format(&self) -> Retained<AVAudioFormat>;
#[unsafe(method(isMeteringEnabled))]
#[unsafe(method_family = none)]
pub unsafe fn isMeteringEnabled(&self) -> bool;
#[unsafe(method(setMeteringEnabled:))]
#[unsafe(method_family = none)]
pub unsafe fn setMeteringEnabled(&self, metering_enabled: bool);
#[unsafe(method(updateMeters))]
#[unsafe(method_family = none)]
pub unsafe fn updateMeters(&self);
#[unsafe(method(peakPowerForChannel:))]
#[unsafe(method_family = none)]
pub unsafe fn peakPowerForChannel(&self, channel_number: NSUInteger) -> c_float;
#[unsafe(method(averagePowerForChannel:))]
#[unsafe(method_family = none)]
pub unsafe fn averagePowerForChannel(&self, channel_number: NSUInteger) -> c_float;
#[cfg(feature = "AVAudioSessionRoute")]
#[unsafe(method(channelAssignments))]
#[unsafe(method_family = none)]
pub unsafe fn channelAssignments(
&self,
) -> Option<Retained<NSArray<AVAudioSessionChannelDescription>>>;
#[cfg(feature = "AVAudioSessionRoute")]
#[unsafe(method(setChannelAssignments:))]
#[unsafe(method_family = none)]
pub unsafe fn setChannelAssignments(
&self,
channel_assignments: Option<&NSArray<AVAudioSessionChannelDescription>>,
);
);
}
impl AVAudioPlayer {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_protocol!(
pub unsafe trait AVAudioPlayerDelegate: NSObjectProtocol {
#[optional]
#[unsafe(method(audioPlayerDidFinishPlaying:successfully:))]
#[unsafe(method_family = none)]
unsafe fn audioPlayerDidFinishPlaying_successfully(
&self,
player: &AVAudioPlayer,
flag: bool,
);
#[optional]
#[unsafe(method(audioPlayerDecodeErrorDidOccur:error:))]
#[unsafe(method_family = none)]
unsafe fn audioPlayerDecodeErrorDidOccur_error(
&self,
player: &AVAudioPlayer,
error: Option<&NSError>,
);
}
);