29 lines
985 B
Plaintext
29 lines
985 B
Plaintext
<div>
|
|
<audio controls>
|
|
<source src="horse.ogg" type="audio/ogg">
|
|
<source id="audioFile" src="horse.mp3" type="audio/mpeg">
|
|
Your browser does not support the audio element.
|
|
</audio>
|
|
</div>
|
|
|
|
<script is:inline>
|
|
fetch('https://game-du.teachertrainingkolkata.in/items/game_drag/19')
|
|
.then(response => response.json())
|
|
.then(responseData => {
|
|
console.log(responseData); // Log the full response
|
|
|
|
// Check if the data contains the 'instruction' field
|
|
const instructionId = responseData.data.instruction;
|
|
|
|
// Assuming you need to build the full URL from this instruction ID
|
|
const audioUrl = `https://game-du.teachertrainingkolkata.in/assets/${instructionId}.mp3`;
|
|
console.log(audioUrl)
|
|
|
|
// Set the audio source dynamically
|
|
document.getElementById('audioFile').src = audioUrl;
|
|
})
|
|
.catch(error => {
|
|
console.error('Error fetching audio source:', error);
|
|
});
|
|
</script>
|