// using ExCSS; using NetCorePpt; using static NetCorePptxTest.Modules.Constants; namespace NetCorePptxTest.Modules; public class DemoMedia { /// /// SLIDE 1= Various Video Formats /// /// public static void genSlide01(PptxGen pptx, bool all = true) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Media" }); if (all) { slide.addTable(new List> { new List { new TableCell { text= "Media Examples: Video Types", options= Constants.BASE_TEXT_OPTS_L }, Constants.BASE_TEXT_OPTS_R } }, Constants.BASE_TABLE_OPTS); slide.addNotes("API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-media.html\r\nIt's worth noting that even if a video file format is supported by PowerPoint, you may still encounter issues with playing the video if the video is encoded using a codec that is not supported by the computer you are using to present the slideshow. It's a good idea to test your slideshow on the computer you will be using to present it to ensure that your videos will play correctly."); } if (all) { var textOption1 = MergeTextOption(Constants.BASE_CODE_OPTS, new TextPropsOptions { x = 0.5, y = 0.6, h = 0.4, w = 3.56 }, Constants.TITLE_STYLE); slide.addText(new TextProps { text = "Type: m4v" }, textOption1); slide.addMedia(new MediaProps { x = 0.5, y = 1.0, h = 2.0, w = 3.56, type = MediaType.video, 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 }); if (all) { var textOption4 = MergeTextOption(Constants.BASE_CODE_OPTS, new TextPropsOptions { x = 9.3, y = 3.0, h = 0.4, w = 3.56 }, Constants.CODE_STYLE); slide.addText("no `cover` image provided", textOption4); } if (all) { // BOTTOM-ROW var textOption5 = MergeTextOption(Constants.BASE_CODE_OPTS, new TextPropsOptions { x = 0.5, y = 3.85, h = 0.4, w = 3.6 }, Constants.TITLE_STYLE); slide.addText("Type: mp4", textOption5); slide.addMedia(new MediaProps { x = 0.5, y = 4.25, h = 2.7, w = 3.6, type = MediaType.video, path = IMAGE_PATHS.sample_mp4.path, cover = Constants.COVER_VIDEO_MP4, }); } if (all) { var textOption6 = MergeTextOption(Constants.BASE_CODE_OPTS, new TextPropsOptions { x = 4.79, y = 3.85, h = 0.4, w = 3.6 }, Constants.TITLE_STYLE); slide.addText("Type: avi", textOption6); slide.addMedia(new MediaProps { x = 4.79, y = 4.25, h = 2.7, w = 3.6, type = MediaType.video, path = IMAGE_PATHS.sample_avi.path, }); } if (all) { var textOption7 = MergeTextOption(Constants.BASE_CODE_OPTS, new TextPropsOptions { x = 9.08, y = 3.85, h = 0.4, w = 3.75 }, Constants.TITLE_STYLE); slide.addText("Type: mov", textOption7); slide.addMedia(new MediaProps { x = 9.08, y = 4.25, h = 2.7, w = 3.75, type = MediaType.video, path = IMAGE_PATHS.sample_mov.path, }); } } /// /// SLIDE 2= Various Audio Typrs /// /// public static void genSlide02(PptxGen pptx) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Media" }); slide.addNotes("API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-media.html"); slide.addTable(new List> { new List { new TableCell { text = "Media Examples: Audio Types", options = Constants.BASE_TEXT_OPTS_L }, Constants.BASE_TEXT_OPTS_R }}, Constants.BASE_TABLE_OPTS); var textOption1 = MergeTextOption(Constants.BASE_CODE_OPTS, new TextPropsOptions { x = 0.5, y = 0.6, h = 0.4, w = 3.5 }, Constants.TITLE_STYLE); slide.addText("Type: mp3", textOption1); slide.addMedia(new MediaProps { x = 0.5, y = 1.0, h = 3.5, w = 3.5, type = MediaType.audio, path = IMAGE_PATHS.sample_mp3.path, cover = COVER_AUDIO, }); 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, type = MediaType.audio, path = IMAGE_PATHS.sample_wav.path, cover = Constants.COVER_AUDIO, }); //if (typeof window !== "undefined" && window.location.href.indexOf("gitbrent") > 0) //{ // // TEST USING LOCAL FILES (OFFICE.COM) // slide.addText('Audio= MP3 (path:"../media")', { x= 0.5, y= 4.6, w= 4.0, h= 0.4, color= "0088CC" }); // slide.addMedia(new MediaProps{ x= 0.5, y= 5.0, w= 4.0, h= 0.3, Type: EnumMediaType.audio, path= "media/sample.mp3" }); //} } /// /// SLIDE 3= YouTube /// /// public static void genSlide03(PptxGen pptx) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Media" }); var all = true; if (all) { slide.addNotes("API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-media.html"); slide.addTable(new List> { new List { new TableCell { text= "Media Examples: YouTube Embed", options= Constants.BASE_TEXT_OPTS_L }, Constants.BASE_TEXT_OPTS_R}}, Constants.BASE_TABLE_OPTS); } if (all) { var textOption1 = MergeTextOption(new TextPropsOptions { x = 0.5, y = 0.75, h = 5.6, w = 12.3 }, Constants.TITLE_STYLE); slide.addText("Online: YouTube", textOption1); // YouTube `link` is the embed URL (share > embed > copy URL like what you see below) slide.addMedia(new MediaProps { x = 2.1, y = 1.2, h = 5.1, w = 9.1, type = MediaType.online, link = "https://www.youtube.com/embed/g36-noRtKR4", cover = COVER_YOUTUBE }); } 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 { shape = ShapeType.rect, x = 0.0, y = 7.0, w = "100%", h = 0.53, color = "BF9000", fill = "FFFCCC", align = HAlign.center, fontSize = 12, }); } } /// /// SLIDE 3= Test large files are only added to export once
/// filesize s/b ~24mb(the size of a single big-earth.mp4 file (17MB) plus other media files) ///
/// public static void genSlide_Test_LargeMedia(PptxGen pptx) { var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Media" }); slide.addNotes("API Docs: https://gitbrent.github.io/PptxGenJS/docs/api-media.html"); slide.addTable(new List> { new List { new TableCell {text = "Media: Test: Large Files Only Added Once", options = Constants.BASE_TEXT_OPTS_L }, Constants.BASE_TEXT_OPTS_R }}, Constants.BASE_TABLE_OPTS); slide.addText(new TextProps { text = IMAGE_PATHS.big_earth_mp4.path }, new TextPropsOptions { x = 0.5, y = 0.5, w = 12.2, h = 1, fill = "EEEEEE", margin = 0, color = "000000", }); 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, // NOTE= Node will throw exception when using "/" 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, // NOTE= Node will throw exception when using "/" path }); } }