Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. Bug Reports
  3. script not working since laytheme 3.2

script not working since laytheme 3.2

Scheduled Pinned Locked Moved Bug Reports
4 Posts 2 Posters 84 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • albrechtA Offline
    albrechtA Offline
    albrecht
    wrote on last edited by
    #1

    script not working since laytheme 3.2

    Dear @Marius @mariusjopen and @Armin-Unruh @arminunruh,

    since major update 3.2 my little script (pic randomly a video from a list and play it at background) is not running anymore. it’s placed in the field "Custom HTML at bottom"

    can you pls help?

    thx
    <3

    here is the script code

    <script>
    jQuery(function() {
      var $videoElement;
      var numberOfMillisecondsBetweenVideoSwitches = 24000; // 10 seconds
      var currentVideoIndex = 0;
      var listOfVideoSources = [
        "http://albrechtgaebel.de/wp-content/uploads/2019/02/Banner-Zugfahrt.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2019/02/Banner_Pinakothek.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2019/02/Banner_PUMA.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2019/02/Banner_Waschstraße.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2019/02/Banner_onSet.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2019/02/Banner_ostsee2.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2017/10/Banner_web_sky.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2017/09/banner_lift.mp4",
        "http://albrechtgaebel.de/wp-content/uploads/2017/10/banner_web_Mediamarkt.mp4",
    
      ]
      
    function shuffle(array) {
      var currentIndex = array.length, temporaryValue, randomIndex;
    
      // While there remain elements to shuffle...
      while (0 !== currentIndex) {
    
        // Pick a remaining element...
        randomIndex = Math.floor(Math.random() * currentIndex);
        currentIndex -= 1;
    
        // And swap it with the current element.
        temporaryValue = array[currentIndex];
        array[currentIndex] = array[randomIndex];
        array[randomIndex] = temporaryValue;
      }
    
      return array;
    }
      
      function playVideo(event) {
          $videoElement[0].play()
      }
    
      function loadRandomVideo() {
        if(currentVideoIndex >= listOfVideoSources.length) {
            currentVideoIndex = 0
            shuffle(listOfVideoSources)
        }
        
        if(!$videoElement) {
            $videoElement = jQuery("#cover-region .background-video video")
            $videoElement.on("loadeddata", playVideo)
        }
          
        $videoElement.find('source').attr('src', listOfVideoSources[currentVideoIndex])
        $videoElement[0].load()  
    
        currentVideoIndex += 1
      }
      
      // randomize list of videos
      shuffle(listOfVideoSources)
      // choose a random one to start
      // loadRandomVideo("http://albrechtgaebel.de/wp-content/uploads/2017/10/Banner_web_Bellevue.mp4")
      // in numberOfMillisecondsBetweenVideoSwitches choose a different video
      setInterval(loadRandomVideo, numberOfMillisecondsBetweenVideoSwitches)
    })
    
     
    </script>
    
    1 Reply Last reply
    0
    • mariusjopenM Offline
      mariusjopenM Offline
      mariusjopen
      Global Moderator
      wrote on last edited by
      #2

      Dear @albrecht
      is there a way that you can isolate the problem? Does the script get called?
      Use console.log("TEST");

      Best!
      Marius

      www.mariusjopen.world

      1 Reply Last reply
      0
      • albrechtA Offline
        albrechtA Offline
        albrecht
        wrote on last edited by
        #3

        Dear @mariusjopen

        found the Problem (with friend of an real dev guy) ;)

        needed to change this

        jQuery("#cover-region .background-video video")
        

        to

        jQuery(".cover-region .background-video video")
        
        1 Reply Last reply
        0
        • mariusjopenM Offline
          mariusjopenM Offline
          mariusjopen
          Global Moderator
          wrote on last edited by
          #4

          Dear @albrecht
          Perfect! Glad to hear!
          Many wishes!
          Marius

          www.mariusjopen.world

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          I also code custom websites or custom Lay features.
          💿 Email me here: 💿
          info@laytheme.com

          Before you post:
          1. When using a WordPress Cache plugin, disable it or clear your cache.
          2. Update Lay Theme and all Lay Theme Addons
          3. Disable all Plugins
          4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

          This often solves issues you might run into

          When you post:
          1. Post a link to where the problem is
          2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
          3. If the problem is difficult to explain, post screenshots / link to a video to explain it
          Online Users
          I
          Ingi
          Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
          laytheme.com
          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Recent
          • Tags
          • Popular
          • Users
          • Search