MCPcopy Index your code
hub / github.com/simstudioai/sim / renderAudio

Function renderAudio

apps/sim/lib/pptx-renderer/renderer/image-renderer.ts:271–304  ·  view source on GitHub ↗

* Render an audio element inside the wrapper.

(node: PicNodeData, ctx: RenderContext, wrapper: HTMLElement)

Source from the content-addressed store, hash-verified

269 * Render an audio element inside the wrapper.
270 */
271function 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.

Callers 1

renderImageFunction · 0.85

Calls 6

resolveMediaPathFunction · 0.90
getOrCreateBlobUrlFunction · 0.90
resolveMediaUrlFunction · 0.85
isUnsupportedFormatFunction · 0.85
renderPlaceholderFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected