<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8' />
<title>Custom User Interface</title>
</head>
<body>
<div>
<button id='play-button'>Play</button>
<span id='content-title'>Loading...</span>
<span id='time-indicator'>0:00</span>
</div>
<script>
var player, playButton, contentTitle, timeIndicator;
function initializeCustomUserInterface() {
player = BeyondWords.Player.instances()[0];
player = player || new BeyondWords.Player({ projectId: <ID>, contentId: '<ID>' });
playButton = document.getElementById('play-button');
contentTitle = document.getElementById('content-title');
timeIndicator = document.getElementById('time-indicator');
player.addEventListener('<any>', rerenderCustomUserInterface);
playButton.addEventListener('click', playOrPause);
}
function rerenderCustomUserInterface() {
var contentItem = player.content[player.contentIndex];
var isPlaying = player.playbackState === 'playing';
var minutes = Math.floor(player.currentTime / 60);
var seconds = Math.floor(player.currentTime % 60);
playButton.innerText = isPlaying ? 'Pause' : 'Play';
contentTitle.innerText = contentItem ? contentItem.title : '';
timeIndicator.innerText = minutes + ":" + seconds.toString().padStart(2, '0');
}
function playOrPause() {
if (player.playbackState === 'playing') {
player.playbackState = 'paused';
} else {
player.playbackState = 'playing';
}
};
</script>
<!-- Remove this script tag if you are using the WordPress plugin. It will be added for you. -->
<script async deref
src='https://proxy.beyondwords.io/npm/@beyondwords/player@latest/dist/umd.js'
onload='initializeCustomUserInterface()'>
</script>
</body>
</html>