jwplayer 6:获取文件名

时间:2013-05-20 19:36:57

标签: javascript jwplayer

是否可以获取当前jwplayer加载文件的文件名?

jwplayer('player_1').setup({
  width: 640,
  height: 480,
  file: "http://domain.com/filename.mp4"
});

我遇到了这个http://www.longtailvideo.com/support/jw-player/28851/javascript-api-reference#playlist,但不确定这是否适用于我的情况。

alert(jwplayer('player_1').getPlaylistItem().index);

2 个答案:

答案 0 :(得分:4)

没关系。想出来了:

var theFile;
if(jwplayer('player_1').config.levels){
  theFile = jwplayer('player_1').getPlaylistItem()['levels'][0]['file'];
} 
else {
  theFile = jwplayer('player_1').getPlaylistItem()['file'];
}

alert(theFile);

答案 1 :(得分:0)

jwplayer('player_1').onPlaylistItem(function(event){

     index = jwplayer('player_1').getPlaylistIndex();
     item = jwplayer('player_1').getPlaylistItem(index);

     theFile = item.file;
     alert(theFile);
 });