• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

txt file for MMM embedyoutube

Scheduled Pinned Locked Moved Unsolved Requests
8 Posts 3 Posters 1.4k Views 2 Watching
Loading More Posts
  • 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.
  • C Offline
    chassain 0 @cowboysdude
    last edited by Jan 17, 2020, 5:33 PM

    @cowboysdude
    you’re right but it’s not for me but for a friend who want a magicmirror. He doesn’t have knowlegde about javascript and to minimalize some error i wanted to work with a text file on his computer, shared with his raspberry…more easy for him, his wife and children :)

    S 1 Reply Last reply Jan 17, 2020, 6:48 PM Reply Quote 0
    • S Offline
      sdetweil @chassain 0
      last edited by Jan 17, 2020, 6:48 PM

      @chassain-0 just read a file, line by line? any comment markers? (#, //, ;);

      something like this?

      list_of_images: [],
      
      read_video_ids: function(){
        let self=this
        var reader = new FileReader();
        reader.onload = function(progressEvent){
          // Entire file
          console.log(this.result);
          self.list_of_images=this.result.split(/\r\n|\n/); // windows or linux line ends
        };
        reader.readAsText( self.config.filename);
      }
      
      

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      C 1 Reply Last reply Jan 17, 2020, 6:59 PM Reply Quote 0
      • C Offline
        chassain 0 @sdetweil
        last edited by Jan 17, 2020, 6:59 PM

        @sdetweil
        line by line exactly…
        line 1 is for video_id without “”
        line 2 without “” to have second video for params video list

        i can read line to line but i need to integrate line 1in config/js to :
        video_id:“line 1”,
        and line2, line 3,… to ;
        video_list :[“line2”, “line3”,…]

        S 1 Reply Last reply Jan 17, 2020, 7:10 PM Reply Quote 0
        • S Offline
          sdetweil @chassain 0
          last edited by Jan 17, 2020, 7:10 PM

          @chassain-0 with or without quotes?

          the code above

          will turn this

          "line1"
          "line2"
          "line3"
          

          into this

          self.list_of_images=["line1","line2","line3"]
          

          change the variable names

          u can do that live, not have to put them in config.js, just read the file

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          C 1 Reply Last reply Jan 17, 2020, 7:13 PM Reply Quote 0
          • C Offline
            chassain 0 @sdetweil
            last edited by Jan 17, 2020, 7:13 PM

            @sdetweil ok thanks i will try this option.

            here a little example of config embedyoutube

            Module.register("MMM-EmbedYoutube", {
            	defaults: {
            		autoplay: false,
            		mute: true,
            		color: "red",
            		controls : false,
            		disablekb: false,
            		fs: true,
            		height: 315,
            		width: 560,
            		loop: false,
            		modestbranding: false,
            		rel : false,
            		showinfo : false,
            		video_id : "",
            		playlist: "",
            		video_list: []
            	},
            
            	getDom: function () {
            		var wrapper = document.createElement("div");
            
            		// Parameter
            		var params = "";
            
            		var videoList = "";
            		if (this.config.video_list && this.config.video_list.length > 0) {
            			videoList = "&playlist=";
            			for (var i = 0; i < this.config.video_list.length; i++) {
            				videoList += this.config.video_list[i];
            				if (i + 1 < this.config.video_list.length)
            					videoList += ",";
            			}
            		}
            
            
            1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil
              last edited by sdetweil Jan 18, 2020, 1:17 PM Jan 17, 2020, 7:41 PM

              u just want the item so u can cut/paste it into the config?

              even smaller, doit.js

              var fs = require("fs");
              var text = fs.readFileSync("./textfile");
              console.log("file="+text);
                  var list_of_images=text.toString().split(/\r\n|\n/); // windows or linux line ends
              
                 console.log("video_list:"+JSON.stringify(list_of_images));
              
              node doit.js
              file=line1
              line2
              line3
              line4
              line5
              video_list:["line1","line2","line3","line4","line5"]
              

              | changed to use ‘:’ instead of = , easier cut/paste jnto config.js

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                7/8
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Sam, technical setup by Karsten.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy