লাইভস্ট্রিমের জন্য প্রি-রোল বিজ্ঞাপন লোড করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
iOS এর জন্য Google ইন্টারেক্টিভ মিডিয়া বিজ্ঞাপন (IMA) SDK।
IMA SDK লাইভ স্ট্রীম এবং সেইসাথে ভিডিও-অন-ডিমান্ড নগদীকরণ করতে ব্যবহার করা যেতে পারে। লাইভ স্ট্রিমের জন্য, আপনাকে প্রতিটি বিজ্ঞাপন বিরতির জন্য একটি নতুন বিজ্ঞাপনের অনুরোধ করতে হবে। আপনার সমস্ত দর্শক একই সময়ে বিজ্ঞাপনের অনুরোধ করছে না এবং বিজ্ঞাপন সার্ভার (গুলি) বগ ডাউন করছে তা নিশ্চিত করতে এই অনুরোধগুলিকে স্তব্ধ করুন৷
এতে সাহায্য করার জন্য, IMA SDK-এর AdsRequest.liveStreamPrefetchSeconds
প্রপার্টি রয়েছে। আপনি AdsLoader.requestAds()
কল করার পরে বিজ্ঞাপন সার্ভারের সাথে যোগাযোগ করার আগে SDK-কে কত সেকেন্ড অপেক্ষা করতে হবে তা এই বৈশিষ্ট্যটি নির্দিষ্ট করে৷ প্রকৃত অনুরোধের সময় র্যান্ডমাইজ করা হবে। উদাহরণ স্বরূপ, আপনি যদি AdsRequest.liveStreamPrefetchSeconds
30 সেট করেন, তাহলে SDK 0 থেকে 30 সেকেন্ড অপেক্ষা করে আপনি AdsLoader.requestAds()
কল করার পর প্রকৃতপক্ষে সার্ভারে অনুরোধ করতে।
অনুশীলনে লাইভ স্ট্রিম প্রাক-আনয়ন
একটি বিজ্ঞাপন বিরতি সম্পূর্ণ হওয়ার সাথে সাথে আমরা আপনার পরবর্তী বিজ্ঞাপন বিরতি প্রি-ফেচ করার পরামর্শ দিই। এটি নিশ্চিত করে যে আপনার প্রাক-আনয়ন উইন্ডোর জন্য সর্বাধিক দৈর্ঘ্য উপলব্ধ। ধরুন আপনার বিজ্ঞাপন বিরতির মধ্যে 5 মিনিট আছে। যখন একটি বিজ্ঞাপন বিরতি সম্পূর্ণ হয়, আপনি 290 সেকেন্ডের একটি প্রি-ফেচ উইন্ডোর সাথে আপনার পরবর্তী বিজ্ঞাপন বিরতির অনুরোধ করতে পারেন (প্রি-ফেচ উইন্ডোর শেষে পাঠানো অনুরোধগুলির সমাধান করার জন্য পর্যাপ্ত সময় আছে তা নিশ্চিত করতে 5 মিনিট বিয়োগ 10 সেকেন্ড):
উদ্দেশ্য-C
- (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event {
...
switch (event.type) {
...
case kIMAAdEvent_ALL_ADS_COMPLETED:
IMAAdsRequest *request = [[IMAAdsRequest alloc]
initWithAdTagUrl: self.adTagUrl
adDisplayContainer: self.adDisplayContainer
avPlayerVideoDisplay: self.avPlayerVideoDisplay
pictureInPictureProxy: self.pictureInPictureProxy
userContext: nil];
// set a delay between the end of the last ad
// in the last request, and the first ad from
// the new request
Float64 adGap = 30;
// make sure the request occurs at least five
// seconds before starting the new set of ads
request.liveStreamPrefetchSeconds = adGap - 5;
[self.adsLoader requestAdsWithRequest:request];
// start new ads after adGap seconds have elapsed
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, adGap * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[adsManager start];
});
break;
...
}
...
}
সুইফট
func adsManager(_ adsManager: IMAAdsManager!, didReceive event: IMAAdEvent!) {
switch event.type {
...
case IMAAdEventType.ALL_ADS_COMPLETED:
let request = IMAAdsRequest(
adTagUrl: AdTagUrl,
adDisplayContainer: adDisplayContainer,
contentPlayhead: contentPlayhead,
userContext: nil)
// set a delay between the end of the last ad
// in the last request, and the first ad from
// the new request
let adGap = 30
// make sure the request occurs at least five
// seconds before starting the new set of ads
request.liveStreamPrefetchSeconds = adGap - 5
adsLoader.requestAds(with: request)
// start new ads after adGap seconds have elapsed
DispatchQueue.main.asyncAfter(deadline: .now() + adGap) {
adsManager.start()
}
break
...
}
}
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-01 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-08-01 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThe IMA SDK allows for monetization of both live streams and video-on-demand content through ad integration.\u003c/p\u003e\n"],["\u003cp\u003eFor live streams, stagger ad requests using the \u003ccode\u003eAdsRequest.liveStreamPrefetchSeconds\u003c/code\u003e property to prevent ad server overload.\u003c/p\u003e\n"],["\u003cp\u003eSetting \u003ccode\u003eAdsRequest.liveStreamPrefetchSeconds\u003c/code\u003e introduces a randomized delay (within the specified range) before the SDK requests ads, helping distribute the load.\u003c/p\u003e\n"],["\u003cp\u003eIt's recommended to pre-fetch the next ad break immediately after the current one finishes, maximizing the available pre-fetch window and ensuring smooth transitions.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples demonstrate how to implement live stream ad pre-fetching in Objective-C and Swift, including setting an appropriate pre-fetch window to avoid delays.\u003c/p\u003e\n"]]],[],null,["# Load pre-roll ads for livestream\n\nthe Google Interactive Media Ads (IMA) SDK for iOS.\n\nThe IMA SDK can be used to monetize live streams as well as video-on-demand.\nFor live streams, you need to make a new ad request for each ad break.\nStagger these requests to ensure that all of your viewers aren't requesting\nads at the same time and bogging down the ad server(s).\n\nTo help with this, the IMA SDK has the `AdsRequest.liveStreamPrefetchSeconds`\nproperty. This property specifies the maximum number of seconds the SDK\nshould wait before reaching out to the ad server after you call\n`AdsLoader.requestAds()`. The actual request time will be randomized. For\nexample, if you set `AdsRequest.liveStreamPrefetchSeconds` to 30, the SDK\nwaits 0 to 30 seconds after you call `AdsLoader.requestAds()` to actually\nmake the request to the server.\n\nLive stream pre-fetch in practice\n---------------------------------\n\nWe recommend pre-fetching your next ad break as soon as an ad break completes.\nThis ensures the maximum length of time is available for your pre-fetch window.\nSuppose you have 5 minutes between ad breaks. When an ad break completes,\nyou can request your next ad break with a pre-fetch window of 290 seconds\n(5 minutes minus 10 seconds, to make sure the requests sent at the end of\nthe pre-fetch window have enough time to resolve): \n\n### Objective-C\n\n\n - (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event {\n\n ...\n\n switch (event.type) {\n\n ...\n\n case kIMAAdEvent_ALL_ADS_COMPLETED:\n\n IMAAdsRequest *request = [[IMAAdsRequest alloc]\n initWithAdTagUrl: self.adTagUrl\n adDisplayContainer: self.adDisplayContainer\n avPlayerVideoDisplay: self.avPlayerVideoDisplay\n pictureInPictureProxy: self.pictureInPictureProxy\n userContext: nil];\n\n // set a delay between the end of the last ad\n // in the last request, and the first ad from\n // the new request\n Float64 adGap = 30;\n // make sure the request occurs at least five\n // seconds before starting the new set of ads\n request.liveStreamPrefetchSeconds = adGap - 5;\n [self.adsLoader requestAdsWithRequest:request];\n // start new ads after adGap seconds have elapsed\n dispatch_after(dispatch_time(DISPATCH_TIME_NOW, adGap * NSEC_PER_SEC), dispatch_get_main_queue(), ^{\n [adsManager start];\n });\n\n break;\n\n ...\n\n }\n\n ...\n\n }\n\n### Swift\n\n func adsManager(_ adsManager: IMAAdsManager!, didReceive event: IMAAdEvent!) {\n switch event.type {\n\n ...\n\n case IMAAdEventType.ALL_ADS_COMPLETED:\n\n let request = IMAAdsRequest(\n adTagUrl: AdTagUrl,\n adDisplayContainer: adDisplayContainer,\n contentPlayhead: contentPlayhead,\n userContext: nil)\n\n // set a delay between the end of the last ad\n // in the last request, and the first ad from\n // the new request\n let adGap = 30\n // make sure the request occurs at least five\n // seconds before starting the new set of ads\n request.liveStreamPrefetchSeconds = adGap - 5\n adsLoader.requestAds(with: request)\n // start new ads after adGap seconds have elapsed\n DispatchQueue.main.asyncAfter(deadline: .now() + adGap) {\n adsManager.start()\n }\n\n break\n\n ...\n }\n }"]]