Create videos

To create a video, you perform the following:

  1. Check whether the video already exists.
    Before you create the video, you must check whether a video with the same ID already exists.

  2. Create the video.
    If the video does not exist, you create a new video with the specified ID.

  3. Specify the parent video library of the video.
    Specify the library where the video belongs to.

  4. Set the required properties.
    When creating a new video, we recommend to set at least the following properties:

    • Title
    • LastModified
    • DateCreated
    • UrlName
    •  MediaFileUrlName
      You can also set any other properties in this step.
  5. Upload the video.
    Upload the video data to the database.

  6. Save the video.
    Save all changes that you have made to the video.

  7. Publish the video.
    Finally, you publish the video using the workflow manager.

EXAMPLE: Create a video with predefined ID.
The example below shows how to create a video with predefined ID.

NOTE: The ID argument is assigned to the master version of the video. For more information about the different versions of a video, see For developers: Content lifecycle.

The following code creates a video with the specified IDTitle and video data.

Native API

First, you get an instance of the LibrariesManager class. You check whether a video with the same ID already exists. Then, to create the video, you must call the CreateVideo method of the LibrariesManager class. You can create a video with either predefined or auto-generated ID, depending on which overload of the method you use. The method returns the master version of the video. Then, you get an instance of the specified parent video library. To associate the video with the video library, you set the video library to the Parent property of the video object. Then, you set the properties of the master version. It is recommended to set at least the following properties: TitleUrlNameLastModifiedPublicationDateDateCreated, MediaFileUrlName. Then, to upload the video data, you call the Upload method of the LibrariesManager class and pass the video, the stream of the selected file and its extension as parameters. To save the changes, you call the SaveChanges method of the manager. Finally, to publish the video, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.

Fluent API

First, you check whether a video with the same ID already exists. Then, you check whether the specified parent video library exists. If it exists you get the singular video library facade of the parent video library. To create the video, you call the CreateVideo method of the facade. The ID argument is assigned to the ID property of the master version of the item. You check out the item. Then, you set the properties of the video by calling the Do method of the facade. To upload the video data, you call the UploadContent method of the facade and pass the video, the stream of the selected file and its extension as an arguments. To check in the video, you call the CheckIn method of the facade. Then, you save the changes. Finally, to publish the video, you call the MessageWorkflow method of the WorkflowManager class and pass the required parameters.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?

Next article

Query videos