AI-generated Key Takeaways
-
GADMediaContent provides information about media content and should be interacted with on the main queue.
-
You can check if the media content has video using the
hasVideoContent
property and control video playback with thevideoController
. -
The
aspectRatio
property provides the width/height ratio of the media content, returning 0 if unknown or no media content exists. -
For video content, you can access its
duration
andcurrentTime
in seconds, both returning 0 if there's no video or the information is unknown. -
Native ads can use the
mainImage
property to display an image when video content is not present.
GADMediaContent
@interface GADMediaContent : NSObject
Provides media content information. Interact with instances of this class on the main queue only.
-
Controls the media content’s video.
Declaration
Swift
var videoController: VideoController { get }
Objective-C
@property (nonatomic, readonly, nonnull) GADVideoController *videoController;
-
Indicates whether the media content has video content.
Declaration
Swift
var hasVideoContent: Bool { get }
Objective-C
@property (nonatomic, readonly) BOOL hasVideoContent;
-
Media content aspect ratio (width/height). The value is 0 when there’s no media content or the media content aspect ratio is unknown.
Declaration
Swift
var aspectRatio: CGFloat { get }
Objective-C
@property (nonatomic, readonly) CGFloat aspectRatio;
-
The video’s duration in seconds or 0 if there’s no video or the duration is unknown.
Declaration
Swift
var duration: TimeInterval { get }
Objective-C
@property (nonatomic, readonly) NSTimeInterval duration;
-
The video’s current playback time in seconds or 0 if there’s no video or the current playback time is unknown.
Declaration
Swift
var currentTime: TimeInterval { get }
Objective-C
@property (nonatomic, readonly) NSTimeInterval currentTime;