Hello, I am wanting to use a custom liquid block on the Sense theme to show different media (image or video) for the desktop and mobile versions of my website. I have tried using the code below, but it only successfully works on the desktop version of the website. When I view the webpage on a mobile device both the specified desktop and mobile media versions are displayed. What changes should I make to the code to only have the proper media show when viewing the desktop and mobile versions of the site? Thanks in advance!
My website url is - https://kovaasport.com/
[
](https://kovaasport.com/collections/bike-jerseys)
Hello @bikerboi
See above answer :
Solution: make the quote same
1 Like
@SetuBridge_1 Thank you! that removes the second video from the desktop site. Now when I load the homepage on my iPhone the video does not automatically loop and play like it does on desktop… There is a ‘play’ button over the video - any suggestions how to fix this? When viewing the preview in the Shopify page builder it appears to work fine, so not sure what fixes I need to incorporate.
1 Like
Hello

I hope it will works if not please try the below answer
Here is a little hack to overcome all the struggles you have with video autoplay on a website:
- Check video is playing or not.
- Trigger video play on events like body click or touch.
Note: Some browsers don’t let videos autoplay unless the user interacts with the device.
So scripts to check whether the video is playing are:
Object.defineProperty(HTMLMediaElement.prototype, 'playing', {
get: function () {
return !!(this.currentTime > 0 && !this.paused && !this.ended && this.readyState > 2);
}});
And then you can simply autoplay the video by attaching event listeners to the body:
$('body').on('click touchstart', function () {
const videoElement = document.getElementById('home_video');
if (videoElement.playing) {
// video is already playing so do nothing
}
else {
// video is not playing
// so play video now
videoElement.play();
}
});
1 Like