Javascript Events

Voxpopme help team -

There are a number of PostMessages that are fired throughout the non-panel video process (https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage) These will work in all modern browsers.

Each event will include the following data:

Event Data

var returnData = {event:"EVENT_NAME"};
parent.postMessage(returnData, '*');

Events can be listened to with the following code:

Event listening

<script>
//this code is used to listen for events from the iframe
        var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";
        var eventer = window[eventMethod];
        var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";

        // Listen to message from child window (iframe)

        var onlyStrings = false;
        try {
            window.postMessage({toString: function () {
                onlyStrings = true;
            }}, "*");
        } catch (e) {
        }

        eventer(messageEvent, function (e) {
            if (e.data) {
                var eventData = {};
                if (typeof e.data === 'string' && onlyStrings) {
                    eventData = JSON.parse(e.data);
                }
                else {
                    eventData = e.data
                }
                if ("EVENT_NAME" == eventData.event) {
                    //add your code for the specified event
                }
            }
        }, false);
</script>

Default

The following PostMessages will be sent:

`initialized`

 Initialized and is ready for use

`serverDisconnected`

Connection to our streaming server was lost.

`detectingCamera`

Detecting active webcam

`hasCamera`

Web camera found

`noCamera`

Error state when no camera is found

`hasMic`

Microphone found

`noMic`

Unable to find a microphone

`cameraDenied`

Camera access denied by user

`readyToRecord`

Camera and Mic found and configured properly

`recordingStarted`

Recording started

`recordingStopped`

Recording stopped

`recordingCancelled`

Recording has been cancelled

`playbackStarted`

Playback of recorded video has begun

`playbackPaused`

Playback paused

`publishing`

The video has begun publishing to the VoxPopMe server

`published`

The video has finished publishing to the VoxPopMe server

`publishFailed`

The video failed to publish

`processed`

The video has finished processing and uploading

`response_complete` (final stage)

This message will be sent when the video has been uploaded and saved successfully to the VoxPopMe platform.

`continue_clicked`

This tracking event can be used to detect the user clicking the continue button. 

`quota_full`

This message will appear if the campaign has completed because it has hit the number of responses specified.

`inactive`

This message will appear if the campaign is not currently active, i.e in draft, pending, scheduled, or has completed to due expiring. 

Have more questions? Submit a request

0 Comments

Article is closed for comments.