Media — Video & Audio

Embed video and audio files with cover frames, or stream online media (YouTube) inside a slide.

Demo class DemoMedia Source file Modules/DemoMedia.cs Slide methods genSlide01 – genSlide03 Output files media_genSlide*.pptx

1Overview

DemoMedia adds slides with slide.addMedia(new MediaProps { … }). MediaProps carries the media type, the file path (from Constants.IMAGE_PATHS) and an optional cover image for the poster frame.

genSlide01/02 cycle through the supported file formats (video: m4v & friends, audio: aiff/wav); genSlide03 shows online media and genSlide_Test_LargeMedia checks that oversized files are only embedded once.

2Demo methods

MethodWhat it demonstrates
genSlide01(all)Video formats — MediaType.video with optional cover frame.
genSlide02(all)Audio types — MediaType.audio with a round cover (aiff/wav).
genSlide03(all)YouTube — MediaType.online with an embed link.
genSlide_Test_LargeMediaLarge-media regression — big files are embedded only once.

3Code samples

Video + cover MediaType.video with an optional cover image frame. DemoMedia.cs · genSlide01
				path = IMAGE_PATHS.sample_m4v.path, cover = COVER_VIDEO_16X9
			});
		}

		if (all)
		{
			var textOption2 = MergeTextOption(Constants.BASE_CODE_OPTS,
				new TextPropsOptions { x = 0.5, y = 3.0, h = 0.4, w = 3.56 }, Constants.CODE_STYLE);
			slide.addText("`cover` image provided", textOption2);
		}

		if (all)
		{
			var textOption3 = MergeTextOption(Constants.BASE_CODE_OPTS,
				new TextPropsOptions { x = 9.3, y = 0.6, h = 0.4, w = 3.56 }, Constants.TITLE_STYLE);
			slide.addText("Type: m4v", textOption3);
		}
		slide.addMedia(new MediaProps 
		{
			x = 9.3, y = 1.0, h = 2.0, w = 3.56, type = MediaType.video,
			path = IMAGE_PATHS.sample_m4v.path
		});
Audio formats MediaType.audio with a round cover (aiff/wav). DemoMedia.cs · genSlide02
		});

		var textOption2 = MergeTextOption(Constants.BASE_CODE_OPTS,
			new TextPropsOptions { x = 4.92, y = 0.6, h = 3.9, w = 3.5 }, Constants.TITLE_STYLE);
		slide.addText("Type: aiff", textOption2);
		slide.addMedia(new MediaProps {
			x = 4.92,
			y = 1.0,
			h = 3.5,
			w = 3.5,
			type = MediaType.audio,
			path = IMAGE_PATHS.sample_aif.path,
			cover = Constants.COVER_AUDIO_ROUND,
		});

		var textOption3 = MergeTextOption(Constants.BASE_CODE_OPTS, 
			new TextPropsOptions { x = 9.33, y = 0.6, h = 0.4, w = 3.5 }, Constants.TITLE_STYLE);
		slide.addText("Type: wav", textOption3);
		slide.addMedia(new MediaProps {
			x = 9.33,
			y = 1.0,
			h = 3.5,
			w = 3.5,
YouTube (online) MediaType.online with a YouTube embed link. DemoMedia.cs · genSlide03
		var textOption2 = MergeTextOption(Constants.BASE_CODE_OPTS,
			new TextPropsOptions { x = 0.5, y = 6.35, h = 0.4, w = 12.3 }, Constants.CODE_STYLE);
		textOption2.align = HAlign.center;
		slide.addText(@"slide.addMedia({ type: ""online"", link: ""https://www.youtube.com/embed/g36-noRtKR4"" })", textOption2);

		if (all)
		{
			// FOOTER
			slide.addText("Note: YouTube videos require newer versions of PowerPoint (v16+/M365). Older versions will show content warning messages.",
				new TextPropsOptions {
Large media (added once) A big video referenced from two cells; the same file is packaged once in the deck. DemoMedia.cs · genSlide_Test_LargeMedia
        slide.addMedia(new MediaProps {
            x = 0.5, y = 2.0, w = 6, h = 3.38,
            type = MediaType.video,
            path = IMAGE_PATHS.big_earth_mp4.path,
            cover = COVER_VIDEO_16X9,
        });
        slide.addMedia(new MediaProps {
            x = 6.83, y = 2.0, w = 6, h = 3.38,
            type = MediaType.video,
            path = IMAGE_PATHS.big_earth_mp4.path,
        });

4Key notes

!

MediaProps drives everything: type = MediaType.video | audio | online, path = media file, cover = poster image (video) or artwork (audio).

!

Online (YouTube) media requires PowerPoint v16+/Microsoft 365; older versions show a content warning — the demo prints this note onto the slide.

!

Cover images come in two sizes from Constants (COVER_VIDEO_16X9, COVER_AUDIO_ROUND) so every media cell keeps a consistent aspect ratio.

!

The large-media test asserts the deck stays ~24 MB — i.e. the 17 MB big-earth.mp4 is packaged once even when several slides reference it.