Shortform messageCallback

    Shortform messageCallback


    Article summary

    We offer the messageCallback function, which allows you to directly handle various events within short-form content.

    Guide for live streaming in the Shortform player

    The events that should be used when live streaming within the short-form player are as follows:

    By adding DETAIL_CLICK_LIVE_CAMPAIGN_LINK, you can enable the corresponding feature.

    <script type="text/javascript" src="https://static.shoplive.cloud/shoplive-shortform.js"></script>
    <script>
      const messageCallback= {
        DETAIL_CLICK_LIVE_CAMPAIGN_LINK: function(payload) {
          var url = `https://YOUR_LIVE_PLAYER_PAGE_URL?campaignKey=${payload.campaignKey}`
          location.href = url;
        },
      };
      cloud.shoplive.initShortform({
        accessKey: 'YOUR ACCESS KEY HERE',
        messageCallback: messageCallback
      });
    </script>

    Messages & Payload

    DETAIL_CLICK_LIVE_CAMPAIGN_LINK

    When entering the short-form player during a live broadcast, the live stream playback and live landing icon may be inserted.

    Payload

    Type

    type

    string


    Installation Example

    Install the below code to the common layout of the page

    <script type="text/javascript" src="https://static.shoplive.cloud/shoplive-shortform.js"></script>
    <script>
      const messageCallback: { 
        LOGIN_REQUIRED: function(payload) {
          alert("LOGIN_REQUIRED");
          location.href = "YOUR_LOGIN_PAGE_URL";
        },
        ON_CLICK_PRODUCT_ITEM: function(payload) {
          alert("ON_CLICK_PRODUCT_ITEM");
          location.href = payload.product.url;      
        }
      };
      
      cloud.shoplive.initShortform({ 
        accessKey: 'YOUR ACCESS KEY HERE', 
        messageCallback: messageCallback 
      });
    </script>

    Messages & Payload

    The following is a list of events that can be directly handled by the messageCallback setting.


    LOGIN_REQUIRED

    On clicking where login is required, such as when a user attempts to post a comment.

    payload

    type

    type

    string


    ON_CLICK_PRODUCT_ITEM

    On clicking on a product in a product list

    payload

    type

    product

    Product

    shorts

    Shorts


    ON_CLICK_SHARE_BUTTON

    On clicking the share button

    payload

    type

    shorts

    Shorts

    url

    string

    DETAIL_ACTIVE

    On activating Shortform Detail(Shortform video play within the feed)

    payload

    type

    shorts

    Shorts

    DETAIL_ON_PLAYER_DISMISS

    On closing Shortform Detail(Shortform video play within feed)

    payload

    type

    N/A

    N/A

    DETAIL_VIEWING_SECONDS

    3 seconds heartbeat when watching a Shortform detail video

    payload

    type

    shorts

    Shorts

    videoCurrentTime

    number