Hello! I want to display the current time of the audio player in a Text element. I’ve tried this but it doesn’t work. Can anyone help me?
let currentTime = $w ( “#myAudioPlayer” ). currentTime
$w . onReady ( function (){
$w ( “#textElement” ). text = currentTime ;
}
Hi Quin,
Use a proper Title so people with the knowledge about it will press the question.
with a title as “I Need Some Help!” no one knows about what the question is and so will not press it.
Hey Quin,
The ‘currentTime’ variables are number. You need to change it to a string to implement it into text.
The code should look like this:
let currentTime = $w ( " #myAudioPlayer " ). currentTime
$w . onReady ( function (){
$w ( " #textElement " ). text = currentTime.toString() ;
}
Let me know if it’s helped you.
Best
Binyamin
The Audio player needs to be referenced inside of the onReady():
$w.onReady(function(){
let currentTime =$w("#myAudioPlayer").currentTime
$w("#textElement").text = currentTime.toString();
}
This works!
But it doesn’t update the time while playing. Does anyone know how to solve that?
Thanks!