Example: Adding a Download Button

This example will show you how to allow users to easily download a video file. This button will be added with our addButton API call.


This example uses the addButton() API call to append an additional item to the player. The code to do so (With comments!) is as follows:

//This portion is what designates the graphic used for the button
//This portion determines the text that appears as a tooltip
   "Download Video", 
//This portion designates the functionality of the button itself
   function() {
//With the below code, we're grabbing the file that's currently playing
   window.location.href = playerInstance.getPlaylistItem()['file'];
//And finally, here we set the unique ID of the button itself.

Note that this API call will draw in whichever playlist item is currently loaded. This may cause issues if you're using an M3U8 or manifest file, but it is possible to set a static video file such as an MP4 instead.

Please sign in to leave your feedback for this article.

Still don't have JW Player? Get It Here