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

Jw player .mp4 video shuffle rotate help


I am using jw player on my site and I would like to know what is the correct way to play random .mp4 video files when you press the play button I have included the code that i am using on my site to play just one .mp4 file, I have a folder with several .mp4 video files that I would like to randomly play on the press of the play button when a user visits my page.

my folder has videos labeled hdvideo1.mp4,hdvideo2.mp4 etc....

<script>
jQuery(document).ready(function($){
$(".vid-play-img").click(function() {
$( "#daOverlay" ).show();
jwplayer('jplayer').setup({
logo: false,
file: '/hdvideo4.mp4',
image: "{{ $title->background }}",
width: "100%",
aspectratio: "16:9",
autostart: true,
controls: false
});
});
});
</script>

1 Community Answers

George

JW Player Support Agent  
0 rated :

I’d probably add all the video paths to an array and then use something like this to pick a random entry and set it as the file

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random
function getRandomArbitrary(min, max) {
return Math.random() * (max – min) + min;
}

This question has received the maximum number of answers.