2014-10-16 112 views
-2

添加下載鏈接,所以這是玩家JWPlayer 5 - 如何在玩家

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" } ] }); 

我想補充一個下載鏈接按鈕,像球員本網站上,例如>>http://www.mp4upload.com/a6hxfn9hdxuy

的sript

你們能幫我嗎?

感謝前:d

+0

可能重複[JWPlayer - 定製listbar添加一個「下載」鏈接(http://stackoverflow.com/questions/22228024/jwplayer - 自定義 - listbar到外接一個下載鏈接) – Ben 2014-10-16 20:35:17

回答

1

這是很容易做到 - 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> 
0

我看這是JW5。這裏是一個插件,你可以使用,此文件保存爲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);