DocumentBuilderInsertOnlineVideo Method (String, String, Byte, Double, Double)
Inserts an online video object into the document and scales it to the specified size.

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.10
Syntax
public Shape InsertOnlineVideo(
	string videoUrl,
	string videoEmbedCode,
	byte[] thumbnailImageBytes,
	double width,
	double height
)

Parameters

videoUrl
Type: SystemString
The URL to the video.
videoEmbedCode
Type: SystemString
The embed code for the video.
thumbnailImageBytes
Type: SystemByte
The thumbnail image bytes.
width
Type: SystemDouble
The width of the image in points. Can be a negative or zero value to request 100% scale.
height
Type: SystemDouble
The height of the image in points. Can be a negative or zero value to request 100% scale.

Return Value

Type: Shape
The image node that was just inserted.
Remarks

You can change the image size, location, positioning method and other settings using the Shape object returned by this method.

Examples
Show how to insert online video into a document using html code
[C#]

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Visible url
string vimeoVideoUrl = @"https://vimeo.com/52477838";

// Embed Html code
string vimeoEmbedCode =
    "<iframe src=\"https://player.vimeo.com/video/52477838\" width=\"640\" height=\"360\" frameborder=\"0\" title=\"Aspose\" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>";

// This video will have an automatically generated thumbnail, and we are setting the size according to its 16:9 aspect ratio
builder.Writeln("Video with an automatically generated thumbnail at the top left corner of the page:");
builder.InsertOnlineVideo(vimeoVideoUrl, RelativeHorizontalPosition.LeftMargin, 0,
    RelativeVerticalPosition.TopMargin, 0, 320, 180, WrapType.Square);
builder.InsertBreak(BreakType.PageBreak);

// We can get an image to use as a custom thumbnail
using (WebClient webClient = new WebClient())
{
    byte[] imageBytes = webClient.DownloadData(AsposeLogoUrl);

    using (MemoryStream stream = new MemoryStream(imageBytes))
    {
        using (Image image = Image.FromStream(stream))
        {
            // This puts the video where we are with our document builder, with a custom thumbnail and size depending on the size of the image
            builder.Writeln("Custom thumbnail at document builder's cursor:");
            builder.InsertOnlineVideo(vimeoVideoUrl, vimeoEmbedCode, imageBytes, image.Width, image.Height);
            builder.InsertBreak(BreakType.PageBreak);

            // We can put the video at the bottom right edge of the page too, but we'll have to take the page margins into account 
            double left = builder.PageSetup.RightMargin - image.Width;
            double top = builder.PageSetup.BottomMargin - image.Height;

            // Here we use a custom thumbnail and relative positioning to put it and the bottom right of tha page
            builder.Writeln("Bottom right of page with custom thumbnail:");

            builder.InsertOnlineVideo(vimeoVideoUrl, vimeoEmbedCode, imageBytes,
                RelativeHorizontalPosition.RightMargin, left, RelativeVerticalPosition.BottomMargin, top,
                image.Width, image.Height, WrapType.Square);
        }
    }
}

doc.Save(ArtifactsDir + "DocumentBuilder.InsertOnlineVideo.docx");
See Also