Functionality:
Randomised audio is to play from an audio list within a gamepage.
What has been done:
I have created an array list of audio files, randomised the audio list via the following method: Math.floor(Math.random() * audioList.length); and after which assign a variable to the randomised audio list and lastly, append it to a id
Issue:
The audio is not playing when user is in that page.How is that possible when the div id is appended to the audiolist?
var audioList = ["lib/audio/Awesome.mp3", "lib/audio/Excellent.mp3", "lib/audio/Fantastic.mp3", "lib/audio/Great.mp3", "lib/SKII/audio/KeepitUp.mp3", "lib/audio/MatchGame.mp3", "lib/audio/MatchSpot1.mp3", "lib/audio/MatchSpot3.mp3"];
$('#DefaultGamePage').fadeIn({
duration: slideDuration,
queue: false,
complete: function() {
$('#DefaultGameTimer').show();
//Draw captured facial image into shape
//contextGame.drawImage(video, 0, 0, 2000, 2000);
//Play Randomised Audio
var random_PlayAudio = Math.floor(Math.random() * audioList.length);
var Audio = audioList[random_PlayAudio];
$("#Play").attr('src', Audio);
......(the rest of the game method)
<div id="GamePage" style="display:none; position:absolute; z-index:20; top:0px; left:0px; width: 1080px; height: 1920px; margin:auto;">
<div id="Play"></div>
....
</div>
Aucun commentaire:
Enregistrer un commentaire