• Jack

    (@argentumfx)


    So I have this javascript code;

    <script type="text/javascript">setTimeout("window.close();", 3000);</script>

    that I am using to close a webpage after 3 seconds, I have tested it and it works as intended. However the functionality I’m really after is closing the page after a Youtube video ends – so I spent some time going through the Youtube Java API and found this;

    player.getPlayerState():Number

    Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).

    So I am trying to merge my initial script;
    <script type="text/javascript">setTimeout("window.close();", 3000);</script>

    with this;
    player.getPlayerState():0

    but I am relatively new to this area, please can someone explain how I can link these?

    Thanks,

    Best Regards,
    AFX

Viewing 3 replies - 1 through 3 (of 3 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Hi, I’m not sure what the WordPress issue is. Are you struggling to enqueue JS?

    @Argetumfx

    A few hints:

    What you try to achieve will fail for many reasons, the first is setTimeOut has no selector of anything. Thus it cannot pass to another call later.

    I suggest you make a button (be it a text, rectangle area or so) and open the video in a modal box, if that suits you. (WordPress loads Jquery anyways).

    Examples of simple jquery modal box:

    https://simplemodal.plasm.it/

    It can be achieved quite simply with a jquery onclick function, which will open whatever you want in a well, modal box.

    Hope it helps,

    Thread Starter Jack

    (@argentumfx)

    Hi @digico,

    The ideal scenario is that our customers click on an introduction video in one of our emails and it takes them to a full screen video player on our website, the functionality I’m looking to achieve is that the page closes when the video finishes so I was hoping to use javascript and Youtube’s API to achieve this…

    This is based on literally what I have read this morning and very little prior knowledge of how javascript functions etc, is the method I’m attempting to use invalid? Also can modal boxes be used to achieve the same effect?

    Thanks,

    Best Regards,
    AFX

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Javascript (Youtube Player)’ is closed to new replies.