Insert video in PowerPoint document

Spire.Presentation for .NET, a reliable .NET PPT component, enables you to generate, read, edit, convert even print your PPT documents without installing Microsoft PowerPoint on your machine. It also includes many useful features, for example, the functionality of inserting video in PPT document.

Video can be used in PPT document to create a more interesting and dynamic PowerPoint effect. Using the Spire.presention you can use the presentation.Slides[0].Shapes.AppendVideoMedia() method to insert video in your PPT document with C#, VB.NET. There is guide will introduce the method to insert video in PPT with C#, VB.NET via Spire.Presentation for .NET.

The main steps of method are:

Step 1 : Create PPT document.

Presentation presentation = new Presentation();

Step 2 :Use the presentation.Slides[0].Shapes.AppendVideoMedia(,) method to insert video.

presentation.Slides[0].Shapes.AppendVideoMedia(@"Spire.Doc Word to HTML.mp4", new RectangleF(100, 100, 20, 20));

Step 3: Add shape to show text and save the PPT document.

IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 250));
presentation.SaveToFile("video.pptx", FileFormat.Pptx2010);

Download and install Spire.Presentation for .NET and use below code to experience this method to insert video in PPT document.

The full code:

[C#]
using System.Drawing;
using System.IO;
using Spire.Presentation;
using Spire.Presentation.Drawing;
namespace InsertVideo
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();

            //set background Image
            string ImageFile = @"D:\Spire.Presentation\Demos\Data\bg.png";
            RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
            presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

            presentation.Slides[0].Shapes.AppendVideoMedia(@"Spire.Doc Word to HTML.mp4", new RectangleF(100, 100, 20, 20));

            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 250));
            shape.ShapeStyle.LineColor.Color = Color.White;
            shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None;
            shape.AppendTextFrame("The sample demonstrates how to Insert Video into PPT using Spire.Presentation.");

            shape.TextFrame.Paragraphs.Append(new TextParagraph());
            shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue. It includes Spire.Doc, Spire XLS, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer, and Spire.BarCode. Spire.Office contains the most up-to-date versions of the above .NET components."));
            foreach (TextParagraph para in shape.TextFrame.Paragraphs)
            {
                para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold");
                para.TextRanges[0].Fill.FillType = FillFormatType.Solid;
                para.TextRanges[0].Fill.SolidColor.Color = Color.Black;
                para.Alignment = TextAlignmentType.Left;
                para.Indent = 35;
            }

            presentation.SaveToFile("video.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("video.pptx");
        }
    }
}
[VB.NET]
Imports System.Drawing
Imports System.IO
Imports Spire.Presentation
Imports Spire.Presentation.Drawing
Module Module1

    Sub Main()
        Dim presentation As New Presentation()

        'set background Image
        Dim ImageFile As String = "D:\Spire.Presentation\Demos\Data\bg.png"
        Dim rect As New RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height)
        presentation.Slides(0).Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect)
        presentation.Slides(0).Shapes(0).Line.FillFormat.SolidFillColor.Color = Color.FloralWhite

        presentation.Slides(0).Shapes.AppendVideoMedia("Spire.Doc Word to HTML.mp4", New RectangleF(100, 100, 20, 20))

        Dim shape As IAutoShape = presentation.Slides(0).Shapes.AppendShape(ShapeType.Rectangle, New RectangleF(50, 150, 600, 250))
        shape.ShapeStyle.LineColor.Color = Color.White
        shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None
        shape.AppendTextFrame("The sample demonstrates how to Insert Video into PPT using Spire.Presentation.")

        shape.TextFrame.Paragraphs.Append(New TextParagraph())
        shape.TextFrame.Paragraphs(1).TextRanges.Append(New TextRange("Spire.Office for .NET is a compilation of Enterprise-Level Office .NET component offered by E-iceblue. It includes Spire.Doc, Spire XLS, Spire.PDF, Spire.DataExport, Spire.PDFViewer, Spire.DocViewer, and Spire.BarCode. Spire.Office contains the most up-to-date versions of the above .NET components."))
        For Each para As TextParagraph In shape.TextFrame.Paragraphs
            para.TextRanges(0).LatinFont = New TextFont("Arial Rounded MT Bold")
            para.TextRanges(0).Fill.FillType = FillFormatType.Solid
            para.TextRanges(0).Fill.SolidColor.Color = Color.Black
            para.Alignment = TextAlignmentType.Left
            para.Indent = 35
        Next

        presentation.SaveToFile("video.pptx", FileFormat.Pptx2010)
        System.Diagnostics.Process.Start("video.pptx")
    End Sub

End Module

If you couldn't successfully use the Spire.presentation, please refer the Spire.Presentation Quick Start which can guide you quickly use the Spire.presentation.