audio done
This commit is contained in:
@@ -11,10 +11,10 @@ import Layout from "../../layouts/Layout.astro";
|
||||
<img src="/assets/top_logo.svg" alt="" draggable="false" class="select-none">
|
||||
</div>
|
||||
<div class="flex flex-row space-x-1 pb-2">
|
||||
<button><img src="/assets/svg/mute.svg" alt=""></button>
|
||||
<button><img src="/assets/svg/reset.svg" alt=""></button>
|
||||
<button onclick="audioPlayAndPause()"><img src="/assets/svg/mute.svg" alt=""></button>
|
||||
<button onclick="retryGame()"><img src="/assets/svg/reset.svg" alt=""></button>
|
||||
<button onclick="saveUserData();"><img src="/assets/svg/tick2.svg" alt=""></button>
|
||||
<button><img src="/assets/svg/cancel.svg" alt=""></button>
|
||||
<button onclick="history.back();"><img src="/assets/svg/cancel.svg" alt=""></button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <input onclick="saveUserData();" class="bg-blue-700 px-8 py-2 rounded-lg shadow-lg font-bold text-white cursor-pointer" type="submit" value="Submit"> -->
|
||||
@@ -135,9 +135,27 @@ import Layout from "../../layouts/Layout.astro";
|
||||
<img src="/assets/svg/clip-art2.svg" alt="Clip Art" class="clip-art">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<audio id="audioPlayer" controls class="hidden">
|
||||
<source id="instrucAudio1" src="" type="audio/ogg">
|
||||
<source id="instrucAudio2" src="" type="audio/mpeg">
|
||||
Your browser does not support the audio element.
|
||||
</audio>
|
||||
</div>
|
||||
</main>
|
||||
</Layout>
|
||||
<script is:inline>
|
||||
let isPlaying = false;
|
||||
function audioPlayAndPause(){
|
||||
if(isPlaying === false){
|
||||
document.getElementById('audioPlayer').play();
|
||||
isPlaying = true;
|
||||
}else if(isPlaying === true){
|
||||
document.getElementById('audioPlayer').pause();
|
||||
document.getElementById('audioPlayer').currentTime = 0;
|
||||
isPlaying = false;
|
||||
}
|
||||
}
|
||||
function retryGame(){
|
||||
window.location.reload();
|
||||
}
|
||||
@@ -199,6 +217,10 @@ import Layout from "../../layouts/Layout.astro";
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
gameData = data.data;
|
||||
let audioLink = `https://game-du.teachertrainingkolkata.in/assets/${gameData.instruction}.mp3`;
|
||||
document.getElementById('instrucAudio1').src = audioLink;
|
||||
document.getElementById('instrucAudio2').src = audioLink;
|
||||
document.querySelector('audio').load();
|
||||
// console.log(gameData)
|
||||
document.getElementById("gameDescription").innerHTML = gameData.description;
|
||||
if(gameData.label1){
|
||||
|
||||
Reference in New Issue
Block a user