Title: Supports postMessage
Last modified: June 8, 2023

---

# Supports postMessage

 *  Resolved [rose18](https://wordpress.org/support/users/rose18/)
 * (@rose18)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/supports-postmessage/)
 * Hi,
 * Does JetPack VideoPress supports postMessage, so we can play/pause videos using
   javascript? Any documentations on it?
 * Thanks!

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

 *  Plugin Contributor [retrofox](https://wordpress.org/support/users/retrofox/)
 * (@retrofox)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/supports-postmessage/#post-16803367)
 * Hi, there! Yes,It does!!
 * We are currently in the process of creating a documentation page, but for the
   time being, let’s share these examples:
 *     ```wp-block-code
       window.postMessage( {
         event: 'videopress_action_play'
       } )
       ```
   
 *     ```wp-block-code
       window.postMessage( {  event: 'videopress_action_pause'} )
       ```
   
 *     ```wp-block-code
       window.postMessage( {  event: 'videopress_action_set_currenttime',  currentTime: 30 // timestamp in seconds} )
       ```
   
 *     ```wp-block-code
       window.postMessage( {  event: 'videopress_action_set_volume',  volume: 0.4 // 40%} )
       ```
   
 *  Thread Starter [rose18](https://wordpress.org/support/users/rose18/)
 * (@rose18)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/supports-postmessage/#post-16804862)
 * Thank you [@retrofox](https://wordpress.org/support/users/retrofox/) !
 * I am getting errors in the console when using the code above. I am trying to 
   play the VideoPress video when it enters viewport, so I am using GSAP for that.
 * Please find my code below:
 *     ```wp-block-code
       gsap.registerPlugin(ScrollTrigger);
   
       const playVideoPressIframe = (iframeE) => {
         iframeE.window.postMessage( { event: 'videopress_action_play'} );
       }
   
       const stopVideoPressIframe = (iframeE) => {
         iframeE.window.postMessage( {  event: 'videopress_action_pause'} );
       }
   
       let videoPressVideoAnimationPanels = gsap.utils.toArray(".videoPress-animation");
   
       videoPressVideoAnimationPanels.forEach((videoPressVideoAnimationPanel, i) => {
   
         let iframeElem = videoPressVideoAnimationPanel.querySelector('iframe');
         //let iframeElemSrc = iframeElem.src;
   
   
          ScrollTrigger.create({
            trigger: videoPressVideoAnimationPanel,
            start: 'top-=80vh center',
            end: 'bottom center',
            markers: true,
            onEnter: () => playVideoPressIframe(iframeElem),
            onEnterBack: () => playVideoPressIframe(iframeElem),
            onLeave: () => stopVideoPressIframe(iframeElem),
            onLeaveBack: () => stopVideoPressIframe(iframeElem)
          });
       });
       ```
   
 * When it enters, it calls the playVideoPressIframe() function and executes the
   code inside. In the play function, I have this line of code to start the video:
 *     ```wp-block-code
       iframeE.window.postMessage( { event: 'videopress_action_play'} );
       ```
   
 * It’s not working and I’m getting this error:
 * _Uncaught TypeError: Cannot read properties of undefined (reading ‘postMessage’)_
 * What is the issue?
 * Thanks!
 *  Plugin Contributor [retrofox](https://wordpress.org/support/users/retrofox/)
 * (@retrofox)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/supports-postmessage/#post-16804906)
 * > What’s the issue?
 * Try defining the [targetOrigin](https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#targetorigin).
   Also, be sure you are picking properly the c contentWindow object of the iFrame.
 * Try the following:
 *     ```wp-block-code
       iframeE.contentWindow.postMessage( { event: 'videopress_action_play' }, { targetOrigin: '*' } );
       ```
   
 *  Plugin Support [Tamirat B. (a11n)](https://wordpress.org/support/users/tamirat22/)
 * (@tamirat22)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/supports-postmessage/#post-16823953)
 * Hello [@rose18](https://wordpress.org/support/users/rose18/)
 * It’s been one week since this topic was last updated. I’m going to mark this 
   thread as solved for now. If you have any further questions or need more help,
   you’re welcome to open another thread here. Cheers!

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

The topic ‘Supports postMessage’ is closed to new replies.

 * ![](https://ps.w.org/jetpack-videopress/assets/icon.svg?rev=2818893)
 * [Jetpack VideoPress](https://wordpress.org/plugins/jetpack-videopress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/jetpack-videopress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/jetpack-videopress/)
 * [Active Topics](https://wordpress.org/support/plugin/jetpack-videopress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/jetpack-videopress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/jetpack-videopress/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [pause](https://wordpress.org/support/topic-tag/pause/)
 * [play](https://wordpress.org/support/topic-tag/play/)
 * [video](https://wordpress.org/support/topic-tag/video/)

 * 4 replies
 * 3 participants
 * Last reply from: [Tamirat B. (a11n)](https://wordpress.org/support/users/tamirat22/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/supports-postmessage/#post-16823953)
 * Status: resolved