This might sound strange, but can I still display fallback image in that case?
Since video elements in mobile (Android & iOS) will open its native video player app when clicked, I want to show GIF version of the video (which I will place as the fallback image) for Android & iOS. I know how to detect whether the browser is mobile or not via Javascript, I just need some advice on best practice.
What I'm doing
<video>
<source mp4>
<source ogg>
<source webm>
<img src="*.gif">
</video>
Then in the js
if(site.isMobile()){
$('video').hide();
$('video img').show();
}
Of course it doesn't work since the img is inside video. I figure I can clone the img and append it before the video element and then hide the video element, something like this :
if(site.isMobile()){
$('video img').clone().prependTo('video'); // just some pseudocode
$('video').hide();
}
Is it a good practice though? Is there any simpler solution?
Video fallback, also known as waterfall or client-side mediation, maximizes the likelihood of filling an impression opportunity when you're using VAST redirects. With fallback, Ad Manager determines the eligibility of ads, ranks them accordingly, and returns a slate of ads, rather than just one.
We can use the onerror attribute on the image to set a fallback. We use the onerror to set the error to null and set the src of the image to a fallback. In our case, a photo of a missing cat. Note: It's not a great practice to rely on external images.
<video>: The Video Embed element. The <video> HTML element embeds a media player which supports video playback into the document. You can use <video> for audio content as well, but the <audio> element may provide a more appropriate user experience.
poster
may be what you're looking for:
Poster: A URL indicating a poster frame to show until the user plays or seeks. If this attribute isn't specified, nothing is displayed until the first frame is available; then the first frame is displayed as the poster frame. -Via https://developer.mozilla.org/en-US/docs/HTML/Element/video
<video width="316" height="161" poster="https://i.stack.imgur.com/BfXRi.png" controls>
<source src="https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" type="video/mp4" />
<source src="https://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv" type="video/ogg" />
Your browser does not support the video tag.
</video>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With