Video Annotations


RichMedia/Video Annotations

The default way to embed video into a PDF is by using RichMedia annotations. This annotation type allows to 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;
}
Was this page helpful? We're happy to answer any questions.