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:

‚Äč<script>
jwplayer().addButton(
//This portion is what designates the graphic used for the button
   "/uploads/myButton.png",
//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 = jwplayer().getPlaylistItem()['file'];
 },
//And finally, here we set the unique ID of the button itself.
"download"
);
</script>

 

Please sign in to leave your feedback for this article.

Still don't have JW Player? Get It Here