From d8ea2afe477b7f8bc995f010506f7faec34a7ebd Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 23 Jun 2026 12:04:09 +0200 Subject: [PATCH] Add support for Screen annotations playing embedded media Screen annotations whose rendition action resolves to an embedded audio/video file now play through the same play-button overlay as RichMedia. Factor the shared resolution logic into a MediaAnnotation base (used by both RichMedia and Screen). It fixes #6078 and #2787. --- src/core/annotation.js | 347 +++++++++++++++---- src/core/file_spec.js | 10 + src/display/annotation_layer.js | 15 +- src/shared/util.js | 11 + test/integration/annotation_spec.mjs | 63 +++- test/integration/presentation_mode_spec.mjs | 11 +- test/unit/annotation_spec.js | 365 +++++++++++++++++++- web/annotation_layer_builder.css | 10 +- web/annotation_layer_builder.js | 2 +- web/pdf_presentation_mode.js | 6 +- web/viewer.css | 2 +- 11 files changed, 737 insertions(+), 105 deletions(-) diff --git a/src/core/annotation.js b/src/core/annotation.js index 6761df712..8eed43b5e 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -19,6 +19,7 @@ import { AnnotationEditorType, AnnotationFieldFlag, AnnotationFlag, + AnnotationRenditionOperation, AnnotationReplyType, AnnotationType, assert, @@ -290,6 +291,9 @@ class AnnotationFactory { case "RichMedia": return new RichMediaAnnotation(parameters); + case "Screen": + return new ScreenAnnotation(parameters); + default: if (!collectFields) { if (!subtype) { @@ -5457,13 +5461,124 @@ class FileAttachmentAnnotation extends MarkupAnnotation { } } -class RichMediaAnnotation extends Annotation { +/** + * Shared base for annotations that play an embedded audio/video clip: + * `RichMedia` (via `RichMediaContent`) and `Screen` (via a rendition action). + * Both resolve a single embedded media file and expose it identically through + * `data.richMedia`, so the display layer can render them with one element. + */ +class MediaAnnotation extends Annotation { + // The MIME types we can build a `