GoogleInteractiveMediaAds Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
IMAStreamManager
@interface IMAStreamManager : NSObject
The IMAStreamManager class is responsible for playing streams.
-
The IMAStreamManagerDelegate to notify with events during stream playback.
-
Identifier used during dynamic ad insertion to uniquely identify a stream. This can be used in
the Stream Activity Monitor Debug Console to debug the stream session.
Declaration
Swift
var streamId: String? { get }
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *streamId;
-
The cuepoints for the current stream, populated after kIMAAdEvent_CUEPOINTS_CHANGED
event is
dispatched. Will be empty for live streams.
Declaration
Objective-C
@property (nonatomic, readonly) NSArray<IMACuepoint *> *_Nonnull cuepoints;
-
Initializes and loads the stream.
Parameters
adsRenderingSettings
|
the IMAAdsRenderingSettings. Pass in to influence ad rendering.
Use nil to default to standard rendering.
|
-
Returns the stream time with ads for a given content time. Returns the given content time
for live streams.
Declaration
Swift
func streamTime(forContentTime contentTime: TimeInterval) -> TimeInterval
Objective-C
- (NSTimeInterval)streamTimeForContentTime:(NSTimeInterval)contentTime;
Parameters
contentTime
|
the content time without any ads (in seconds)
|
Return Value
the stream time that corresponds with the given content time once ads are inserted
-
Returns the content time without ads for a given stream time. Returns the given stream time
for live streams.
Declaration
Swift
func contentTime(forStreamTime streamTime: TimeInterval) -> TimeInterval
Objective-C
- (NSTimeInterval)contentTimeForStreamTime:(NSTimeInterval)streamTime;
Parameters
streamTime
|
the stream time with inserted ads (in seconds)
|
Return Value
the content time that corresponds with the given stream time once ads are removed
-
Returns the previous cuepoint for the given stream time. Returns nil if no such cuepoint exists.
This is used to implement features like snap back, and called when the publisher detects that
the user seeked in order to force the user to watch an ad break they may have skipped over.
Declaration
Swift
func previousCuepoint(forStreamTime streamTime: TimeInterval) -> IMACuepoint?
Objective-C
- (nullable IMACuepoint *)previousCuepointForStreamTime:
(NSTimeInterval)streamTime;
Parameters
streamTime
|
the stream time that the was seeked to.
|
Return Value
the previous IMACuepoint for the given stream time.
-
Replaces all of the ad tag parameters used for upcoming ad requests for a
live stream.
Note that this call is a no-op for VOD streams.
Declaration
Swift
func replaceAdTagParameters(_ adTagParameters: [String : String]?)
Objective-C
- (void)replaceAdTagParameters:
(nullable NSDictionary<NSString *, NSString *> *)adTagParameters;
Parameters
adTagParameters
|
the new ad tag parameters for the current stream.
|
-
Requests SDK to retrieve the ad metadata and then load the provided streamManifestUrl and
streamSubtitles into the player. This should be manually triggered once the stream manifest has
been retrieved from the third party video stitcher. Note that this is only used for Pod serving
VOD with a third party video stitcher, and is a no-op for other stream request types.
Declaration
Swift
func loadThirdPartyStream(_ streamURL: URL, streamSubtitles: [[String : String]])
Objective-C
- (void)loadThirdPartyStream:(nonnull NSURL *)streamURL
streamSubtitles:
(nonnull NSArray<NSDictionary<NSString *, NSString *> *> *)
streamSubtitles;
Parameters
streamURL
|
the manifest url for the stream with dynamic ad insertion.
|
streamSubtitles
|
the subtitles array for the stream.
|
-
Cleans the stream manager’s internal state for proper deallocation.
Declaration
Objective-C
- (void)destroy;
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-20 UTC.
[null,null,["Last updated 2025-08-20 UTC."],[[["\u003cp\u003eThe IMAStreamManager class is the core component for playing streams with ads, handling ad insertion and stream management.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to initialize, control, and interact with streams, including seeking, retrieving cue points, and managing ad tag parameters.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the IMAStreamManagerDelegate to receive events and updates during stream playback, enabling custom ad integration and UI interactions.\u003c/p\u003e\n"],["\u003cp\u003eIt supports various functionalities like dynamic ad insertion, stream time management, and handling third-party streams for VOD content.\u003c/p\u003e\n"],["\u003cp\u003eFor proper cleanup and resource management, it's crucial to call the \u003ccode\u003edestroy\u003c/code\u003e method when the stream manager is no longer needed.\u003c/p\u003e\n"]]],["The `IMAStreamManager` class manages stream playback, including ad insertion. Key actions include initializing streams with `initializeWithAdsRenderingSettings:`, obtaining stream/content time conversions via `streamTimeForContentTime:` and `contentTimeForStreamTime:`, and retrieving cue points with `cuepoints` and `previousCuepointForStreamTime:`. It also handles live stream ad tag parameter replacement using `replaceAdTagParameters:`, and loading third-party streams through `loadThirdPartyStream:streamSubtitles:`. It notifies the `IMAStreamManagerDelegate` of stream events and cleans its internal state with `destroy`.\n"],null,["# GoogleInteractiveMediaAds Framework Reference\n\nIMAStreamManager\n================\n\n @interface IMAStreamManager : NSObject\n\nThe IMAStreamManager class is responsible for playing streams.\n- `\n ``\n ``\n `\n\n ### [delegate](#/c:objc(cs)IMAStreamManager(py)delegate)\n\n `\n ` \n The IMAStreamManagerDelegate to notify with events during stream playback. \n\n #### Declaration\n\n Swift \n\n weak var delegate: (any NSObjectProtocol & ../Protocols/IMAStreamManagerDelegate.html)? { get set }\n\n Objective-C \n\n @property (nonatomic, weak, nullable) NSObject\u003c../Protocols/IMAStreamManagerDelegate.html\u003e *delegate;\n\n- `\n ``\n ``\n `\n\n ### [streamId](#/c:objc(cs)IMAStreamManager(py)streamId)\n\n `\n ` \n Identifier used during dynamic ad insertion to uniquely identify a stream. This can be used in\n the Stream Activity Monitor Debug Console to debug the stream session. \n\n #### Declaration\n\n Swift \n\n var streamId: String? { get }\n\n Objective-C \n\n @property (nonatomic, copy, readonly, nullable) NSString *streamId;\n\n- `\n ``\n ``\n `\n\n ### [cuepoints](#/c:objc(cs)IMAStreamManager(py)cuepoints)\n\n `\n ` \n The cuepoints for the current stream, populated after `kIMAAdEvent_CUEPOINTS_CHANGED` event is\n dispatched. Will be empty for live streams. \n\n #### Declaration\n\n Swift \n\n var cuepoints: [../Classes/IMACuepoint.html] { get }\n\n Objective-C \n\n @property (nonatomic, readonly) NSArray\u003c../Classes/IMACuepoint.html *\u003e *_Nonnull cuepoints;\n\n- `\n ``\n ``\n `\n\n ### [-initializeWithAdsRenderingSettings:](#/c:objc(cs)IMAStreamManager(im)initializeWithAdsRenderingSettings:)\n\n `\n ` \n Initializes and loads the stream. \n\n #### Declaration\n\n Swift \n\n func initialize(with adsRenderingSettings: ../Classes/IMAAdsRenderingSettings.html?)\n\n Objective-C \n\n - (void)initializeWithAdsRenderingSettings:\n (nullable ../Classes/IMAAdsRenderingSettings.html *)adsRenderingSettings;\n\n #### Parameters\n\n |------------------------------|-----------------------------------------------------------------------------------------------------------|\n | ` `*adsRenderingSettings*` ` | the IMAAdsRenderingSettings. Pass in to influence ad rendering. Use nil to default to standard rendering. |\n\n- `\n ``\n ``\n `\n\n ### [-streamTimeForContentTime:](#/c:objc(cs)IMAStreamManager(im)streamTimeForContentTime:)\n\n `\n ` \n Returns the stream time with ads for a given content time. Returns the given content time\n for live streams. \n\n #### Declaration\n\n Swift \n\n func streamTime(forContentTime contentTime: TimeInterval) -\u003e TimeInterval\n\n Objective-C \n\n - (NSTimeInterval)streamTimeForContentTime:(NSTimeInterval)contentTime;\n\n #### Parameters\n\n |---------------------|-----------------------------------------------|\n | ` `*contentTime*` ` | the content time without any ads (in seconds) |\n\n #### Return Value\n\n the stream time that corresponds with the given content time once ads are inserted\n- `\n ``\n ``\n `\n\n ### [-contentTimeForStreamTime:](#/c:objc(cs)IMAStreamManager(im)contentTimeForStreamTime:)\n\n `\n ` \n Returns the content time without ads for a given stream time. Returns the given stream time\n for live streams. \n\n #### Declaration\n\n Swift \n\n func contentTime(forStreamTime streamTime: TimeInterval) -\u003e TimeInterval\n\n Objective-C \n\n - (NSTimeInterval)contentTimeForStreamTime:(NSTimeInterval)streamTime;\n\n #### Parameters\n\n |--------------------|------------------------------------------------|\n | ` `*streamTime*` ` | the stream time with inserted ads (in seconds) |\n\n #### Return Value\n\n the content time that corresponds with the given stream time once ads are removed\n- `\n ``\n ``\n `\n\n ### [-previousCuepointForStreamTime:](#/c:objc(cs)IMAStreamManager(im)previousCuepointForStreamTime:)\n\n `\n ` \n Returns the previous cuepoint for the given stream time. Returns nil if no such cuepoint exists.\n This is used to implement features like snap back, and called when the publisher detects that\n the user seeked in order to force the user to watch an ad break they may have skipped over. \n\n #### Declaration\n\n Swift \n\n func previousCuepoint(forStreamTime streamTime: TimeInterval) -\u003e ../Classes/IMACuepoint.html?\n\n Objective-C \n\n - (nullable ../Classes/IMACuepoint.html *)previousCuepointForStreamTime:\n (NSTimeInterval)streamTime;\n\n #### Parameters\n\n |--------------------|-----------------------------------------|\n | ` `*streamTime*` ` | the stream time that the was seeked to. |\n\n #### Return Value\n\n the previous IMACuepoint for the given stream time.\n- `\n ``\n ``\n `\n\n ### [-replaceAdTagParameters:](#/c:objc(cs)IMAStreamManager(im)replaceAdTagParameters:)\n\n `\n ` \n Replaces all of the ad tag parameters used for upcoming ad requests for a\n live stream.\n Note that this call is a no-op for VOD streams. \n\n #### Declaration\n\n Swift \n\n func replaceAdTagParameters(_ adTagParameters: [String : String]?)\n\n Objective-C \n\n - (void)replaceAdTagParameters:\n (nullable NSDictionary\u003cNSString *, NSString *\u003e *)adTagParameters;\n\n #### Parameters\n\n |-------------------------|---------------------------------------------------|\n | ` `*adTagParameters*` ` | the new ad tag parameters for the current stream. |\n\n- `\n ``\n ``\n `\n\n ### [-loadThirdPartyStream:streamSubtitles:](#/c:objc(cs)IMAStreamManager(im)loadThirdPartyStream:streamSubtitles:)\n\n `\n ` \n Requests SDK to retrieve the ad metadata and then load the provided streamManifestUrl and\n streamSubtitles into the player. This should be manually triggered once the stream manifest has\n been retrieved from the third party video stitcher. Note that this is only used for Pod serving\n VOD with a third party video stitcher, and is a no-op for other stream request types. \n\n #### Declaration\n\n Swift \n\n func loadThirdPartyStream(_ streamURL: URL, streamSubtitles: [[String : String]])\n\n Objective-C \n\n - (void)loadThirdPartyStream:(nonnull NSURL *)streamURL\n streamSubtitles:\n (nonnull NSArray\u003cNSDictionary\u003cNSString *, NSString *\u003e *\u003e *)\n streamSubtitles;\n\n #### Parameters\n\n |-------------------------|------------------------------------------------------------|\n | ` `*streamURL*` ` | the manifest url for the stream with dynamic ad insertion. |\n | ` `*streamSubtitles*` ` | the subtitles array for the stream. |\n\n- `\n ``\n ``\n `\n\n ### [-destroy](#/c:objc(cs)IMAStreamManager(im)destroy)\n\n `\n ` \n Cleans the stream manager's internal state for proper deallocation. \n\n #### Declaration\n\n Swift \n\n func destroy()\n\n Objective-C \n\n - (void)destroy;"]]