Video Annotations

RichMedia/Video Annotations

The default way to embed video into a PDF is by using RichMedia annotations. This annotation type can store and embed videos directly into the PDF and is supported on both iOS and Android. RichMedia annotations can be created with Adobe Acrobat and various similar tools.

PSPDFKit does not yet support creating RichMedia annotations, this is coming in a future update.

Download a sample file with an RichMedia video here. (Try with our free PDF Viewer apps)

Video annotation

Various customizations and RichMedia control actions are supported, such as show/hide controls.

Warning: Ensure the codex used is a standard MPG/H264 or similar type that is universally supported. Acrobat in most cases uses Flash as player technology which supports some lesser common, outdated formats as well.

Showing/Hiding Video Controls

By default, video controls are always shown. There might be documents with a flag set on the video annotation, to explicitely hide video controls. If you still want to show controls, this can be altered in the document itself, by setting the Playback Control Skin to "All Controls" in Adobe Acrobat.

Video annotation controls

Or you can edit the PSPDFLinkAnnotation object of the video, and set the controlsEnabled property. This property will either be enabled/disabled depending on the set control style of the annotation in the document.

You can use the following code snippet after creating the PSPDFDocument instance to enable controls for all rich media annotations in the document.

Copy
1
2
3
4
5
6
7
8
let allAnnotationsDictionary = document.allAnnotations(of: .richMedia)
let allAnnotations = allAnnotationsDictionary.flatMap { _, value in
    return value
}

allAnnotations.forEach { annotation in
    (annotation as? PSPDFRichMediaAnnotation)?.controlsEnabled = true
}
Copy
1
2
3
4
5
6
7
8
9
NSDictionary *allAnnotationsDictionary = [document allAnnotationsOfType:PSPDFAnnotationTypeRichMedia];
NSMutableArray *allAnnotations = [NSMutableArray array];
[allAnnotationsDictionary enumerateKeysAndObjectsUsingBlock: ^(NSNumber *key, NSArray *value, BOOL *stop) {
    [allAnnotations addObjectsFromArray:value];
}];

for (PSPDFRichMediaAnnotation *annotation in allAnnotations) {
    annotation.controlsEnabled = YES;
}

Autoplay

The PDF format defines autoplay in the RichMediaSettings Dictionary as RichMediaActivation. Supported activation conditions are both PO and PV, PSPDFKit makes no difference in these autoplay conditions and will trigger start once the page has appearared. (XA defines manual start, this is also used if the value is omitted)

PSPDFKit exposes this as flag on the annotation object.

Supported Audio/Video Formats

PSPDFKit passes the extracted audio or video material to the system player. Supported contex, bitrates and similar depend on your target platform and OS version. Both iOS and Android support most variations of mp3 audio and mp4 video formats, however please test content on an actual device. Support in Simulator/Emulator environments can be different.

Content Appearance

RichMedia (Video/Audio) annotations are usually displayed via embedded Flash controls, which is not supported on mobile. PSPDFKit will extract the content and has logic to interpret common parameters such as showing/hiding controls. There are a variety of different Flash players used, so it's not always possible to map all varianbles. Please ping support if you have a document that is not correctly interpreted.

RichMedia Annotations are defined in Adobe® Supplement to the ISO 32000 Specification, BaseVersion: 1.7 ExtensionLevel: 3.