Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Multiple files with the audio player?


Hi, I have the audio player as found here:

http://support.jwplayer.com/customer/portal/articles/1406724-aac-mp3-audio-embed

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?

Thanks in advance.

11 Community Answers

Todd

JW Player Support Agent  
0 rated :

Hi,

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

Hope this helps,
Todd

j...

User  
0 rated :

Thanks for the reply. Ok, that makes sense. But, I can not get it to work. In the top (head), I have:

<script src="javascripts/vendor/custom.modernizr.js"></script>

<script type="text/javascript" src="/jwplayer.js" ></script>
<script type="text/javascript">jwplayer.key="xxxxxxx==";</script>

And then down the page, I have:

<div id="myElement">Loading the player ...</div>
<script>
jwplayer("myElement").setup({
file: "/mp3/montage.mp3",
width: 480,
height: 30
});
</script>
<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>

I still have the player, and it works, but if I click on the links, nothing happens. Do I have some redundancy there?

Thanks!

Todd

JW Player Support Agent  
0 rated :

Looks like your not using the variable in the function correctly. Try this:

<div id="myElement">Loading the player …</div> <script> function loadaudio(filePath) { jwplayer().load([{ file: filePath, 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>

j...

User  
-1 rated :

Hi, thanks. Still not working.

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:


<div id="myElement">Loading the player …</div>
<script>
jwplayer("myElement").setup({
file: "/mp3/montage.mp3",
width: 480,
height: 30
});
</script>
<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' work either. What am I missing here?

Todd

JW Player Support Agent  
0 rated :

Use your license key in this code and it should work:

<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, file: imageName }]); jwplayer().play(); } </script></head> <body> <div id="video">Loading the player …</div>

<br> <a href="javascript:playThisVideo('bunny.mp4','bunny.jpg');">Big Buck Bunny</a><br> <a href="javascript:playThisVideo('sintel.mp4','sintel.jpg');">Sintel</a><br> <a href="javascript:playThisVideo('tears.mp4','tears.jpg');">Tears of Steel</a>
<script> jwplayer('video').setup({ file: 'bunny.mp4', image: 'bunny.jpg', autostart: true }); </script>

</body> </html>

j...

User  
0 rated :

Sorry, I am getting REALLY confused here.

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:

"error loading playlist"

and three links:

Big Buck Bunny
Sintel
Tears of Steel

What am I dong wrong here?

Todd

JW Player Support Agent  
0 rated :

The videos that I pointed to in my sample code do not match your files on your server.

E-mail the link to where the video is hosted to support@jwplayer.com

I will take a look at your code and put your filenames in the code correctly

-Todd

j...

User  
0 rated :

Hi. I am not looking to host video files. Audio files. And I don't want that huge black box appearing on the page.

It's not where the audio files are hosted that's the issue. That's the easy part:

/mp3/montage2.mp3

As I said, the player works just fine with one audio file. It's multiple files that I can't get it to work with. Still email you?

Thanks for the help.

Todd

JW Player Support Agent  
0 rated :

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>

<br> <a href="javascript:playThisVideo('PUT_AUDIO1_PATH_HERE','PUT_IMAGE1_PATH_HERE');">PUT_TITLE1_HERE</a><br> <a href="javascript:playThisVideo('PUT_AUDIO2_PATH_HERE','PUT_IMAGE2_PATH_HERE');">PUT_TITLE2_HERE</a><br> <a href="javascript:playThisVideo('PUT_AUDIO3_PATH_HERE','PUT_IMAGE3_PATH_HERE');">PUT_TITLE3_HERE</a>

<script> jwplayer('video').setup({ file: 'PUT_AUDIO1_PATH_HERE', image: 'PUT_IMAGE1_PATH_HERE', autostart: true }); </script></body> </html>

jhayat3

User  
0 rated :

Thanks for that.

Ok, it's working now - thank you.

I added the following:

<script>
jwplayer("myElement").setup({
width: 480,
height: 30
});
</script>

In the hopes of having just the bottom audio portion showing, and not the video box. Is this not intended to work?

jhayat3

User  
0 rated :

Hi - anyone home? :)

This question has received the maximum number of answers.