├── LICENSE ├── MMM-EasyBack.css ├── MMM-EasyBack.js ├── README.md ├── images ├── Example.jpg └── Your background picture files go in this folder.txt └── videos └── baboon.mp4 /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Mykle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MMM-EasyBack.css: -------------------------------------------------------------------------------- 1 | /* Copy and paste any or all of these css entries into your custom.css file inside your 2 | * css folder. The functions are annotated to make things as easy as possible for you. 3 | * 4 | */ 5 | 6 | 7 | .MMM-EasyBack .photo { 8 | width: 100%; /* size the picture */ 9 | } 10 | 11 | .MMM-EasyBack #video { 12 | width: 110%; 13 | height: 110%; 14 | } 15 | 16 | .MMM-EasyBack .iframe { 17 | margin-top: 50px; 18 | margin-bottom: 0px; 19 | margin-left: 50px; 20 | margin-right: 0px; 21 | } 22 | -------------------------------------------------------------------------------- /MMM-EasyBack.js: -------------------------------------------------------------------------------- 1 | /* Magic Mirror 2 | * Module: MMM-EasyBack 3 | * 4 | * By Mykle1 5 | * MIT Licensed. 6 | */ 7 | Module.register("MMM-EasyBack", { 8 | 9 | defaults: { 10 | bgName: "", // .jpg, .gif, .png, Full screen animated gifs too! 11 | videoName: "", // your local picture files go in "images" folder of MMM-EasyBack 12 | youTubeID: "So3vH9FY2H4", // YouTube ID from the YouTube url 13 | height: "1080px", // your display's resolution in pixels. Enter in config.js 14 | width: "1920px", // your display's resolution in pixels. Enter in config.js 15 | animationSpeed: "0", 16 | updateInterval: 60 * 60 * 1000, 17 | }, 18 | 19 | start: function() { 20 | self = this; 21 | this.url = ''; 22 | 23 | setInterval(function() { 24 | self.updateDom(self.config.animationSpeed || 0); 25 | }, this.config.updateInterval); 26 | 27 | if (this.config.bgName != "") { 28 | this.url = "modules/MMM-EasyBack/images/" + this.config.bgName; 29 | } else if (this.config.videoName != "") { 30 | this.url = "modules/MMM-EasyBack/videos/" + this.config.videoName; 31 | } 32 | }, 33 | 34 | 35 | getStyles: function() { 36 | return ["MMM-EasyBack.css"] 37 | }, 38 | 39 | // Override dom generator. 40 | getDom: function() { 41 | 42 | if (this.config.youTubeID != '') { 43 | 44 | var iframe = document.createElement("IFRAME"); 45 | iframe.classList.add("iframe"); 46 | iframe.style = "border: 0 none transparent "; 47 | iframe.width = this.config.width; 48 | iframe.height = this.config.height; 49 | type="text/javascript"; 50 | iframe.src = `https://www.youtube.com/embed/${this.config.youTubeID}?autoplay=1&mute=1&loop=1&showinfo=0&vq=hd1080 allowfullscreen`; 51 | 52 | return iframe; 53 | 54 | } else 55 | 56 | var wrapper = document.createElement("div"); 57 | 58 | var image = document.createElement("img"); 59 | if (this.config.bgName != '') { 60 | image.src = this.url; 61 | image.className = "photo"; 62 | console.log("MMM-EasyBack: Now showing image background") 63 | wrapper.appendChild(image); 64 | 65 | } else if (this.config.videoName != '') { 66 | var video = document.createElement(null); 67 | wrapper.innerHTML = ``; 68 | wrapper.appendChild(video); 69 | 70 | } else { 71 | console.log("MMM-EasyBack error: Please enter either image OR video in config.js NOT BOTH"); 72 | } 73 | 74 | return wrapper; 75 | }, 76 | 77 | 78 | ///// Add this function to the modules you want to control with voice ////// 79 | ///// Must be the same as in "sentences" array in MMM-voice.js ///// 80 | 81 | notificationReceived: function(notification, payload) { 82 | if (notification === 'HIDE_BACKGROUND') { 83 | this.hide(); 84 | } else if (notification === 'SHOW_BACKGROUND') { 85 | this.show(1000); 86 | } 87 | }, 88 | }); 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## MMM-EasyBack 2 | 3 | The easiest way to use video and pictures as a background on your mirror. 4 | 5 | Use any YouTube video as a live background with just the YouTube ID of the video. 6 | 7 | Works by default with Hello-Lucy voice. https://github.com/mykle1/Hello-Lucy. 8 | 9 | .jpg files, .png files, .gif files, Full Screen animated gifs (not recommended for Pi users). 10 | 11 | .mp4 and .mov files (others not tested). 12 | 13 | ## Where your background files go 14 | 15 | * Your background picture files go in the "images" folder inside the MMM-EasyBack module folder. 16 | 17 | * Your local video files go in the "videos" folder inside the MMM-EasyBack module folder. 18 | 19 | ## Installation 20 | 21 | * `git clone https://github.com/mykle1/MMM-EasyBack` into the `~/MagicMirror/modules` directory. 22 | 23 | ## Config.js entry and options 24 | 25 | ``` 26 | { 27 | module: 'MMM-EasyBack', 28 | position: 'fullscreen_below', 29 | config: { 30 | bgName: "Example.jpg", // "Example.jpg", the file name of your background image (case sensitive) 31 | videoName: "", // "baboon.mp4", // file name of your local video 32 | youTubeID: "", //"SkeNMoDlHUU", // "So3vH9FY2H4", // ID from any YouTube video. ID comes after the = sign of YouTube url 33 | height: "1080px", // your display's resolution in pixels. Enter in config.js 34 | width: "1920px", // your display's resolution in pixels. Enter in config.js 35 | } 36 | }, 37 | ``` 38 | 39 | ## Remember 40 | 41 | * Background picture files go in the "images" folder inside the MMM-EasyBack module folder. 42 | 43 | * Your local video files go in the "videos" folder inside the MMM-EasyBack module folder. 44 | 45 | * No need to download YouTube video. You only need the ID from the YouTube url 46 | 47 | ## Electron browser may hinder autostart of video media 48 | 49 | ### Do this 50 | 51 | Edit MagicMirror/js/electron.js 52 | 53 | Add the line shown below 54 | 55 | ``` 56 | let mainWindow; 57 | 58 | function createWindow() { 59 | app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required'); //< -------- added 60 | ``` 61 | 62 | Save and restart MagicMirror 63 | 64 | ## Fix for use with Chromium Browser 65 | 66 | ### Thanks to sdetweil and Darkmx-6 67 | 68 | I edited the file chromium_start.sh found here: 69 | ``` 70 | pi@raspberrypi:~ $ ls 71 | chromium_start.sh MagicMirror mmstart.sh node-v10.16.0-linux-armv6l package-lock.json 72 | and added 73 | ``` 74 | --autoplay-policy=no-user-gesture-required 75 | 76 | Example: 77 | 78 | GNU nano 3.2 chromium_start.sh 79 | ``` 80 | #!/bin/sh 81 | unclutter & 82 | xset -dpms # disable DPMS (Energy Star) features. 83 | xset s off # disable screen saver 84 | xset s noblank # don’t blank the video device 85 | matchbox-window-manager & 86 | #midori -e Fullscreen -a http://localhost:8080 87 | chromium-browser --autoplay-policy=no-user-gesture-required --incognito --kiosk http://localhost:8080/ 88 | ``` 89 | 90 | -------------------------------------------------------------------------------- /images/Example.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykle1/MMM-EasyBack/56151ee0049285198e32f3cc9408ba2471d25a8b/images/Example.jpg -------------------------------------------------------------------------------- /images/Your background picture files go in this folder.txt: -------------------------------------------------------------------------------- 1 | Your background/Desktop pictures go in the images folder with this file 2 | -------------------------------------------------------------------------------- /videos/baboon.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykle1/MMM-EasyBack/56151ee0049285198e32f3cc9408ba2471d25a8b/videos/baboon.mp4 --------------------------------------------------------------------------------