Delay a module from loading?



  • The problem i got is that i need all my modules to load befor i load the Ifram module as i want it to load last and not when the rest is loading.
    As in the iFrame i got a live stream that auto plays when the Ifram module is loading and i want to save power for that as it is now all hangs when loading.

    Hope for an solution.



  • @wizz the modules get loaded in the order you put them in the config ;)



  • @strawberry-3-141 That i know but i want it to be delayed as it is a live stream that loads and plays on auto.
    So i rely need it as it is consuming cpu power when it loads and than the result is that my RPI hangs and needs to restart.

    Or if it is any function / Module so i can manage the stream by a mouse click or other as i can delete the line that turns the stream on automatically.



  • @wizz you could enhance the start function with a timeout which sets a flag delayload and calls the updatedom function, then in getdom you check if the delayload flag is set, if so then render the iframe



  • @strawberry-3-141 Thanks for your help and for all support.
    I rely like the solution and all works fine.
    So again many thanks for your help.



  • @strawberry-3.141 would you happen to sit on an example of this sorcery you speak of? I’m looking to add a delay to my newsfeed, as I have 3 different feeds, and it’s quite disorienting when all 3 reload at the same time.



  • @Advokaten

    Module.register("iFrame",{
      // Default module config.
      defaults: {
        height:"300px",
        width:"100%"
      },
    
      start: function(){
        setTimeout(() => {this.delayLoad = true; this.updateDom();}, 2 * 60 * 1000);
      },
    
      // Override dom generator.
      getDom: function() {
        var iframe = document.createElement("IFRAME");
    
        if(this.delayLoad){
          iframe.style = "border:0";
          iframe.width = this.config.width;
          iframe.height = this.config.height;
          iframe.src = this.config.url;
        }
        return iframe;
      }
    });
    

Log in to reply
 

Looks like your connection to MagicMirror Forum was lost, please wait while we try to reconnect.