objc2_avf_audio/generated/AVMIDIPlayer.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Generic callback block.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avmidiplayercompletionhandler?language=objc)
13#[cfg(feature = "block2")]
14pub type AVMIDIPlayerCompletionHandler = *mut block2::DynBlock<dyn Fn()>;
15
16extern_class!(
17 /// A player for music file formats (MIDI, iMelody).
18 ///
19 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfaudio/avmidiplayer?language=objc)
20 #[unsafe(super(NSObject))]
21 #[derive(Debug, PartialEq, Eq, Hash)]
22 pub struct AVMIDIPlayer;
23);
24
25extern_conformance!(
26 unsafe impl NSObjectProtocol for AVMIDIPlayer {}
27);
28
29impl AVMIDIPlayer {
30 extern_methods!(
31 /// Create a player with the contents of the file specified by the URL.
32 ///
33 /// 'bankURL' should contain the path to a SoundFont2 or DLS bank to be used
34 /// by the MIDI synthesizer. For OSX it can be set to nil for the default,
35 /// but for iOS it must always refer to a valid bank file.
36 #[unsafe(method(initWithContentsOfURL:soundBankURL:error:_))]
37 #[unsafe(method_family = init)]
38 pub unsafe fn initWithContentsOfURL_soundBankURL_error(
39 this: Allocated<Self>,
40 in_url: &NSURL,
41 bank_url: Option<&NSURL>,
42 ) -> Result<Retained<Self>, Retained<NSError>>;
43
44 /// Create a player with the contents of the data object
45 ///
46 /// 'bankURL' should contain the path to a SoundFont2 or DLS bank to be used
47 /// by the MIDI synthesizer. For OSX it can be set to nil for the default,
48 /// but for iOS it must always refer to a valid bank file.
49 #[unsafe(method(initWithData:soundBankURL:error:_))]
50 #[unsafe(method_family = init)]
51 pub unsafe fn initWithData_soundBankURL_error(
52 this: Allocated<Self>,
53 data: &NSData,
54 bank_url: Option<&NSURL>,
55 ) -> Result<Retained<Self>, Retained<NSError>>;
56
57 /// Get ready to play the sequence by prerolling all events
58 ///
59 /// Happens automatically on play if it has not already been called, but may produce a delay in startup.
60 #[unsafe(method(prepareToPlay))]
61 #[unsafe(method_family = none)]
62 pub unsafe fn prepareToPlay(&self);
63
64 #[cfg(feature = "block2")]
65 /// Play the sequence.
66 #[unsafe(method(play:))]
67 #[unsafe(method_family = none)]
68 pub unsafe fn play(&self, completion_handler: AVMIDIPlayerCompletionHandler);
69
70 /// Stop playing the sequence.
71 #[unsafe(method(stop))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn stop(&self);
74
75 /// The length of the currently loaded file in seconds.
76 #[unsafe(method(duration))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn duration(&self) -> NSTimeInterval;
79
80 /// Indicates whether or not the player is playing
81 #[unsafe(method(isPlaying))]
82 #[unsafe(method_family = none)]
83 pub unsafe fn isPlaying(&self) -> bool;
84
85 /// The playback rate of the player
86 ///
87 /// 1.0 is normal playback rate. Rate must be > 0.0.
88 #[unsafe(method(rate))]
89 #[unsafe(method_family = none)]
90 pub unsafe fn rate(&self) -> c_float;
91
92 /// Setter for [`rate`][Self::rate].
93 #[unsafe(method(setRate:))]
94 #[unsafe(method_family = none)]
95 pub unsafe fn setRate(&self, rate: c_float);
96
97 /// The current playback position in seconds
98 ///
99 /// Setting this positions the player to the specified time. No range checking on the time value is done.
100 /// This can be set while the player is playing, in which case playback will resume at the new time.
101 #[unsafe(method(currentPosition))]
102 #[unsafe(method_family = none)]
103 pub unsafe fn currentPosition(&self) -> NSTimeInterval;
104
105 /// Setter for [`currentPosition`][Self::currentPosition].
106 #[unsafe(method(setCurrentPosition:))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn setCurrentPosition(&self, current_position: NSTimeInterval);
109 );
110}
111
112/// Methods declared on superclass `NSObject`.
113impl AVMIDIPlayer {
114 extern_methods!(
115 #[unsafe(method(init))]
116 #[unsafe(method_family = init)]
117 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
118
119 #[unsafe(method(new))]
120 #[unsafe(method_family = new)]
121 pub unsafe fn new() -> Retained<Self>;
122 );
123}