Skip to content

Commit

Permalink
fix: fix iOS load media
Browse files Browse the repository at this point in the history
  • Loading branch information
andrepolischuk committed Apr 22, 2024
1 parent 39940e5 commit e850692
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .size-limit.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"path": "dist/index.js",
"limit": "19.8 KB"
"limit": "19.85 KB"
}
]
9 changes: 7 additions & 2 deletions src/runner/runWaterfall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,13 @@ export const runWaterfall = (
}

// NOTE: It seems that if the video doesn't load synchronously inside a touchend or click event handler, the user gesture breaks on iOS and it won't allow a play.
if (options.videoElement && options.videoElement.paused && isIos()) {
options.videoElement.load()
const shouldLoad =
isIos() &&
options.videoElement?.paused &&
options.videoElement?.canPlayType('application/vnd.apple.mpegurl')

if (shouldLoad) {
options.videoElement?.load()
}

waterfall(() => requestAd(adTag, resultOptions), placeholder, {
Expand Down

0 comments on commit e850692

Please sign in to comment.