Solved

How can I display autoplay video only on the home page?

NeuroDepth
Excursionist
35 2 6

Hi, hoping someone can please help me. I have added an autoplay video to my website, but I only want it to be displayed on the home page. How do I remove it or hide it from all other pages. Eg; remove from product page, check out page etc. I assume I need to add a code for this? I have attached the link to my profile for reference.

 

https://neurodepthnd.com

 

Thank you.

Accepted Solution (1)
NeuroDepth
Excursionist
35 2 6

This is an accepted solution.

Resolved now, it is now working. I put part of the code in the wrong spot. Thanks so much for your help.

View solution in original post

Replies 6 (6)

Ujjaval
Shopify Partner
1242 197 209

@NeuroDepth you can add below code around where you have added the code of video 

{% if template == "index" or template == "page" %}
  // Add you video code here. so it will be appear in home page only
{% endif %}
NeuroDepth
Excursionist
35 2 6

Thanks for your help Ujjaval, the video has stopped playing on the other pages, but it has left a big white gap at the top of the page. How can I fix this?

Thank you

Ujjaval
Shopify Partner
1242 197 209

@NeuroDepth Had you added that video section into the all pages ? by customization add section feature ? If not then i have to looking into it to resolve the gapping issue. I need store access.

NeuroDepth
Excursionist
35 2 6
Good morning, auto play is working on iPhone, but not on laptop. Do you know how I can fix this?Below is the code I am using. Thank you.
 
{% if template == "index" or template == "page" %}
 
<video playsinline="" loop="" muted="" autoplay="autoplay" preload="" id="vid" width="100%">
 
 
<source src="
 
<iframe 
h=0bd374b918" width="640" height="200" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>.webm" type="video/webm"
 
  </video>
{% endif %}>
 
NeuroDepth
Excursionist
35 2 6

This is an accepted solution.

Resolved now, it is now working. I put part of the code in the wrong spot. Thanks so much for your help.

Hamza13005
Visitor
1 0 0

 Hello Ujjaval, Good morning, i need your help about this : 

<style>
video {
width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
</style>
<video autoplay playsinline loop controls>
<source src="">
<source src="https://cdn.shopify.com/videos/c/vp/12f8bc686e084deaa48274566f647868/12f8bc686e084deaa48274566f64786..."
type="video/mp4">
<source src="https://cdn.shopify.com/videos/c/vp/12f8bc686e084deaa48274566f647868/12f8bc686e084deaa48274566f64786..."
type="video/mp4">
</video>

 

I Need to make AUTOPLAY VIDEO AND SOUNDS TOO ONLY IN HOME PAGE? So Can you Help Me ??, So this is my luiqid code: can you give me correct code: <style>
video {
width: 100%;
height: auto;
display: block;
margin: 0 auto;
}
</style>
<video autoplay playsinline loop controls>
<source src="">
<source src="https://cdn.shopify.com/videos/c/vp/12f8bc686e084deaa48274566f647868/12f8bc686e084deaa48274566f64786..."
type="video/mp4">
<source src="https://cdn.shopify.com/videos/c/vp/12f8bc686e084deaa48274566f647868/12f8bc686e084deaa48274566f64786..."
type="video/mp4">
</video>

Thanks SO much !
 Have a good day , reply to mail adresse:  elfalloussihamza@gmail.com Thanks a lot bro