קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
StreamManager
classpublic
טיפול בשידורים של הטמעת מודעות דינמיות. הוא מנהל את האינטראקציות עם הקצה העורפי של DAI, מטפל בפינים למעקב וכן מעביר אירועי סטרימינג ומודעות לבעלי האפליקציה. שילוב עם CAF API לממשק המשתמש של המודעות.
יצרן
StreamManager
new
StreamManager(mediaElement)
פרמטר
mediaElement
אופציונלי
רכיב המדיה ב-HTML שבו תתבצע ההפעלה. יש לציין את הערך הזה רק אם משתמשים בנגן מותאם אישית.
הפונקציה מחזירה את מזהה מקור הנתונים של מקור הנתונים הנוכחי.
החזרות
(null or string)
loadStreamMetadata
הפונקציה loadStreamMetadata() מחזירה void
המערכת מבקשת מ-SDK לטעון את המטא-נתונים של המודעה, ולאחר מכן משדרת את האירוע StreamEvent.LOADED.
צריך להפעיל את הפעולה הזו באופן ידני אחרי שמניפסט הסטרימינג אוחזר מכלי צד שלישי לחיבור סרטונים. השדה הזה משמש רק להצגת VOD ב-Pod עם כלי מיזוג וידאו של צד שלישי, והוא לא פעיל לבקשות אחרות של סטרימינג.
[null,null,["עדכון אחרון: 2025-08-21 (שעון UTC)."],[[["\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`"]]