Enhancing Video Accessibility: Control Video Downloads with api.video
Enhancing Video Accessibility: Control Video Downloads with api.video
Learn how you and your users can have full control over video accessibility, and how you can enable or disable video downloads for your viewers in this short tutorial.
Video content is a critical digital media component, offering a dynamic way to share information and engage with audiences. api.video provides a robust video on demand platform, where you and your users can have full control over video accessibility. You can enable viewers to download the source videos directly from the api.video player, or from the player of your choice. Improve user experience and drive engagement in your solution by enabling viewers to access videos offline, or give content creators the ability to create backups of their media. It also works the other way around - you have the ability to disable video download functionality altogether and restrict access to the video source file, if that suits your use case better.
This article will explain the ways you can enable or disable video downloading through the api.video player using our API and the Dashboard, and will also give you a simple example for creating a custom download button for the player of your choice.
Download access control with a single setting
api.video simplifies the process of offering downloadable videos by providing a single property that can be set to either true or false when a video is uploaded. The mp4Support property decides whether your viewers can access and download the source file a of a video. When enabled, this feature introduces a download button directly on the api.video player, allowing viewers to download videos with a single click. Setting the property to false on the other hand disables the download option, giving creators more control over the distribution of their content.
The
mp4Supportproperty is enabled by default for all video uploads.
Control downloads via the API
Let’s dive into how you can control video downloads programmatically when integrating with one of api.video’s API clients.
This example uses api.video’s Node.Js API client. Check out our Libraries & SDKs for a complete list of available API clients.
Utilizing api.video’s /videos endpoint, you can enable or disable downloads for individual videos during upload, or you can update an already uploaded video to change download permissions.
Let’s see how this process looks like when uploading a video:
- Create a video object and define the
mp4Supportproperty
// Documentation: https://github.com/apivideo/api.video-nodejs-client/blob/main/doc/api/VideosApi.md#create
const client = new ApiVideoClient({ apiKey: "YOUR_API_KEY" });
// create a video using all available attributes
const video = await client.videos.create({
title: "My video", // The title of your new video.
m4Support: false // In this example, downloads will be disabled.
});
- Upload the video source file
const file = './my-video.mp4'; // The path to the video you would like to upload. The path must be local. If you want to use a video from an online source, you must use the "/videos" endpoint and add the "source" parameter when you create a new video.
const videoId = video.id
const upload = await client.videos.upload(videoId, file)
Now let’s see how the same thing looks like for a video that is already hosted on api.video:
// First install the "@api.video/nodejs-client" npm package
// Documentation: https://github.com/apivideo/api.video-nodejs-client/blob/main/doc/api/VideosApi.md#update
const client = new ApiVideoClient({ apiKey: "YOUR_API_KEY" });
const videoId = 'vi4k0jv....TdRAEjQ4Jfrgz'; // The video ID for the video you want to update.
// define the value you want to update
const videoUpdatePayload = {
mp4Support: true, // Let's enable downloads!
};
const updatedVideo = await client.videos.update(videoId, videoUpdatePayload);
Check out the API reference for more details about the
/videosendpoint, and take a look at the Video Download guide’s examples for other API clients.
Enable downloads through the Dashboard
When you are hosting your own content at api.video, the Dashboard gives you granular control over every video that you upload. Check out the Videos page to see a list of all your uploaded videos!
Let’s see how you can modify download access without writing a single line of code:
Open the Details view for any specific video where you want to enable or disable download access:
On the Video details page, click on the Update video object button:
Modify the
MP4 supportsetting with a simple toggle and click on Update Video to save your changes:
Once you save your changes, the download button will appear for this video in the api.video player.
Create a custom download button
Most video player solutions have native support for downloading the video’s source file. However, you can also add a download button to a custom player that does not have this functionality.
Leverage api.video’s API by sending a request that retrieves the video’s id, and then render a custom download button serves the mp4 asset for video.
Check out the Video download guide for a step-by-step walkthrough on how to create a custom download button using Node.Js, api.video’s Node.Js API client, npm, and React.
Conclusion
The ability to enable or disable video downloads is a fundamental aspect of content management, and api.video is here to offer a simple and intuitive solution for both developers and content creators.
Explore the capabilities of api.video! Check out our documentation, browse through the available Libraries & SDKs, and sign up to get started for free.
Start with api.video today to deliver a comprehensive, feature-rich video on demand service. The team is readily available to assist you with any inquiries or to help you discover the full potential of api.video.