hello is there any way to add the function in the javascript and enable the option in the menu?
a try this dont work:
<video id="myPlayer" width="640" height="360" controls>
<source src="video1.mp4" type="video/mp4">
<track kind="captions" src="captions.vtt" srclang="en" label="English">
</video>'
<ul id="myPlaylist" class="able-playlist" data-player="myPlayer">
<li data-src="video1.mp4">Video 1</li>
<li data-src="video2.mp4">Video 2</li>
<li data-src="video3.mp4">Video 3</li>
</ul>
<script>
// Function to shuffle an array
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
// Get the playlist items
const playlist = document.getElementById('myPlaylist');
const playlistItems = Array.from(playlist.children);
// Shuffle the playlist items
const shuffledItems = shuffleArray(playlistItems);
// Clear the existing playlist
playlist.innerHTML = '';
// Add the shuffled items back to the playlist
shuffledItems.forEach(item => playlist.appendChild(item));
// Initialize Able Player (assuming you have the Able Player library loaded)
const myPlayer = new AblePlayer(document.getElementById('myPlayer'));
</script>
hello is there any way to add the function in the javascript and enable the option in the menu?
a try this dont work:
<video id="myPlayer" width="640" height="360" controls><source src="video1.mp4" type="video/mp4"><track kind="captions" src="captions.vtt" srclang="en" label="English"></video>'<ul id="myPlaylist" class="able-playlist" data-player="myPlayer"><li data-src="video1.mp4">Video 1</li><li data-src="video2.mp4">Video 2</li><li data-src="video3.mp4">Video 3</li></ul><script>// Function to shuffle an array
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
// Get the playlist items
const playlist = document.getElementById('myPlaylist');
const playlistItems = Array.from(playlist.children);
// Shuffle the playlist items
const shuffledItems = shuffleArray(playlistItems);
// Clear the existing playlist
playlist.innerHTML = '';
// Add the shuffled items back to the playlist
shuffledItems.forEach(item => playlist.appendChild(item));
// Initialize Able Player (assuming you have the Able Player library loaded)
const myPlayer = new AblePlayer(document.getElementById('myPlayer'));
</script>