با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
StreamManager
عمومیکلاس
جریانهای درج آگهی پویا را مدیریت می کند. تعاملات با باطن DAI را مدیریت می کند و پینگ های ردیابی و همچنین انتقال جریان و رویدادهای تبلیغاتی را به ناشر انجام می دهد. با CAF API برای رابط کاربری تبلیغات ادغام می شود.
سازنده
StreamManager
StreamManager جدید (mediaElement)
پارامتر
mediaElement
اختیاری
عنصر رسانه HTML که در آن پخش انجام می شود. فقط در صورت استفاده از پخش کننده سفارشی ارائه دهید.
پرتاب می کند
زمانی که پارامترهای مورد نیاز ارائه نمی شوند.
اموال
پخش جریانی
PodServingStreamMonitor غیر پوچ
روش ها
addEventListener
addEventListener (نوع، شنونده) void را برمی گرداند
تابعی که هر بار که رویدادی از این نوع رخ می دهد نامیده می شود.
برمی گرداند
void
getStreamId
getStreamId() برمی گرداند (تهی یا رشته ای)
شناسه جریان را برای جریان فعلی برمیگرداند.
برمی گرداند
(null or string)
loadStreamMetadata
loadStreamMetadata() void را برمی گرداند
از SDK درخواست می کند تا ابرداده تبلیغات را بارگیری کند و سپس StreamEvent.LOADED را پخش می کند. پس از بازیابی مانیفست جریان از sticher ویدیوی شخص ثالث، این باید به صورت دستی فعال شود. این فقط برای Pod Serving VOD با استیچر ویدیوی شخص ثالث استفاده میشود و برای سایر درخواستهای پخش جریانی غیرفعال است.
برمی گرداند
void
removeEventListener
removeEventListener(type, listener) void را برمی گرداند
یک شنونده را برای نوع رویداد داده شده حذف می کند. تابع شنونده باید با ارجاع به تابعی که قبلاً به addEventListener ارسال شده است برابر باشد.
replaceAdTagParameters(adTagParameters) void را برمی گرداند
جایگزین تمام پارامترهای برچسب تبلیغاتی مورد استفاده برای درخواستهای تبلیغاتی آتی برای پخش زنده میشود.
پارامتر
adTagParameters
شی با ویژگی های رشته
پارامترهای برچسب آگهی جدید. باید مقادیر رشته ای داشته باشد.
مقدار نباید صفر باشد.
برمی گرداند
void
requestStream
requestStream(loadRequest، streamRequest) Promise حاوی (null، غیر تهی cast.framework.messages.LoadRequestData یا غیر تهی cast.framework.messages.ErrorData) را برمی گرداند.
درخواست می کند یک جریان با استفاده از پارامترهای جریان ارائه شده بارگیری شود. loadRequest را با داده های جریان بارگیری شده پر می کند.
تاریخ آخرین بهروزرسانی 2025-08-21 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-21 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eThe StreamManager class handles dynamic ad insertion streams, managing interactions with the DAI backend, tracking pings, and forwarding events.\u003c/p\u003e\n"],["\u003cp\u003eIt integrates with the CAF API for ad UI and requires a media element for playback only when using a custom player.\u003c/p\u003e\n"],["\u003cp\u003eKey methods include \u003ccode\u003egetStreamId\u003c/code\u003e, \u003ccode\u003eloadStreamMetadata\u003c/code\u003e, \u003ccode\u003ereplaceAdTagParameters\u003c/code\u003e, \u003ccode\u003erequestStream\u003c/code\u003e, and \u003ccode\u003ereset\u003c/code\u003e for stream management.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003erequestStream\u003c/code\u003e initiates stream loading using provided parameters, while \u003ccode\u003ereplaceAdTagParameters\u003c/code\u003e updates ad tag parameters for live streams.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ereset\u003c/code\u003e halts the stream manager and any ongoing polling processes, ensuring a clean state.\u003c/p\u003e\n"]]],[],null,["# Class: StreamManager\n\nStreamManager\n=============\n\nclass public\n\nHandles dynamic ad insertion streams. It manages interactions with the\nDAI backend and handles tracking pings as well as forwarding stream and\nad events to the publisher. Integrates with the CAF API for ad UI.\n\nConstructor\n-----------\n\n### StreamManager\n\nnew\nStreamManager(mediaElement)\n\n| #### Parameter ||\n|--------------|---------------------------------------------------------------------------------------------------|\n| mediaElement | Optional The HTML media element where playback will occur. Only provide if using a custom player. |\n\nThrows\n\n: when required parameters are not supplied.\n\nProperty\n--------\n\n### streamMonitor\n\nnon-null PodServingStreamMonitor\n\nMethods\n-------\n\n### addEventListener\n\naddEventListener(type, listener) returns void\n\nAdds a listener for the given event type.\n\n| #### Parameter ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| type | string The type of event to listen for. |\n| listener | function(non-null [StreamEvent](/ad-manager/dynamic-ad-insertion/sdk/cast/reference/js/StreamEvent)) A function called each time an event of this type occurs. |\n\nReturns\n\n: `void`\n\n### getStreamId\n\ngetStreamId() returns (null or string)\n\nReturns the stream id for the current stream.\n\nReturns\n\n: `(null or string)`\n\n### loadStreamMetadata\n\nloadStreamMetadata() returns void\n\nRequests SDK to load ad metadata and then broadcasts StreamEvent.LOADED.\nThis should be manually trigger once the stream manifest has been retrieved\nfrom 3rd party video stitcher. This is only used for Pod Serving VOD with\n3rd party video stitcher, and is no-op for other stream request.\n\nReturns\n\n: `void`\n\n### removeEventListener\n\nremoveEventListener(type, listener) returns void\n\nRemoves a listener for the given event type. The listener function must\nbe equal by reference to the one previously passed to `addEventListener`.\n\n| #### Parameter ||\n|----------|--------------------------------------------------------------------------------------------------------------------------------------------|\n| type | string The type of event for which to remove the listener. |\n| listener | function(non-null [StreamEvent](/ad-manager/dynamic-ad-insertion/sdk/cast/reference/js/StreamEvent)) The function to remove as a listener. |\n\nReturns\n\n: `void`\n\n### replaceAdTagParameters\n\nreplaceAdTagParameters(adTagParameters) returns void\n\nReplaces all of the ad tag parameters used for upcoming ad requests for a\nlive stream.\n\n| #### Parameter ||\n|-----------------|-----------------------------------------------------------------------------------------------------------|\n| adTagParameters | Object with string properties The new ad tag parameters. Must have string values. Value must not be null. |\n\nReturns\n\n: `void`\n\n### requestStream\n\nrequestStream(loadRequest, streamRequest) returns Promise containing (null, non-null cast.framework.messages.LoadRequestData, or non-null cast.framework.messages.ErrorData)\n\nRequests a stream to be loaded using provided stream parameters. Populates\nthe loadRequest with the loaded stream data.\n\n| #### Parameter ||\n|---------------|---------------------------------------------------------------------------------------------------------------|\n| loadRequest | cast.framework.messages.LoadRequestData Value must not be null. |\n| streamRequest | [StreamRequest](/ad-manager/dynamic-ad-insertion/sdk/cast/reference/js/StreamRequest) Value must not be null. |\n\nReturns\n\n: `non-null Promise containing (null, non-null cast.framework.messages.LoadRequestData, or non-null cast.framework.messages.ErrorData)`\n\n### reset\n\nreset() returns void\n\nResets the stream manager and removes any continuous polling.\n\nReturns\n\n: `void`"]]