# Adding Media Content

## Content



You can add media content by creating a [C1MediaItem](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaItem.html) object and then setting its [C1MediaItem.MediaSource](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaItem.MediaSource.html) property to the location of your media file. In this topic, you will add a video file to the media player in the **Properties** window, in XAML, and in code.

**At Design Time (Visual Studio)**

To add video content, complete the following steps:

1.  Click the [C1MediaPlayer](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaPlayer.html) control once to select it.
2.  Find the **Items** property and click its ellipsis button ![Ellipsis.png](https://cdn.mescius.io/document-site-files/images/35d97b39-ed23-40ca-bb1b-90a2e9178ac1/adding_media_content_files/image001.png). The **Collection Editor: Items** dialog box opens.
3.  Click **Add** to add a **C1MediaItem** object the **C1MediaPlayer** control.
4.  In the **Properties** grid, set the following:
    *   Set the **MediaSource** property to "http://download.componentone.com/pub/Videos/Trevor%20Does%20Silverlight.wmv".
    *   Set the [C1MediaItem.Title](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaItem.Title.html) property to "Trevor Does Silverlight".
5.  Click the **OK** to close the **Collection Editor: Items** dialog box.
6.  Run the program and observe that content is loaded into the control.

**At Design Time (Blend)**

To add video content using Blend, complete the following steps:

1.  Click the [C1MediaPlayer](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaPlayer.html) control once to select it.
2.  Under the Properties panel, find the Items property and click its ellipsis button (…). The **C1MediaItem Collection Editor: Items** dialog box opens.
3.  Click **Add Another Item** to add a **C1MediaItem** object the **C1MediaPlayer** control.
4.  In the **Properties** grid, set the following:
    *   Set the [MediaSource](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaItem.MediaSource.html) property to " [http://download.componentone.com/pub/Videos/Trevor%20Does%20Silverlight.wmv](http://download.componentone.com/pub/Videos/Trevor%20Does%20Silverlight.wmv)".
    *   Set the [Title](/componentone/api/wpf/online-mediaplayer/dotnet-framework-api/C1.WPF.MediaPlayer.4.6.2/C1.WPF.MediaPlayer.C1MediaItem.Title.html) property to "Trevor Does Silverlight".
5.  Click the **OK** to close the **C1MediaItem Collection Editor: Items** dialog box.
6.  Run the project.

**In XAML**

To add video content using XAML, complete the following:

1.  Place the following markup between the `_<c1mediaplayer:C1MediaPlayer>_` and `_</c1mediaplayer:C1MediaPlayer>_` tags:
    
    ```xml
    <c1mediaplayer:C1MediaItem MediaSource="http://download.componentone.com/pub/Videos/Trevor%20Does%20Silverlight.wmv" Title="Trevor Does Silverlight" Name="C1MediaPlayer1" />
    ```
    
2.  Run the program and observe that content is loaded into the control.

**In Code**

To add video content using code, complete the following steps:

1.  Open the **Window1.xaml.cs** page and import the following namespace:
    
    ```vbnet
    Imports C1.WPF.MediaPlayer
    ```
    
    ```csharp
    using C1.WPF.MediaPlayer;
    ```
    
2.  Place the following code beneath the **InitializeComponent()** method:
    
    ```vbnet
    'Create a C1MediaItem object
     Dim C1MediaItem1 As New C1MediaItem()
    'Create a Uri object that contains the media file's path
    Dim Uri1 As New Uri("http://download.componentone.com/pub/Videos/Trevor%20Does%20Silverlight.wmv")
    'Set the C1MediaItems content source to the Uri object
    C1MediaItem1.MediaSource = Uri1
    'Name the media item
    C1MediaItem1.Title = "Trevor Does Silverlight"
    'Add the media item to the media player
    C1MediaPlayer1.Items.Add(C1MediaItem1)
    ```
    
    ```csharp
    //Create a C1MediaItem object
    C1MediaItem C1MediaItem1 = new C1MediaItem();
    //Create a Uri object that contains the media file's path
    Uri Uri1 =  new Uri("http://download.componentone.com/pub/Videos/Trevor%20Does%20Silverlight.wmv");
    //Set the C1MediaItems content source to the Uri object
    C1MediaItem1.MediaSource = Uri1;
    //Name the media item
    C1MediaItem1.Title = "Trevor Does Silverlight";
    //Add the media item to the media player
    c1MediaPlayer1.Items.Add(C1MediaItem1);
    ```
    
3.  Run the program and observe that content is loaded into the control.