Comments (10)
I'd enjoy it.
Thought about the description in the wiki
You can edit the Wiki page yourself 😃
PS: You re-opened the issue?
Yes, because @LukeSkywalker92 has marked the extension as a enhancement and I also think it's a feature that is interesting for everyone. I am currently looking for an easy way to install addons that are interesting for everyone. There are some ideas already, but not yet fully realized.
So that the topic is not forgotten, I have reopened the issue.
from teleframe.
Here is a first implementation in form of an addon:
Any comments?
How should I submit my code?
/**
* introduces quicker image changes after interactions and slows down with time
* @param {AddonBase inherited} interface object to register and send events
*/
// import interval from config.json
var fs = require('fs');
var configfile = fs.readFileSync("./config/config.json", "utf8");
var config = JSON.parse(configfile);
var maxInterval = (config.interval) ? config.interval:45000;
const additionalChanges = (config.imageCount) ? config.imageCount:30;
var counter = 1;
const functionFlexIntervals = (interface) => {
//interface.registerListener('newImage', (sender, type) => counter = 1);
interface.registerListener('images-loaded', () => counter = 1);
interface.registerListener('imageDeleted', () => counter = 1);
interface.registerListener('paused', (status) => counter = 1);
interface.registerListener('muted', (status) => counter = 1);
interface.registerListener('recordStopped', () => counter = 1);
interface.registerListener('unstarImage', index => counter = 1);
interface.registerListener('starImage', index => counter = 1);
interface.registerListener('changedActiveImage', index => {
// introduce an additional picture change:
if (counter < additionalChanges) {
var additionalChange = Math.round(maxInterval*counter/additionalChanges);
interface.logger.info("additional change in: " + additionalChange);
setTimeout(() => { interface.sendEvent('next'); }, additionalChange);
counter += 1;
};
});
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = functionFlexIntervals;
}
from teleframe.
Nice idea, exactly for these requirements the addon interface was implemented.
A few hints:
You do not need to read the configuration file itself. The configuration is provided by the addon interface and all keys have a valid value. So you can access the values directly.
For example:
//...
const functionFlexIntervals = (interface) => {
var config;
var counter = 1;
interface.registerListener('teleFrame-ready', teleFrameObjects => {
config = teleFrameObjects.config;
});
//...
interface.registerListener('changedActiveImage', index => {
// introduce an additional picture change:
if (counter < config.imageCount) {
var additionalChange = Math.round(config.interval*counter/config.imageCount);
interface.logger.info("additional change in: " + additionalChange);
setTimeout(() => { interface.sendEvent('next'); }, additionalChange);
counter += 1;
};
});
How should I submit my code?
Please create a repository for the addon yourself and we will link it on the Available TeleFrame addons - wiki page.
from teleframe.
Cool!
Here you go:
https://github.com/call-me-matt/teleframe-flexintervals
from teleframe.
It' s done.
from teleframe.
Another little hint:
You can specify the events you want to listen to using an array if you want to do the same thing every time.
interface.registerListener([
'images-loaded', 'imageDeleted', 'paused', 'muted',
'recordStopped', 'unstarImage', 'starImage'
], index => counter = 1);
from teleframe.
Thank you so much for your help.
I really like this addon-interface.
Thought about the description in the wiki, maybe "introduces quicker image changes which slow down with time" is a catchier description.
PS: You re-opened the issue?
from teleframe.
is there a way to detect if a picture or video is shown?
(call-me-matt/teleframe-flexintervals#3)
from teleframe.
I suppose you've noticed the problem with video playback time. It almost drove me crazy yesterday, too.
You can use interface.images[index].src
to check for .mp4
These changes should solve the problem
@@ -68,13 +68,16 @@ const functionFlexIntervals = (interface) => {
}
const additionalChange = Math.max(minChangeTime, Math.round(config.interval*counter/config.imageCount));
nextChangeTime = new Date().getTime() + additionalChange;
// introduce an additional picture change:
if (!isPaused && counter < config.imageCount) {
- setChangeTimer(additionalChange);
+ // ignore videos because the duration is unknown
+ if (!interface.images[index].src.match(/\.mp4$/i)) {
+ setChangeTimer(additionalChange);
+ }
counter += 1;
- };
+ }
});
};
from teleframe.
Great, thank you
from teleframe.
Related Issues (20)
- Default touch gestures on Waveshare 10.1 display HOT 1
- Installation problems caused by non compatible versions of node/npm
- keys a,l,k,left,right not working in other apps when TeleFrame is running
- Telefram stratet nicht HOT 5
- Allow (encrypted!) messages from Signal
- Text messages possible? HOT 1
- Message that the teleframe is powered on and ready to receive new pictures
- Charging State / Battery State
- turnOffHour HOT 1
- ToggleMonitor, TurnOnHour and TurnOffHour in 7" touch monitor with Raspi 4 not working HOT 2
- How to modify required settings? HOT 2
- White screen between image changes HOT 3
- stuck at splash screen "TeleFrame" HOT 9
- Reboot fails HOT 23
- No Image delete in bot mode HOT 2
- TeleFrame funktioniert nach Neustart nicht mehr HOT 1
- Automatic install & run issues with Raspberry Pi Os Bullseye HOT 3
- Black screen with logo on Debian HOT 3
- Depreciation warnings on npm install
- Not working in newer Electron versions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from teleframe.