There might be a couple of potential issues that could prevent the duration from being displayed correctly.
Timing: When accessing the duration property of the video player, it’s crucial to ensure that the video has loaded completely. Otherwise, the duration might not be available. You can handle this by waiting for the onReady event of the video player. Here’s an example of how you can modify your code to include the onReady event:
By wrapping the duration retrieval code inside the onReady event handler, you ensure that the duration is accessed only after the video player is ready.
Element IDs: Double-check that the IDs used in your code (#button110, #videoPlayer1, #text487) match the actual IDs of the elements on your Wix page. If the IDs don’t match, the code won’t be able to find the correct elements and won’t update the text accordingly.
Make sure that the button, video player, and text element IDs are correct and that they exist on your Wix page.
By addressing these potential issues and ensuring that the video player has loaded before accessing the duration, you should be able to retrieve and display the correct duration of the YouTube video when the button is clicked.