I am trying to run InStream Ad. I cloned the PreBidMobile Android repo and just run the code and open Activity GamOriginalApiInStreamActivity. In this Ad video is being skipped or I do not know it is somehow giving some cache error
after not playing Ad video just jumped to content video part.
Samle code:
class GamOriginalApiInStreamActivity : BaseAdActivity() {
companion object {
const val AD_UNIT_ID = "/21808260008/prebid_demo_app_instream"
const val CONFIG_ID = "prebid-demo-video-interstitial-320-480-original-api"
const val WIDTH = 640
const val HEIGHT = 480
const val VIDEO_URL = "https://storage.googleapis.com/gvabox/media/samples/stock.mp4"
}
private var adUnit: InStreamVideoAdUnit? = null
private var player: SimpleExoPlayer? = null
private var adsUri: Uri? = null
private var adsLoader: ImaAdsLoader? = null
private var playerView: PlayerView? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
createAd()
}
private fun createAd() {
// 1. Create InStreamVideoAdUnit
adUnit = InStreamVideoAdUnit(CONFIG_ID, WIDTH, HEIGHT)
// 2. Configure video parameters
adUnit?.videoParameters = configureVideoParameters()
// 3. Init player view
playerView = PlayerView(this)
val params = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 600)
adWrapperView.addView(playerView, params)
// 4. Make a bid request to Prebid Server
adUnit?.fetchDemand { _: ResultCode?, keysMap: Map<String?, String?>? ->
// 5. Prepare the creative URI
val sizes = HashSet<AdSize>()
sizes.add(AdSize(WIDTH, HEIGHT))
val prebidURL = Util.generateInstreamUriForGam(
AD_UNIT_ID,
sizes,
keysMap
)
adsUri = Uri.parse(prebidURL)
// 6. Init player
initializePlayer()
}
}
private fun configureVideoParameters(): VideoParameters {
return VideoParameters(listOf("video/x-flv", "video/mp4")).apply {
placement = Signals.Placement.InStream
api = listOf(
Signals.Api.VPAID_1,
Signals.Api.VPAID_2
)
maxBitrate = 1500
minBitrate = 300
maxDuration = 30
minDuration = 5
playbackMethod = listOf(Signals.PlaybackMethod.AutoPlaySoundOn)
protocols = listOf(
Signals.Protocols.VAST_2_0
)
}
}
private fun initializePlayer() {
adsLoader = ImaAdsLoader.Builder(this).build()
val playerBuilder = SimpleExoPlayer.Builder(this)
player = playerBuilder.build()
playerView!!.player = player
adsLoader!!.setPlayer(player)
val uri = Uri.parse(VIDEO_URL)
val mediaItem = MediaItem.fromUri(uri)
val dataSourceFactory: DataSource.Factory = DefaultDataSourceFactory(this, getString(R.string.app_name))
val mediaSourceFactory = ProgressiveMediaSource.Factory(dataSourceFactory)
val mediaSource: MediaSource = mediaSourceFactory.createMediaSource(mediaItem)
val dataSpec = DataSpec(adsUri!!)
val adsMediaSource = AdsMediaSource(
mediaSource, dataSpec, "ad", mediaSourceFactory,
adsLoader!!, playerView!!
)
player?.setMediaSource(adsMediaSource)
player?.playWhenReady = true
player?.prepare()
}
}
This screens run after the initialization of Prebid SDK and MobileAdsSDK
My device Logs right after requesting the stored imp
I Advertising id was received
2024-07-23 12:00:26.740 23407-23445 PrebidBaseNetworkTask org.prebid.mobile.prebidkotlindemo D url: https://prebid-server-test-j.prebid.org/openrtb2/auction
2024-07-23 12:00:26.740 23407-23445 PrebidBaseNetworkTask org.prebid.mobile.prebidkotlindemo D queryParams: {"imp":[{"id":"71fd7d1a-77e5-422d-904a-ea09eb8c89f0","instl":0,"clickbrowser":0,"video":{"mimes":["video\/x-flv","video\/mp4"],"minduration":5,"maxduration":30,"protocols":[2],"w":640,"h":480,"minbitrate":300,"maxbitrate":1500,"placement":1,"playbackmethod":[1],"delivery":[3],"api":[1,2]},"ext":{"prebid":{"storedrequest":{"id":"prebid-demo-video-interstitial-320-480-original-api"}}}}],"id":"71fd7d1a-77e5-422d-904a-ea09eb8c89f0","app":{"name":"Prebid Kotlin Demo","bundle":"org.prebid.mobile.prebidkotlindemo","ver":"1.0.0","publisher":{"id":"0689a263-318d-448b-a3d4-b02e8a709d9d"},"ext":{"prebid":{"source":"prebid-mobile","version":"2.2.3"}}},"device":{"ua":"Mozilla\/5.0 (Linux; Android 12; Redmi Note 9 Pro Build\/SKQ1.211019.001; wv) AppleWebKit\/537.36 (KHTML, like Gecko) Version\/4.0 Chrome\/126.0.6478.134 Mobile Safari\/537.36","lmt":0,"devicetype":4,"make":"Xiaomi","model":"Redmi Note 9 Pro","os":"Android","osv":"12","hwv":"Xiaomi Redmi Note 9 Pro","language":"en","carrier":"Ufone","mccmnc":"410-03","ifa":"3d0491cd-bbf3-4897-8cd9-8209396f4566","h":2400,"w":1080,"connectiontype":3,"pxratio":2.75},"regs":{"ext":{"coppa":0,"gdpr":1}},"user":{},"source":{"tid":"71fd7d1a-77e5-422d-904a-ea09eb8c89f0"},"ext":{"prebid":{"storedrequest":{"id":"0689a263-318d-448b-a3d4-b02e8a709d9d"},"cache":{"bids":{},"vastxml":{}},"targeting":{}}}}
2024-07-23 12:00:26.743 23407-23407 DecorView[] org.prebid.mobile.prebidkotlindemo D onWindowFocusChanged hasWindowFocus true
2024-07-23 12:00:28.756 23407-23407 PrebidBaseNetworkTask org.prebid.mobile.prebidkotlindemo D Result: {"id":"71fd7d1a-77e5-422d-904a-ea09eb8c89f0","seatbid":[{"bid":[{"id":"prebid-demo-response-video-interstitial-320-480-original-api","impid":"71fd7d1a-77e5-422d-904a-ea09eb8c89f0","price":0.11701999999468729,"adm":"<?xml version= \"1.0\" encoding= \"UTF-8\"?> <VAST version= \"2.0\"> <Ad id= \"TestAd\"> <InLine><AdSystem>Prebid</AdSystem><AdTitle>VAST 2.0 Linear Ad</AdTitle><Creatives><Creative id= \"2014\" AdID= \"20150911\" sequence= \"1\"><Linear><Duration>00:00:15</Duration><MediaFiles><MediaFile delivery= \"progressive\" bitrate= \"348\" width= \"320\" height= \"180\" type= \"video/mp4\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile><MediaFile delivery= \"progressive\" bitrate= \"381\" width= \"620\" height= \"360\" type= \"video/mp4\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile><MediaFile delivery= \"progressive\" bitrate= \"553\" width= \"620\" height= \"360\" type= \"video/mp4\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile><MediaFile delivery= \"progressive\" bitrate= \"983\" width= \"620\" height= \"360\" type= \"video/mp4\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/PrebidLogo.mp4]]></MediaFile></MediaFiles></Linear></Creative><Creative AdID= \"TestAd-Companion\"><CompanionAds><Companion width= \"300\" height= \"250\"><StaticResource creativeType= \"image/jpeg\"><![CDATA[https://s3.amazonaws.com/files.prebid.org/creatives/prebid300x250.png]]></StaticResource><CompanionClickThrough><![CDATA[https://prebid.org/]]></CompanionClickThrough></Companion></CompanionAds></Creative></Creatives></InLine></Ad></VAST>","adid":"test-ad-id-12345","adomain":["prebid.org"],"crid":"test-creative-id-1","w":375,"h":667,"ext":{"prebid":{"type":"video","targeting":{"hb_pb":"0.10","hb_env":"mobile-app","hb_size_prebid":"375x667","hb_pb_prebid":"0.10","hb_bidder_prebid":"prebid","hb_size":"375x667","hb_bidder":"prebid","hb_env_prebid":"mobile-app"}},"origbidcpm":0.11701999999468729,"origbidcur":"USD"}}],"seat":"prebid","group":0}],"cur":"USD","ext":{"errors":{"cache":[{"code":999,"message":"HTTP status code 404"}]},"warnings":{"prebid":[{"code":999,"message":"WARNING: request.imp[0].ext must contain at least one valid bidder"}]},"responsetimemillis":{"cache":202,"prebid":0},"tmaxrequest":5000,"prebid":{"auctiontimestamp":1721718028692}}}
2024-07-23 12:00:28.785 23407-23407 PrebidMacrosResolution org.prebid.mobile.prebidkotlindemo E replace: Failed. Input string is null or empty.
2024-07-23 12:00:28.785 23407-23407 PrebidMacrosResolution org.prebid.mobile.prebidkotlindemo E replace: Failed. Input string is null or empty.
2024-07-23 12:00:28.786 23407-23407 PrebidBidLoader org.prebid.mobile.prebidkotlindemo D Schedule refresh timer
2024-07-23 12:00:28.786 23407-23407 PrebidBidLoader org.prebid.mobile.prebidkotlindemo D setupRefreshTimer: Canceled. AdConfiguration is null or AdType is not Banner
2024-07-23 12:00:28.892 23407-23407 rebidkotlindem org.prebid.mobile.prebidkotlindemo W Accessing hidden method Landroid/media/AudioTrack;->getLatency()I (unsupported, reflection, allowed)
2024-07-23 12:00:28.903 23407-23407 ExoPlayerImpl org.prebid.mobile.prebidkotlindemo I Init d79135e [ExoPlayerLib/2.15.1] [joyeuse, Redmi Note 9 Pro, Xiaomi, 31]
2024-07-23 12:00:28.936 23407-23407 Compatibil...geReporter org.prebid.mobile.prebidkotlindemo D Compat change id reported: 147600208; UID 10591; state: ENABLED
2024-07-23 12:00:29.090 23407-23445 rebidkotlindem org.prebid.mobile.prebidkotlindemo E Attempt to load writable dex file: /data/user/0/org.prebid.mobile.prebidkotlindemo/cache/1621276117097.jar
2024-07-23 12:00:29.091 23407-23445 ziparchive org.prebid.mobile.prebidkotlindemo W Unable to open '/data/user/0/org.prebid.mobile.prebidkotlindemo/cache/1621276117097.dm': No such file or directory
2024-07-23 12:00:29.094 23407-23445 hc org.prebid.mobile.prebidkotlindemo D File /data/user/0/org.prebid.mobile.prebidkotlindemo/cache/1621276117097.dex not found. No need for deletion
2024-07-23 12:00:29.183 1533-2216 VerityUtils system_server E Failed to measure fs-verity, errno 1: /data/app/~~LGIs57qgAbCt2Qld8Qst7A==/org.prebid.mobile.prebidkotlindemo-w74ZfcyRz1xlRVtk11w2Eg==/base.apk
2024-07-23 12:00:33.016 23407-23649 MetadataUtil org.prebid.mobile.prebidkotlindemo D
I am trying to run InStream Ad. I cloned the PreBidMobile Android repo and just run the code and open Activity GamOriginalApiInStreamActivity. In this Ad video is being skipped or I do not know it is somehow giving some cache error after not playing Ad video just jumped to content video part.
Samle code:
This screens run after the initialization of Prebid SDK and MobileAdsSDK
My device Logs right after requesting the stored imp