• Resolved balajianimation

    (@balajianimation)


    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)
  • Plugin Support lastsplash (a11n)

    (@lastsplash)

    Hi @balajianimation

    Per our scope of support, we aren’t able to assist with debugging custom code. However, since it is my first time running into this API documentation, I am reaching out to our development team to see if this is still an available API.

    We’ll let you know here once we have an update.

    Plugin Support lastsplash (a11n)

    (@lastsplash)

    Hi @balajianimation

    Thanks for your patience here. Our development team confirmed that this API is still current. Looking at the code, it appears you are mixing the JS API methods. With your code, you would want to do something like:

    iframe.contentWindow.postMessage({
    event: 'videopress_action_play'
    }, '*');

    For your reference, here are the postMessage events docs and JS API docs.

    Since we can’t assist further with custom code, I am going to mark this thread as resolved.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom play pause button not working’ is closed to new replies.