mediaBrix.isLoaded()

Type Function
Return value Boolean
Revision Release 2024.3703
Keywords ads, advertising, MediaBrix, isLoaded
See also mediaBrix.show()
mediaBrix.*

Overview

Checks to see if a MediaBrix ad is already loaded. Returns true if an ad is loaded/ready, otherwise returns false.

Syntax

mediaBrix.isLoaded( placementId )
placementId (required)

String. The placement ID of the ad you want to check is loaded. This will be sent to you following completion of the MediaBrix registration process.

Example

local mediaBrix = require( "plugin.mediaBrix" )

local function adListener( event )

    if ( event.phase == "init" ) then  -- Successful initialization
        print( event.isError )
        -- Load a MediaBrix ad
        mediaBrix.load( "PLACEMENT_ID" )

    elseif ( event.phase == "loaded" ) then  -- The ad was successfully loaded
        print( event.type )

    elseif ( event.phase == "failed" ) then  -- The ad failed to load
        print( event.type )
        print( event.isError )
        print( event.response )
    end
end

-- Initialize MediaBrix
mediaBrix.init( adListener, { appId="YOUR_APP_ID" } )

-- Sometime later, check if the ad is loaded
local isAdLoaded = mediaBrix.isLoaded( "PLACEMENT_ID" )
print( isAdLoaded )