- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to play HTML5 Audio Randomly
To play randomly, add the songs like this:
init ([ 'http://demo.com/songs/song1.mp3, 'http://demo.com/songs/song2.mp3, 'http://demo.com/songs/song3.mp3 ]);
Use the following to play randomly using Math.random:
function displayRandom() { var audio = Math.floor(Math.random() * (collection.length)); audio = collection[audio]; audio.play(); setTimeout(loop,audio.duration*1000); }
- Related Articles
- HTML5 Audio to Play Randomly
- How to play audio and video file in iOS?
- How to detect HTML5 audio MP3 support
- How to play audio file from the assets directory in Android?
- HTML5 audio control stop button
- Is it possible to style HTML5 audio tag?
- HTML5 check if audio is playing
- HTML5 audio not playing in PhoneGap App
- How do we embed audio in web pages in HTML5?
- Play infinitely looping video on-load in HTML5
- Play local (hard-drive) video file with HTML5 video tag?
- How to Play Dominoes?
- Play video on canvas and preserve the last frame/image on HTML5 Canvas
- Create a media resources for media elements, defined inside video or audio elements in HTML5.
- How to embed youtube as an audio player?

Advertisements