Register friendly obstructions (Android)

Register custom controls as friendly obstructions when using OMID with Google IMA ads in your Android app.


If you use the IAB Open Measurement Interface Definition (OMID) and run Google IMA ads, all custom video controls that overlay the media element must be registered as friendly obstructions. Friendly obstructions are views -- such as video controls -- that are essential to the user’s experience but do not impact viewability.

The JWFriendlyAdObstructions class enables you to register fully transparent overlays or small buttons. Once registered, your custom video controls are excluded from the ad viewability measurements that the Open Measurement SDK calculates.

The following table lists the views that can and cannot be registered.

PermittedNot Permitted
β€’ Transparent overlay used to capture user taps

β€’ Transient buttons such as the following:
Β Β Β Β Β Β β—¦ Pause
Β Β Β Β Β Β β—¦ Play
Β Β Β Β Β Β β—¦ Fullscreen
Β Β Β Β Β Β β—¦ Cast/AirPlay
Β Β Β Β Β Β β—¦ Collapse
Β Β Β Β Β Β β—¦ Progress/Seek
Β Β Β Β Β Β β—¦ Other playback-related actions
β€’ Watermarks
β€’ Pop-ups
β€’ Dialogs
β€’ Non-transient buttons
β€’ Other obscuring views







Register friendly obstructions

Use the following steps and code sample to register a custom video control as a friendly ad obstruction:

  1. Add the custom view, for example customControlbar, to your app.
  2. Use getJWFriendlyAdObstructions() to get a reference to the list of friendly ad obstructions.
  3. Add the custom view to the JWFriendlyAdObstructions list.

mPlayerView = findViewById(R.id.jwplayer);
View customControlbar = findViewById(R.id.custom_controlbar);

// Add our custom controlbar to the list of friendly ad obstructions
friendlyAdObstructions = mPlayerView.getJWFriendlyAdObstructions();
friendlyAdObstructions.add(customControlbar);

List<AdBreak> adSchedules = new ArrayList<>();

AdBreak adBreak = new AdBreak.Builder()
    .offset("10")
    .tag("https://www.domain.com/adtag.xml")
    .build();
        
adSchedules.add(adBreak);

ImaAdvertisingConfig imaAdvertisingConfig = new ImaAdvertisingConfig.Builder()
    .schedule(adSchedules)
    .build();

PlaylistItem playlistItem = new PlaylistItem.Builder()
    .file("https://cdn.jwplayer.com/manifests/{MEDIA_ID}.m3u8")
    .build();

List<PlaylistItem> playlist = new ArrayList<>();
playlist.add(playlistItem);

PlayerConfig config = new PlayerConfig.Builder()
    .playlist(playlist)
    .advertisingConfig(imaAdvertisingConfig)
    .build();

mPlayerView.setup(config);