and it works fine. Is it possible to have one instance of the player, but have several audio files that are clickable links, linked to it? So, the page would have say, four audio files which are clickable links. Clicking the first audio file (link) would start that file in the player, then clicking the second audio file (link) would start that file in the player, and so on. Is this possible?
Yes. You could accomplish this via our JavaScript API by creating a JavaScript function that gets called each time a link is clicked. On each click, the link would pass the file name of the audio file to load, then play that file. Check out the code example at http://support.jwplayer.com/customer/portal/articles/1439570-example-loading-new-playlists
It wasn't clear to me whether I use only your code, or combine that with some of the code I already have. And if the latter, I am not clear as to what. So, if I have:
<div id="myElement">Loading the player …</div> <script> function loadaudio('/mp3/montage.mp3') { jwplayer().load([{ file: '/mp3/montage.mp3', image: "/pics/music-1.png" }]); jwplayer().play(); }; </script> <li><a href="javascript:loadaudio('/mp3/montage.mp3')">Song 1</a></li> <li><a href="javascript:loadaudio('/mp3/montage2.mp3')">Song 2</a></li>
- that doesn't do it. Note that I changed " filePath " to " '/mp3/montage.mp3' ". Then if I have:
Ok, if I add that code, I still have the player (which I want), and I still have the links (which I want) - tho they dont trigger the player, and I know have this other black box which says:
Sorry, audio files and video files are the exact same in terms of being loaded in the player, so I apologize for using the terms interchangeable. In fact, if you load a video and set the height of your player to 30 px like I did in my code example for you, the player will treat it as an audio file.
You will need to update the code below to add your jwplayer.key and the names of your media files where I wrote PUT_YOUR_FILE_PATH_HERE:
<html>
<head>
<script src="javascripts/vendor/custom.modernizr.js"></script><script type="text/javascript" src="/jwplayer.js" ></script><script type="text/javascript">jwplayer.key="xxxxxxx==";</script><script>
function playThisVideo(fileName,imageName) {
jwplayer('video').load([{
file: fileName,
image: imageName
}]);
jwplayer().play();
}
</script></head>
<body>
<div id="video">Loading the player …</div>