PSPDFSoundAnnotation


@interface PSPDFSoundAnnotation : PSPDFAnnotation

A sound annotation (PDF 1.2) shall analogous to a text annotation except that instead of a text note, it contains sound recorded from the iOS device’s microphone or imported from a file.

To ensure maximum compatibility set the boundingBox for sound annotations to the same size Adobe Acrobat uses (20x15pt). PSPDFKit will always render sound annotations at a fixed size of 74x44pt, centered in the provided boundingBox.

Note

Make sure you configured Microphone Permissions in your app. See https://pspdfkit.com/guides/ios/current/getting-started/permissions/#toc_microphone-permissions for futher documentation.
  • Determines if recording annotations are available.

    Recording sound annotations are not available in all environments. E.g. when running inside an App Extension, sound annotations are unavailable as microphone access is disabled.

    See

    -initRecorder

    Declaration

    Objective-C

    @property (readonly, nonatomic, class) BOOL recordingAnnotationAvailable;

    Swift

    class var recordingAnnotationAvailable: Bool { get }

    Return Value

    YES if sound annotations are available, NO otherwise.

  • Initializes an empty sound annotation that can be recorded into.

    Warning

    Calling this initializer will throw an exception if +recordingAnnotationAvailable returns NO. Check this method before calling -initRecorder.

    See

    +recordingAnnotationAvailable

    Declaration

    Objective-C

    - (nonnull instancetype)initRecorderWithOptions:
        (nullable NSDictionary<NSString *, id> *)options;

    Swift

    init(recorderWithOptions options: [String : Any]? = nil)

    Return Value

    A new, empty instance of PSPDFSoundAnnotation.

  • Initializes an empty sound annotation that can be recorded into with a default option set.

    Declaration

    Objective-C

    - (nonnull instancetype)initRecorder;

    Swift

    init(recorder: ())
  • Initializes a sound annotation with the sound file located at the given URL.

    Use this method if you want to initialize a sound annotation that already has an existing sound file.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithURL:(nonnull NSURL *)soundURL
                                  error:(NSError *_Nullable *_Nullable)error;

    Swift

    init(url soundURL: URL, error: NSErrorPointer)

    Parameters

    soundURL

    The file URL to the sound file.

    error

    Upon return contains an error if the creation was not possible.

    Return Value

    A new sound annotation, ready to be played.

  • The annotation controller.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        PSPDFSoundAnnotationController *_Nonnull controller;

    Swift

    var controller: PSPDFSoundAnnotationController { get }
  • The sound icon name.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *iconName;

    Swift

    var iconName: String? { get set }
  • If the annotation is able to record audio

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL canRecord;

    Swift

    var canRecord: Bool { get }
  • URL to the sound content.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSURL *soundURL;

    Swift

    var soundURL: URL? { get }
  • The number of bits per sample value per channel. Default value: 16. 8 or 16 bits per channel are supported.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger bits;

    Swift

    var bits: UInt { get }
  • The sampling rate, in samples per second.

    Based on the PDF spec, 8000, 11,025, or 22,050 samples per second are most widely supported. Based on empiric testing, 44100 works great as well.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger rate;

    Swift

    var rate: UInt { get }
  • The number of sound channels. Default value: 1. The PDF spec supports 1 or 2 channels.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger channels;

    Swift

    var channels: UInt { get }
  • Encoding of the sound stream. Use PSPDFSoundAnnotationEncoding* for values.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *encoding;

    Swift

    var encoding: String? { get }
  • Loads bits, sample rate, channels, encoding from sound file.

    Declaration

    Objective-C

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

    Swift

    func loadAttributesFromAudioFile() throws
  • Get the direct sound data.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSData *soundData;

    Swift

    var soundData: Data? { get }