* Render an audio element inside the wrapper.
(node: PicNodeData, ctx: RenderContext, wrapper: HTMLElement)
| 269 | * Render an audio element inside the wrapper. |
| 270 | */ |
| 271 | function renderAudio(node: PicNodeData, ctx: RenderContext, wrapper: HTMLElement): void { |
| 272 | const audioUrl = resolveMediaUrl(node.mediaRId, ctx) |
| 273 | |
| 274 | if (audioUrl) { |
| 275 | // Show poster image if available |
| 276 | if (node.blipEmbed) { |
| 277 | const rel = ctx.slide.rels.get(node.blipEmbed) |
| 278 | if (rel) { |
| 279 | const mediaPath = resolveMediaPath(rel.target) |
| 280 | const data = ctx.presentation.media.get(mediaPath) |
| 281 | if (data && !isUnsupportedFormat(mediaPath)) { |
| 282 | const cached = getOrCreateBlobUrl(mediaPath, data, ctx.mediaUrlCache) |
| 283 | const img = document.createElement('img') |
| 284 | img.src = cached |
| 285 | img.style.width = '100%' |
| 286 | img.style.height = 'calc(100% - 32px)' |
| 287 | img.style.objectFit = 'contain' |
| 288 | wrapper.appendChild(img) |
| 289 | } |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | const audio = document.createElement('audio') |
| 294 | audio.src = audioUrl |
| 295 | audio.controls = true |
| 296 | audio.style.width = '100%' |
| 297 | audio.style.position = 'absolute' |
| 298 | audio.style.bottom = '0' |
| 299 | audio.style.left = '0' |
| 300 | wrapper.appendChild(audio) |
| 301 | } else { |
| 302 | renderPlaceholder(wrapper, 'Audio') |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /** |
| 307 | * Resolve a media URL from a relationship ID. |
no test coverage detected