ComponentOne MediaPlayer for WPF and Silverlight
C1MediaPlayer Task-Based Help / Adding Media Content
In This Topic
    Adding Media Content
    In This Topic

    You can add media content by creating a C1MediaItem object and then setting its C1MediaItem.MediaSource 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 control once to select it.
    2. Find the Items property and click its ellipsis button Ellipsis.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 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 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:
    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:        
      XAML
      Copy Code
      <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:

      Visual Basic
      Copy Code
      Imports C1.WPF.MediaPlayer
      

      C#
      Copy Code
      using C1.WPF.MediaPlayer;
      

       

    2. Place the following code beneath the InitializeComponent() method:

       

      Visual Basic
      Copy Code
      '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)
      

       

      C#
      Copy Code
      //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.