问题
so this is the sript for the player
jwplayer("flvplayer").setup({
file: "$direct_link",
flashplayer: "$c->{site_url}/player/$name.swf",
image: "$file->{video_img_url}",
duration:"$file->{vid_length}",
width: $file->{vid_width},
height: $file->{vid_height},
provider: 'http',
modes: [ { type: "flash", src: "$c->{site_url}/player/$name.swf" },{ type: "html5", config: {file:'$direct_link','provider':'http'} }, { type: "download" } ] });
I want to add a download link button, like player on this website, example >> http://www.mp4upload.com/a6hxfn9hdxuy
Can you guys help me?
Thanks before :D
回答1:
This is easy to do - http://support.jwplayer.com/customer/portal/articles/1436999-example-adding-a-download-button
<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>
回答2:
I see this is for JW5. Here is a plugin you can use, save this file as download.js:
(function(jwplayer){
var template = function(player, div, config) {
var assets = {
download: "http://www.longtailvideo.com/sites/default/files/download.png"
}
var goDownload = function() {
var item = player.getPlaylistItem();
if(item['downloadlink']) {
document.location = item['downloadlink'];
} else if(config.link) {
document.location = config.link;
} else {
document.location = item.file;
}
};
function setup(evt) {
player.getPlugin("dock").setButton(
'downloadButton',
goDownload,
assets.download
);
};
player.onReady(setup);
this.resize = function(width, height) {};
};
jwplayer().registerPlugin('download', template);
})(jwplayer);
来源:https://stackoverflow.com/questions/26410651/jwplayer-5-how-to-add-download-link-at-the-player