I want to use this Fluid Player function for each video with the same class name. I heard that I can do it using the Array.forEach() method, but I have no idea how.
I have also tried using a normal for loop, and executing the Fluid Player function on every array element but it didn't work.
What am I doing wrong?
<!DOCTYPE html>
<html>
<body>
<link rel="stylesheet" href="https://cdn.fluidplayer.com/v2/current/fluidplayer.min.css" type="text/css"/>
<script src="https://cdn.fluidplayer.com/v2/current/fluidplayer.min.js"></script>
<video class = "classname" id="short" height="225" loop controls>
<source src="deja vu.mp4" type="video/mp4"/>
</video>
<video class = "classname" id="short" height="225" loop controls>
<source src="deja vu.mp4" type="video/mp4"/>
</video>
<video class = "classname" id="short" height="225" loop controls>
<source src="deja vu.mp4" type="video/mp4"/>
</video>
</body>
<script type="text/javascript">
var array = document.getElementByClassName('classname');
Array.forEach();
</script>
<script type="text/javascript">
var myFP = fluidPlayer(
'short',
{
layoutControls: {
fillToContainer: false,
primaryColor: false,
posterImage: false,
autoPlay: false,
playButtonShowing: true,
playPauseAnimation: true,
mute: false,
logo: {
imageUrl: null,
position: 'top left',
clickUrl: null,
opacity: 1,
mouseOverImageUrl: null,
imageMargin: '2px',
hideWithControls: false,
showOverAds: false
},
htmlOnPauseBlock: {
html: null,
height: null,
width: null
},
allowDownload: false,
allowTheatre: false,
playbackRateEnabled: false,
controlBar: {
autoHide: true,
autoHideTimeout: 1,
animated: false
},
},
vastOptions: {
}
}
);
</script>
</html>
getElementByClassNamedoesn't return an array, it returns a HTMLCollection object. Though that object hasforEachmethod in modern browsers.fluidPlayer(call doesn't seem to take any arguments related to elements, though...