ตรวจสอบเหตุการณ์การบัฟเฟอร์โฆษณา
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
SDK โฆษณาสื่ออินเทอร์แอกทีฟ (IMA) สำหรับ iOS
คู่มือนี้อธิบายวิธีดำเนินการตามสถานะการบัฟเฟอร์โฆษณา
การใช้เหตุการณ์บัฟเฟอร์ในแอป
คุณสามารถใช้วิธีการมอบสิทธิ์ต่อไปนี้ใน IMAAdsManagerDelegate
เพื่อเพิ่มตัวบ่งชี้กิจกรรมลงในแอปเมื่อโฆษณาหยุดชั่วคราวเพื่อบัฟเฟอร์
- (void)adsManagerAdDidStartBuffering(IMAAdsManager *)adsManager
: เรียกใช้เมื่อโฆษณาที่เริ่มเล่นแล้วหยุดเพื่อบัฟเฟอร์
- (void)adsManager:(IMAAdsManager *)adsManager adDidBufferToMediaTime:(NSTimeInterval)mediaTime
:
เรียกว่าบัฟเฟอร์โฆษณา ระบบจะเรียกใช้เมธอดนี้ซ้ำๆ ตราบใดที่โฆษณายัง
บัฟเฟอร์อยู่
- (void)adsManagerAdPlaybackReady:(IMAAdsManager *)adsManager
: เรียกใช้เมื่อ
โฆษณาปัจจุบันได้รับการบัฟเฟอร์เพียงพอเพื่อให้การเล่นโฆษณาไม่น่าจะ
เกินบัฟเฟอร์
ตัวอย่าง
การเพิ่มทั้งหมดอิงตาม
ตัวอย่างขั้นสูงของ IMA SDK
(สำหรับทั้ง iOS และ tvOS) ดังนี้
@interface VideoViewController () <IMAAdsManagerDelegate,...>
...
@end
@implementation VideoViewController
...
- (void)adsManagerAdDidStartBuffering:(IMAAdsManager *)adsManager {
// Show your activity indicator above the video player - ad playback has
// stopped to buffer.
}
- (void)adsManagerAdPlaybackReady:(IMAAdsManager *)adsManager {
// Hide your activity indicator - as playback resumes.
}
คำถามที่พบบ่อย
ฉันแสดงตัวบ่งชี้กิจกรรมก่อนที่โฆษณาจะเริ่มเล่นได้ไหม
ได้ แต่เราขอแนะนำให้ใช้วิธีการมอบสิทธิ์ที่แตกต่างกันสำหรับกรณีการใช้งานนั้น คุณสามารถแสดงตัวบ่งชี้กิจกรรมเมื่อโทรหา [adsManager start]
และซ่อนตัวบ่งชี้กิจกรรมเมื่อจับภาพ kIMAAdEvent_STARTED
ใน
- (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-31 UTC
[null,null,["อัปเดตล่าสุด 2025-08-31 UTC"],[[["\u003cp\u003eThis guide explains how to utilize ad buffer events to implement an activity indicator in your app, enhancing user experience during ad playback.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the \u003ccode\u003eIMAAdsManagerDelegate\u003c/code\u003e methods to trigger actions like showing and hiding an activity indicator based on the ad's buffering state.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eadsManagerAdDidStartBuffering\u003c/code\u003e, \u003ccode\u003eadsManagerAdPlaybackReady\u003c/code\u003e, and \u003ccode\u003eadsManager:(IMAAdsManager *)adsManager adDidBufferToMediaTime:(NSTimeInterval)mediaTime\u003c/code\u003e methods provide signals for managing the activity indicator during buffering.\u003c/p\u003e\n"],["\u003cp\u003eWhile you can show an activity indicator before ad playback, using delegate methods specific to ad start events is recommended for that scenario.\u003c/p\u003e\n"]]],[],null,["# Monitor ad buffering events\n\nInteractive Media Ads (IMA) SDK for iOS.\n\nThis guide explains how to take action based on ad buffering state.\n\nUsing buffer events in your app\n-------------------------------\n\nYou can use the following delegate methods on `IMAAdsManagerDelegate` to add an\nactivity indicator to your app when ads pause to buffer:\n\n- `- (void)adsManagerAdDidStartBuffering(IMAAdsManager *)adsManager`: Called when an ad that already started playing has stopped to buffer.\n- `- (void)adsManager:(IMAAdsManager *)adsManager adDidBufferToMediaTime:(NSTimeInterval)mediaTime`: Called as an ad buffers. This method is called repeatedly as long as an ad is buffering.\n- `- (void)adsManagerAdPlaybackReady:(IMAAdsManager *)adsManager`: Called when the current ad is sufficiently buffered such that ad playback is not likely to outrun the buffer.\n\n### Example\n\nAll additions are based on the\n[IMA SDK Advanced Sample](//github.com/googleads/googleads-ima-ios/tree/master/Objective-C/AdvancedExample)\n(for both iOS and tvOS): \n\n```objective-c\n @interface VideoViewController () \u003cIMAAdsManagerDelegate,...\u003e\n\n ...\n\n @end\n\n @implementation VideoViewController\n\n ...\n\n - (void)adsManagerAdDidStartBuffering:(IMAAdsManager *)adsManager {\n // Show your activity indicator above the video player - ad playback has\n // stopped to buffer.\n }\n\n - (void)adsManagerAdPlaybackReady:(IMAAdsManager *)adsManager {\n // Hide your activity indicator - as playback resumes.\n }\n```\n\nFAQ\n---\n\n### Can I show an activity indicator before my ad starts playing?\n\nYes, but we recommend relying on different delegate methods for that\nuse case. You can show the activity indicator when you call `[adsManager start]`,\nand hide the activity indicator when you catch `kIMAAdEvent_STARTED` in\n`- (void)adsManager:(IMAAdsManager *)adsManager didReceiveAdEvent:(IMAAdEvent *)event`."]]