PSPDFSoundAnnotationController

Objective-C

@interface PSPDFSoundAnnotationController : NSObject

/// Stops any currently active recording or playback, except the sender.
/// If the sender is nil, all annotations are stopped.
+ (void)stopRecordingOrPlaybackForAllExcept:(nullable id)sender;

/// Checks if we have permission to record.
+ (void)requestRecordPermission:(nullable void (^)(BOOL granted))block;

PSPDF_EMPTY_INIT_UNAVAILABLE

- (instancetype)initWithSoundAnnotation:(PSPDFSoundAnnotation *)annotation NS_DESIGNATED_INITIALIZER;

/// The controlled sound annotation.
@property (nonatomic, weak, readonly) PSPDFSoundAnnotation *annotation;

/// The current playback state.
@property (nonatomic, readonly) PSPDFSoundAnnotationState state;

/// The duration of the audio playback
@property (nonatomic, readonly) NSTimeInterval playbackDuration;

/// Starts or resumes playback.
- (BOOL)startPlayback:(NSError **)error;

/// Pauses playback or recording.
- (void)pause;

/// Stops playback or recording.
- (BOOL)stop:(NSError **)error;

#if !TARGET_OS_WATCH

/// The audio player object. Only available if playback is ongoing or prepared.
@property (nonatomic, readonly, nullable) AVAudioPlayer *audioPlayer;

#endif

#if PSPDF_HAS_RECORDING_FEATURE

/// Starts or resumes recording.
- (BOOL)startRecording:(NSError **)error;

/// Discards the current recording.
- (void)discardRecording;

#endif

@end

Swift

class SoundAnnotationController : NSObject

Undocumented

  • Stops any currently active recording or playback, except the sender. If the sender is nil, all annotations are stopped.

    Declaration

    Objective-C

    + (void)stopRecordingOrPlaybackForAllExcept:(nullable id)sender;

    Swift

    class func stopRecordingOrPlaybackForAllExcept(_ sender: Any?)
  • Checks if we have permission to record.

    Declaration

    Objective-C

    + (void)requestRecordPermission:(nullable void (^)(BOOL))block;

    Swift

    class func requestRecordPermission(_ block: ((Bool) -> Void)? = nil)
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithSoundAnnotation:(PSPDFSoundAnnotation *)annotation NS_DESIGNATED_INITIALIZER;

    Swift

    init(soundAnnotation annotation: SoundAnnotation)
  • The controlled sound annotation.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly) PSPDFSoundAnnotation *_Nullable annotation;

    Swift

    weak var annotation: SoundAnnotation? { get }
  • The current playback state.

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFSoundAnnotationState state;

    Swift

    var state: SoundAnnotation.State { get }
  • The duration of the audio playback

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSTimeInterval playbackDuration;

    Swift

    var playbackDuration: TimeInterval { get }
  • Starts or resumes playback.

    Declaration

    Objective-C

    - (BOOL)startPlayback:(NSError *_Nullable *_Nullable)error;

    Swift

    func startPlayback() throws
  • Pauses playback or recording.

    Declaration

    Objective-C

    - (void)pause;

    Swift

    func pause()
  • Stops playback or recording.

    Declaration

    Objective-C

    - (BOOL)stop:(NSError *_Nullable *_Nullable)error;

    Swift

    func stop() throws
  • The audio player object. Only available if playback is ongoing or prepared.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) AVAudioPlayer *audioPlayer;

    Swift

    var audioPlayer: AVAudioPlayer? { get }
  • Starts or resumes recording.

    Declaration

    Objective-C

    - (BOOL)startRecording:(NSError *_Nullable *_Nullable)error;

    Swift

    func startRecording() throws
  • Discards the current recording.

    Declaration

    Objective-C

    - (void)discardRecording;

    Swift

    func discardRecording()