Reputation: 1284
I would like to build a file browser, which displays information about the file when clicking. The file itself should then be loaded into jwplayer per PHP.
Can I somehow do this by clicking on the file? Or should I use JavaScript? (which I try to avoid)
Upvotes: 1
Views: 298
Reputation: 1468
create a file browser by listin all files that you want to list by php outputing something like :
<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
and the function
<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>
change the function by yourself if any bug will ocour because i might have forgot something
Upvotes: 2
Reputation: 16494
If you want to use a file browser, use a php/javasript-based script. Don't try to build it by yourself, unless you have too much time. Check http://www.gerd-tentler.de/tools/filemanager/ and http://encode-explorer.siineiolekala.net/explorer/index.php. The web is full of excellent free scripts. Depending on how you want to use jwplayer (audio? video?) you can easily create the div that plays the file (see jw docs) or create an iframe that plays the file.
The most simple way would be to create an onclick event for all the files that end with .mpg or .mp3 that creates the div/iframe.
Upvotes: 0