I would like to put a number to link to different music style playlist. To a specific music style is no problem.
But also i want to make a random video player with all music playlists Is there a way to put a random number between 1-10 on the place --randomnumber--
<script type="text/javascript">
jwplayer('mediaplayer').setup({
'flashplayer': 'jwplayer/player-licensed.swf',
'id': 'playerID',
'width': '650',
'height': '370',
'playlistfile': 'jwplayer/--randomnumber--/playlist.xml',
'controlbar': 'over',
'autostart': 'true',
'repeat': 'always'
})
</script>
Thank you already for your help.
You could quickly define a function to generate a random integer, as follows:
function generateRandomInteger(max) {
return Math.floor(Math.random() * max) + 1;
}
Then concatenate that into your playlistfile property in your existing code:
<script type="text/javascript">
jwplayer('mediaplayer').setup({
'flashplayer': 'jwplayer/player-licensed.swf',
'id': 'playerID',
'width': '650',
'height': '370',
'playlistfile': 'jwplayer/' + generateRandomInteger(10) + '/playlist.xml',
'controlbar': 'over',
'autostart': 'true',
'repeat': 'always'
})
</script>
This should do it:
'jwplayer/' + Math.ceil(10 * Math.random()) + '/playlist.xml'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With