我想构建一个文件浏览器,它在单击时显示有关文件的信息。然后文件本身应该通过 PHP 加载到 jwplayer 中。
我可以通过单击文件以某种方式执行此操作吗? 或者我应该使用 JavaScript? (我尽量避免)
最佳答案
通过 listin 所有你想通过 php 输出的文件来创建一个文件浏览器:
<div id="player_container"></div>
<a href="./files/file.mp4" onclick="playjw(this)" />
<a href="./files/file2.mp4" onclick="playjw(this)" />
<a href="./files/file3.mp4" onclick="playjw(this)" /> ect
和功能
<script type='text/javascript'>
var temp;
var temphref; //these variables to get the href of the anchor back when opening
//another file so you could open the first file again
function playjw(file) {
var srcfile=file.href;
jwplayer('player_container').setup ({
'flashplayer': 'player.swf',
'file': srcfile,
'controlbar': 'bottom',
'width': '470',
'height': 320,
'provider': 'http'
});
return false; // this is required to not let the browser follow the link.
}
</script>
如果出现任何错误,请自行更改功能,因为我可能忘记了一些东西
关于php - JWPlayer 文件浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10774409/