Media Block
About 1086 words
- Type ID:
4 - Type: Map
Media places an external resource on the page: an image, an SVG, a page of a PDF, audio or video. The main file stores only the resource's path, position, size and playback parameters; the resource itself is kept in the resource package filename.uink.extra.
Levels
- Standard: images (PNG, JPEG, SVG) and their
width,height,transform,opacity,fit,crop. - Full: PDF pages, audio, video and playback parameters.
- Core and Basic readers skip Media.
Fields
Common fields
| Field | Type | Requirement | Level | Description |
|---|---|---|---|---|
type | uint16 | Required | Standard | Always 4 |
contentId | uint32 | Required | Standard | Content sequence number shared with Ink, Shape and Clear (INK-2) |
undoId | uint32 | Required | Standard | Undo group number (INK-3) |
path | string | Required | Standard | Path of the resource in the resource package (EXTRA-3, EXTRA-4) |
mimeType | string | Required | Standard | MIME type of the resource, for example image/png |
extra | Map | Optional | — | App-private fields |
Visual media
Images, SVG, PDF pages and video add:
| Field | Type | Requirement | Level | Description |
|---|---|---|---|---|
width | float32 | Required | Standard | Box width before transform, greater than 0 |
height | float32 | Required | Standard | Box height before transform, greater than 0 |
transform | Array<float32>(6) | Optional | Standard | Affine matrix; defaults to the identity matrix |
opacity | float32 | Optional | Standard | 0–1; defaults to 1 |
fit | int32 | Optional | Standard | How the resource fits into the box; defaults to 0 Fill |
crop | Map | Optional | Standard | Show only part of the resource, see below |
fit
| Value | Name | Effect |
|---|---|---|
0 | Fill | Stretched to fill the box, aspect ratio not kept |
1 | Contain | Aspect ratio kept, fully inside the box, centered; empty space transparent |
2 | Cover | Aspect ratio kept, fills the box, centered; overflow cropped |
3 | None | At the resource's original pixel size (1 resource pixel = 1 Canvas unit), placed at the top-left corner of the box; overflow cropped |
4–127 | Reserved | — |
128+ | Private | — |
width: 150 height: 240fit: 0 FillStretched to fill the box, ignoring the aspect ratio.x: 0, y: 0, width: 150, height: 240crop
| Field | Type | Requirement | Description |
|---|---|---|---|
x | float32 | Required | X of the top-left corner of the crop area |
y | float32 | Required | Y of the top-left corner of the crop area |
width | float32 | Required | Width of the crop area, greater than 0 |
height | float32 | Required | Height of the crop area, greater than 0 |
Units are the resource's own coordinates: pixels for bitmaps, viewBox units for SVG, points (1/72 inch) for PDF pages.
PDF pages (Full)
| Field | Type | Requirement | Description |
|---|---|---|---|
pageCount | uint32 | Optional | Total number of pages in the document, greater than 0 |
pageIndex | uint32 | Optional | Page currently shown, starting at 0; defaults to 0 |
Audio and video (Full)
| Field | Type | Default | Description |
|---|---|---|---|
autoplay | bool | false | Play automatically when the page opens |
loop | bool | false | Loop playback |
volume | float32 | 1 | Volume, 0–1 |
startTime | float64 | 0 | Start position, in seconds |
playbackRate | float32 | 1 | Playback speed, a finite positive number |
Rules
Geometry
MEDIA-1 The box of visual media is the rectangle with top-left corner
(0, 0)and bottom-right corner(width, height), in Canvas units. First take part of the resource according tocrop, then fit it into the box according tofit, finally applytransform, and map it with the page'sviewport(CANVAS-17).MEDIA-2
transformis stored as[a, b, c, d, e, f]:x' = a × x + c × y + e y' = b × x + d × y + fThe matrix handles scaling, rotation, skew and translation. When it is missing, its length is not 6, or it contains non-finite numbers, the identity matrix is used and a warning is reported.
MEDIA-3 When
cropextends beyond the resource, its intersection with the resource is used; when the intersection is empty or the fields are invalid,cropis ignored. An unknownfitis treated as Fill.
Content order
- MEDIA-4 Media shares
contentIdandundoIdwith Ink, Shape and Clear and is drawn in object stream order (FILE-14). - MEDIA-5 Erase Ink does not affect Media (INK-11); Clear clears earlier Media.
Resources
- MEDIA-6 When the resource package, an entry or the resource is unavailable, keep the Media's position and order and indicate that the resource is missing; strokes, shapes and other Media must not be affected (EXTRA-11).
- MEDIA-7 SVG is handled as a static image (EXTRA-9).
- MEDIA-8 UInk registers
application/pdfas the standard document type. Other documents such as Word and PowerPoint may be used as private types, with no guarantee of interoperability across apps.
PDF and playback
- MEDIA-9 When the PDF can be parsed, the actual page count is authoritative; when it disagrees with
pageCount, the actual page count is used and a warning is reported. An out-of-rangepageIndexis clamped to the valid range. When the resource is missing,pageCountandpageIndexmay be used to show a page-number placeholder. - MEDIA-10 Clamp
startTimeto the range from0to the media duration; an invalidplaybackRatebecomes1. - MEDIA-11 Autoplay may be restricted by platform permissions, muting policies or user settings; failing to autoplay is not an error.
Error tolerance
- MEDIA-12 A finite but out-of-range
opacityorvolumeis clamped to0–1. - MEDIA-13 A Media missing
pathormimeType, or visual media missingwidth/height, is skipped and a warning is reported, without affecting the following content.
Saving
- MEDIA-14 When Media is present, a full save follows the resource package commit order.
Example
{
"type": 4,
"contentId": 2,
"undoId": 1,
"path": "images/diagram.png",
"mimeType": "image/png",
"width": 800.0,
"height": 450.0,
"transform": [1.0, 0.0, 0.0, 1.0, 120.0, 80.0],
"opacity": 0.9,
"fit": 1, // Contain
"crop": { "x": 0.0, "y": 40.0, "width": 1600.0, "height": 900.0 }
}{
"type": 4,
"contentId": 3,
"undoId": 2,
"path": "documents/lesson.pdf",
"mimeType": "application/pdf",
"width": 1280.0,
"height": 720.0,
"transform": [1.0, 0.0, 0.0, 1.0, 80.0, 60.0],
"pageCount": 24,
"pageIndex": 5
}{
"type": 4,
"contentId": 4,
"undoId": 3,
"path": "audio/explanation.mp3",
"mimeType": "audio/mpeg",
"volume": 0.8,
"startTime": 2.5
}Fallback
| Capability the reader lacks | How it is shown |
|---|---|
| Media (Core, Basic) | Skipped |
| PDF, audio, video (Standard) | Layout placeholder kept, with an "unsupported" notice |
When exporting to Core or Basic, Media may be removed; a PDF may have its current page rasterized to PNG. See Compatible export.