Read the statement by Michael Teeuw here.
Controlling Embedded Youtube Video on MM
-
@zichao92 I cleaned up your module
Module.register("youtube",{ start: function() { Log.info("Starting module: " + this.name); }, getStyles: function() { return ['script.css']; }, sendCommand: function(cmd){ var myPlayer = document.getElementById('my-video'); if(myPlayer){ myPlayer.contentWindow.postMessage(JSON.stringify({ "event": "command", "func": cmd }), "*"); } }, notificationReceived: function(notification, payload) { if (notification === "PAUSE_VIDEO"){ this.sendCommand("pauseVideo"); } if (notification === "PLAY_VIDEO"){ this.sendCommand("playVideo"); } }, getDom: function() { var wrapper = document.createElement("div"); var background = document.createElement("div"); background.classList.add("video-background"); var foreground = document.createElement("div"); foreground.classList.add("video-foreground"); var iframe = document.createElement("iframe"); iframe.setAttribute("id", "my-video"); iframe.setAttribute("src", "https://www.youtube.com/embed/5kIe6UZHSXw?enablejsapi=1&autoplay=1"); iframe.setAttribute("frameborder", "0"); iframe.setAttribute("type", "text/html"); foreground.appendChild(iframe); background.appendChild(foreground); wrapper.appendChild(background); return wrapper; } });
-
OMG you are life saver. So the whole trick to my module is to use sendcommand instead?
-
@zichao92 not only you had some more issues and sendCommand is a custom method
-
These modules are very interesting.
Would it be possible to use voice command to manage pause and play of youtube?
Via notification?
Thank you -
@strawberry-3.141 Funny how the youtube URL renders within the code tags! :)
-
I had this problem with my Alarm Clock MM and voice commands. Everything works perfectly until the alarm sounds. Now my voice command has to compete with the alarm that is playing. The success rate was pretty low and I was not happy with that. Setting a long enough pause in the alarm sound to issue a voice command seemed to work ok but I wasn’t happy with that either. In the end, I settled for making a clickable button appear when the alarm sounded.
-
Now I control PLAY and PAUSE through voice commands in the youtube module, instead of with MMM-Remote-Control.
I would like to send data like http://localhost:8080 /youtube?Id=XXXXXXX, also with voice, but I can not find the form. The idea is to have a list of videos to play, automated by voice. Any idea?
It could become a very interesting module…