# Online Video

DsWord is a Document Solutions product that offers a high performance library to create, load, modify, and save Word documents programmatically.

## Content

DsWord allows you to insert and play online videos directly from the document without leaving the document. You can add an online video to the document by inserting the URL of the video into the picture created with [Picture](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Picture.html) class using [SetUrl](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.WebVideoProperties.SetUrl.html) method of [WebVideoProperties](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.WebVideoProperties.html) class.
**SetUrl** method has three overloads, allowing you to specify the input URL, title, height, and width of the video. This method generates the appropriate [EmbeddedHtml](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.WebVideoProperties.EmbeddedHtml.html) property string internally, providing a convenient way for you to define these parameters that may be challenging to write directly.

> !type=note
> **Note:** EmbeddedHtml property will receive width and height either from parameters or directly from [Width](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.WebVideoProperties.Width.html) and [Height](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.WebVideoProperties.Height.html) properties of WebVideoProperties class when you use an overload without them. EmbeddedHtml, Width, and Height properties are serialized as distinct OpenXML tags.

Refer to the following example code to insert the URL of the video to add online video to the document:

```csharp
// Initialize GcWordDocument.
var doc = new GcWordDocument();

// Add picture to document.
var image = doc.Body.Paragraphs.Add().AddRun().AddPicture();
            
// Set poster frame image.
byte[] imageBytes1 = File.ReadAllBytes("sunrise.jpg");
image.ImageData.SetImage(imageBytes1, contentType: "image/jpg");

// Add online video Url and set title, width, and height.
image.ImageData.WebVideoProperties.SetUrl("https://www.youtube.com/watch?v=gsnqXt7d1mU&list=PL4Gr5tOAPttLOY9IrWVjJlv4CtkYI5cI_&index=2", "Sunrise", 600, 300);

// Save the document.
doc.Save("OnlineVideo.docx");
```

![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/online-video.gif)

## Customize Hyperlink Action

DsWord provides **HyperlinkOnClick** and **HyperlinkOnHover** properties of Shape classes such as [Shape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Shape.html), [Picture](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Picture.html), [GroupShape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.GroupShape.html), [CanvasShape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.CanvasShape.html), and [InkShape](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.InkShape.html), which are derived from [ShapeBase](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeBase.html), that enable you to customize or redefine the click and hover action of the hyperlink.
You can also add and define hyperlinks to other shapes using the properties of [HyperlinkOnAction](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.HyperlinkOnAction.html) class. For more information, see [Shape Hyperlink](/document-solutions/dot-net-word-api/docs/online/features/shapes/ShapeHyperlink).
Refer to the following example code to redefine click and hover actions:

```csharp
// Initialize GcWordDocument.
var doc = new GcWordDocument();

// Add picture to document.
var image = doc.Body.Paragraphs.Add().AddRun().AddPicture();
image.Size.Width.Value = 500f;
image.Size.Height.Value = 500f;

// Set poster frame image.
byte[] imageBytes1 = File.ReadAllBytes("sunrise.jpg");
image.ImageData.SetImage(imageBytes1, contentType: "image/jpg");

// Add online video Url.
image.ImageData.WebVideoProperties.SetUrl("https://www.youtube.com/watch?v=gsnqXt7d1mU&list=PL4Gr5tOAPttLOY9IrWVjJlv4CtkYI5cI_&index=2", "Sunrise");

// Set new address for the hyperlink.
var newUrl = new Uri("https://www.youtube.com/watch?v=5p_SuO96Jd4&pp=ygUHc3VucmlzZQ%3D%3D", UriKind.RelativeOrAbsolute);
image.HyperlinkOnClick.Address = newUrl;

// Set new screen tip.
image.HyperlinkOnHover.ScreenTip = "screen tip";

// Save the document.
doc.Save("RedefinedHyperlink.docx");
```

**Limitations**
Microsoft Word ignores the parameters of SetUrl method (width, height, and title) and Width and Height properties. The effects of these parameters and properties may be visible in alternative applications that also work with Word files.