Skip to content

Commit b29f09e

Browse files
committed
Add resolution for custom video assets
1 parent 2238828 commit b29f09e

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

src/content/docs/ios/migration-to-ios-sdk-v4.mdx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,18 @@ Rename the view, update the configuration parameter, and update any `didSelectPr
187187

188188
## AdaptyUI custom assets
189189

190-
### AdaptyUICustomVideoAsset.player
190+
### AdaptyUICustomVideoAsset
191191

192-
If you use custom video assets, replace `AVQueuePlayer` with `AVPlayer`:
192+
Two changes affect every existing call site:
193+
194+
- `.player` now takes `AVPlayer` instead of `AVQueuePlayer`.
195+
- Every case gained a trailing `resolution: CGSize?` parameter. Pass `nil` to keep the current behavior, or pass the actual pixel size so the player can reserve layout space (aspect ratio = `width / height`) before the video loads.
193196

194197
```diff showLineNumbers
198+
- case file(url: URL, preview: AdaptyUICustomImageAsset?)
199+
- case remote(url: URL, preview: AdaptyUICustomImageAsset?)
195200
- case player(item: AVPlayerItem, player: AVQueuePlayer, preview: AdaptyUICustomImageAsset?)
196-
+ case player(item: AVPlayerItem, player: AVPlayer, preview: AdaptyUICustomImageAsset?)
201+
+ case file(url: URL, preview: AdaptyUICustomImageAsset?, resolution: CGSize?)
202+
+ case remote(url: URL, preview: AdaptyUICustomImageAsset?, resolution: CGSize?)
203+
+ case player(item: AVPlayerItem, player: AVPlayer, preview: AdaptyUICustomImageAsset?, resolution: CGSize?)
197204
```

src/content/docs/version-3.0/get-pb-paywalls.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ For example, you can:
157157
- Show a different image or video to some users.
158158
- Show a local preview image while a remote main image is loading.
159159
- Show a preview image before running a video.
160+
- Provide a video's pixel resolution so the player reserves layout space (aspect ratio = `width / height`) before the video loads. Pass `nil` to skip this.
160161

161162
Here's an example of how you can provide custom assets via a simple dictionary:
162163

@@ -175,11 +176,12 @@ let customAssets: [String: AdaptyCustomAsset] = [
175176
)
176177
),
177178

178-
// Show a local video with a preview image
179+
// Show a local video with a preview image and a known resolution
179180
"hero_video": .video(
180181
.file(
181182
url: Bundle.main.url(forResource: "custom_video", withExtension: "mp4")!,
182-
preview: .uiImage(value: UIImage(named: "video_preview")!)
183+
preview: .uiImage(value: UIImage(named: "video_preview")!),
184+
resolution: CGSize(width: 1080, height: 1920)
183185
)
184186
),
185187
]

0 commit comments

Comments
 (0)