Kể từ Chrome 53 và iOS 10, Android và iPhone hỗ trợ phát video trực tiếp và
tự động phát không có tiếng. Hướng dẫn này sẽ chỉ cho bạn các sửa đổi đối với
mẫu đơn giản
cần thiết cho chức năng này.
Quảng cáo có thể bỏ qua yêu cầu trình phát video của bạn phát nội dung cùng dòng (không phải phát toàn màn hình),
đồng thời tắt tính năng phát tuỳ chỉnh trên iPhone. Tính năng phát tuỳ chỉnh luôn tắt
trên Android Chrome. Sửa đổi HTML và JavaScript của mẫu đơn giản như sau:
google.ima.settings.setDisableCustomPlaybackForIOS10Plus(true);
adDisplayContainer =
new google.ima.AdDisplayContainer(containerElement, contentVideoElement);
adsLoader = new google.ima.AdsLoader(adDisplayContainer);
Sự thay đổi đối với HTML này đảm bảo rằng nội dung của bạn sẽ phát trong trình phát video cùng dòng trên
iPhone, thay vì trình phát toàn màn hình mặc định của iPhone và khởi động ở trạng thái tắt tiếng.
Việc thay đổi JavaScript khiến SDK IMA sử dụng trình phát video riêng để phát quảng cáo,
thay vì sử dụng lại trình phát nội dung như bình thường trên iPhone.
[null,null,["Cập nhật lần gần đây nhất: 2024-10-15 UTC."],[[["Starting with Chrome 53 and iOS 10, inline video playback and muted autoplay are supported on Android and iPhone."],["This guide provides modifications for the simple sample to enable this functionality, requiring inline video player use for skippable ads and disabling custom playback on iPhones."],["Updates include adding `playsinline` attribute to the video element in HTML and calling `google.ima.settings.setDisableCustomPlaybackForIOS10Plus(true)` in JavaScript."],["These changes ensure content plays inline on iPhone, preventing default fullscreen and utilizing IMA SDK's video player for ad playback instead of the content player."],["Note that fullscreen implementations relying on `videoPlayer.requestFullscreen()` will break with this change as fullscreen with skippable ads on iPhone is currently unsupported by IMA SDK."]]],[]]