تتيح حزمة تطوير البرامج لإعلانات الوسائط التفاعلية على Android إمكانية إنشاء قوائم تشغيل إعلانات آلية بالكامل. تُدرج هذه الميزة فواصل إعلانية في المحتوى على النحو المحدّد في إدارة إعلانات Google عند عرض إعلاناتك. ويبسّط أيضًا بشكل كبير رمز مشغّل الفيديو اللازم لعرض فواصل إعلانية، بما في ذلك الإعلانات قبل التشغيل وأثناء التشغيل وبعد التشغيل.
عند عرض الإعلانات في "مدير إعلانات Google"، يمكن تحديد قواعد إعلانية مختلفة، مثل "عرض فاصل إعلاني دائمًا في بداية المحتوى" أو "عرض فاصل إعلاني مدته دقيقة واحدة كل 30 دقيقة من المحتوى".
عند طلب الإعلانات، يمكن لخادم الإعلانات عرض قائمة تشغيل إعلانات. تعالج حزمة SDK قائمة التشغيل وتجدول تلقائيًا الفواصل الإعلانية التي تم تحديدها.
بما أنّ نظام التشغيل Android يستخدم مشغّل الفيديو نفسه لتشغيل الإعلانات والمحتوى،
إذا كنت تخطّط لتنفيذ قواعد الإعلانات، عليك حفظ موضع رأس التشغيل للمحتوى
عند بدء عرض الإعلان، ثم الانتقال إلى هذا الموضع عند انتهاء عرض الإعلان.
احرص على تنفيذ واجهة VideoAdPlayer في مشغّل الفيديو. يضمن ذلك إدراج الفواصل الإعلانية تلقائيًا في الأوقات المحدّدة في "مدير إعلانات Google".
يتم استخدام الحدثين CONTENT_PAUSE_REQUESTED
وCONTENT_RESUME_REQUESTED
لإيقاف المحتوى مؤقتًا واستئنافه عند تشغيل فواصل إعلانية. يُرجى الرجوع إلى مستندات واجهة برمجة التطبيقات ذات الصلة للحصول على تفاصيل حول هذه الأحداث.
ملاحظة: عند انتهاء تشغيل المحتوى أو توقّف المستخدم عن تشغيله، احرص على استدعاء AdsLoader.contentComplete لإعلام حزمة تطوير البرامج (SDK) بأنّ المحتوى قد انتهى. بعد ذلك، تعرض حزمة تطوير البرامج (SDK) فاصل الإعلانات ما بعد التشغيل، إذا تم تحديد موعد له. يتم عرض الحدث
ALL_ADS_COMPLETED عند تشغيل جميع الفواصل الإعلانية. بالإضافة إلى ذلك، يُرجى العِلم أنّ تتبُّع المحتوى يبدأ عند استدعاء init()، ويجب دائمًا استدعاء init() قبل تشغيل المحتوى.
تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-09-06 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\u003cp\u003eIMA Android SDK simplifies video ad integration by automating ad playlist insertion and playback, including pre-rolls, mid-rolls, and post-rolls.\u003c/p\u003e\n"],["\u003cp\u003eAd breaks are scheduled based on rules defined in Google Ad Manager, enabling features like pre-roll ads and periodic mid-rolls.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers must implement the \u003ccode\u003eVideoAdPlayer\u003c/code\u003e interface and manage content position during ad breaks for seamless transitions between ads and content.\u003c/p\u003e\n"],["\u003cp\u003eThe SDK provides events (\u003ccode\u003eCONTENT_PAUSE_REQUESTED\u003c/code\u003e, \u003ccode\u003eCONTENT_RESUME_REQUESTED\u003c/code\u003e) to handle content playback during ad breaks and signals ad completion with \u003ccode\u003eALL_ADS_COMPLETED\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eContent tracking begins with \u003ccode\u003einit()\u003c/code\u003e, which should be called before content playback, and \u003ccode\u003econtentComplete()\u003c/code\u003e should be called after content ends to trigger post-rolls.\u003c/p\u003e\n"]]],[],null,["Select platform: [HTML5](/interactive-media-ads/docs/sdks/html5/client-side/ad-rules \"View this page for the HTML5 platform docs.\") [Android](/interactive-media-ads/docs/sdks/android/client-side/ad-rules \"View this page for the Android platform docs.\") [iOS](/interactive-media-ads/docs/sdks/ios/client-side/ad-rules \"View this page for the iOS platform docs.\") [tvOS](/interactive-media-ads/docs/sdks/tvos/client-side/ad-rules \"View this page for the tvOS platform docs.\")\n\nIMA Android SDK supports fully automated ad playlists. This feature\ninserts ad breaks into the content as specified in\n[Google Ad Manager](//admanager.google.com/)\nwhen trafficking your ads. It also greatly simplifies the video player code\nnecessary to support ad breaks, including pre-rolls, mid-rolls and post-rolls.\n\n- When trafficking the ads in Ad Manager, it is possible to specify various ad rules like \"always play ad break at the beginning of the content\" or \"play a one minute ad break every 30 minutes of content\".\n- When ads are requested, the ad server can return an ad playlist. The SDK processes the playlist and automatically schedules the ad breaks that have been specified.\n- Since Android uses the same video player for both ad and content playback, if you plan to implement ad rules, you must save the playhead position of your content when an ad starts, then seek to that position when the ad finishes. Be sure to implement the `VideoAdPlayer` interface in your video player. This ensures that ad breaks are automatically inserted at the times specified in Ad Manager. \n\n ```gdscript\n private boolean playingContent = true;\n private int contentPosition = -1;\n private List callbacks =\n new ArrayList();\n\n @Override\n public void addCallback(VideoAdPlayerCallback callback) {\n callbacks.add(callback);\n }\n\n @Override\n public void removeCallback(VideoAdPlayerCallback callback) {\n callbacks.remove(callback);\n }\n\n public void loadContent() {\n playingContent = true;\n load(CONTENT_URL);\n }\n\n @Override\n public void loadAd(String mediaUrl) {\n playingContent = false;\n load(mediaUrl);\n }\n\n public void pauseContent() {\n savePosition();\n pause();\n }\n\n @Override\n public void pauseAd() {\n pause();\n }\n\n private void pause() {\n myVideoView.pause();\n for (VideoAdPlayerCallback callback : callbacks) {\n callback.onPause();\n }\n }\n\n public void resumeContent() {\n loadContent();\n if (contentPosition \u003e 0) {\n restorePosition();\n }\n resume();\n }\n\n @Override\n public void resumeAd() {\n resume();\n }\n\n private void resume() {\n myVideoView.start();\n for (VideoAdPlayerCallback callback : callbacks) {\n callback.onResume();\n }\n }\n\n public void savePosition() {\n contentPosition = myVideoView.getCurrentPosition();\n }\n\n public void restorePosition() {\n myVideoView.seekTo(contentPosition);\n }\n ```\n- The `CONTENT_PAUSE_REQUESTED` and `CONTENT_RESUME_REQUESTED` events are used to pause and resume the content when ad breaks are played. Refer to the relevant [API documentation](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdEvent.AdEventType) for details on these events.\n\n**Note:** When the content has finished playing or\nthe user has stopped playback, be sure to call\n[AdsLoader.contentComplete](/interactive-media-ads/docs/sdks/android/client-side/api/reference/com/google/ads/interactivemedia/v3/api/AdsLoader#contentComplete())\nin order to signal to the SDK that the content is done. The SDK\nthen plays the post-roll ad break, if one has been scheduled. The\n`ALL_ADS_COMPLETED` event is raised when ALL ad breaks\nhave been played. In addition, note that content tracking begins when\n`init()` is called and you should always call `init()`\nbefore playing content."]]