Custom play pause button not working
-
I have just followed your api to have custom play pause button it’s not working
https://github.com/Automattic/videopress-player-api-doc/blob/trunk/public-js-api.md<button id="playButton">Play</button> <button id="pauseButton">Pause</button>[videopress beXgxd9g w=1080 h=1920]
document.addEventListener('DOMContentLoaded', () => {
const iframe = document.querySelector('iframe[src*="videopress"]');
if (iframe) {
// Play button functionality
document.getElementById('playButton').addEventListener('click', () => {
iframe.contentWindow.postMessage(
JSON.stringify({ method: 'play' }),
'*'
);
});
// Pause button functionality
document.getElementById('pauseButton').addEventListener('click', () => {
iframe.contentWindow.postMessage(
JSON.stringify({ method: 'pause' }),
'*'
);
});
// Log responses from the iframe for debugging
window.addEventListener('message', (event) => {
if (event.origin.includes('videopress.com')) {
console.log('Response from VideoPress:', event.data);
}
});
} else {
console.error('VideoPress iframe not found!');
}
});
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Custom play pause button not working’ is closed to new replies.