hide next button until video finished

459 views
Skip to first unread message

Lukas von Flüe

unread,
Jan 28, 2021, 3:33:42 PM1/28/21
to oTree help & discussion
Hi all,

my subjects will see several videos. I save them in a folder called "static". I want to prevent the subjects from proceeding to a next page before they have clicked to start the video and the whole video has played.

Can I somehow hide the next button until subjects have clicked the video and the video has finished? If so, how? Or is there a better solution?

Below the code of the template page where I include the video:

Screen Shot 2021-01-28 at 21.32.05.png

Thanks in advance for your help.

Cheers,
Lukas 



film_code.txt

Chris @ oTree

unread,
Jan 28, 2021, 3:42:43 PM1/28/21
to Lukas von Flüe, oTree help & discussion
You can hide it with javascript. Take a look at javascript tutorials on how to show and hide elements on a page. 

Sent from my phone

On Jan 29, 2021, at 4:33 AM, Lukas von Flüe <lukass....@gmail.com> wrote:

Hi all,

my subjects will see several videos. I save them in a folder called "static". I want to prevent the subjects from proceeding to a next page before they have clicked to start the video and the whole video has played.

Can I somehow hide the next button until subjects have clicked the video and the video has finished? If so, how? Or is there a better solution?

Below the code of the template page where I include the video:

<Screen Shot 2021-01-28 at 21.32.05.png>


Thanks in advance for your help.

Cheers,
Lukas 



--
You received this message because you are subscribed to the Google Groups "oTree help & discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to otree+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/1e6f7796-50d7-4161-996e-b0080e0d7704n%40googlegroups.com.

<Screen Shot 2021-01-28 at 21.32.05.png>
<film_code.txt>

Chris @ oTree

unread,
Jan 28, 2021, 3:45:57 PM1/28/21
to oTree help & discussion
as for detecting the video state, you can use JavaScript also. Look on this page: 
also here:

Lukas von Flüe

unread,
Jan 28, 2021, 4:00:10 PM1/28/21
to oTree help & discussion
Hi Chris,

thanks for the quick reply. I will try that.

Cheers

Lukas von Flüe

unread,
Jan 29, 2021, 1:08:39 PM1/29/21
to oTree help & discussion
Hi all,

just in case someone else might be interested in the solution to my original question, below is a code that works.
As indicated by Chris, one way is to add an "EventListener" in Java and then set the visibility of the nextbutton to "hidden":

solved.png

Cheers,
Lukas

Aiste Petkeviciute

unread,
Apr 14, 2021, 12:11:28 PM4/14/21
to oTree help & discussion
Hello everyone,

I have tried to apply Lukas' solution but it does not seem to work for me.. I attach the screenshot.

If someone could help me, it would be great!

Best regards,
Aiste
Screenshot (70).png

Chris @ oTree

unread,
Apr 14, 2021, 12:23:10 PM4/14/21
to Aiste Petkeviciute, oTree help & discussion
Try using your browser’s javascript console to check for errors and use console.log to see if your code is executing as you expect. 

Sent from my phone

On Apr 15, 2021, at 12:11 AM, Aiste Petkeviciute <aist....@gmail.com> wrote:

Hello everyone,
To view this discussion on the web, visit https://groups.google.com/d/msgid/otree/3e796c7d-b120-4bd2-9b41-9ffe9be27904n%40googlegroups.com.
<Screenshot (70).png>

Nicole Voss

unread,
May 10, 2021, 9:16:19 PM5/10/21
to oTree help & discussion
Aiste, were you able to figure out how to make this work with an iFrame video? I'm thinking that is your issue. Is there a solution to this or an alternative? 
Reply all
Reply to author
Forward
0 new messages