Read the statement by Michael Teeuw here.
MMM-pages - how to know which page index my module has?
-
Hi,
I am currently adopting MMM-MPlayer to interact with MMM-pages.
Reason is that suspending the module does not suspend (stop) the stream, as it is an overlay.
As long as MMM-MPlayer is running, it will always display the stream.From the config I can deduct the page index (3 in this case):
modules: [ ["compliments"], // page 1 ["MMM-YrThen"], // page 2 ["calendar"], // page 3 ["MMM-MPlayer"], // page 4 ],
And I see that reflected in the log:
0|MagicMirror | [2025-01-18 16:13:55.383] [LOG] [MMM-MPlayer.js:65:15] Received MMM-pages NEW_PAGE 3 0|MagicMirror | [2025-01-18 16:13:55.804] [LOG] [module.js:189:7] compliments is suspended. 0|MagicMirror | [2025-01-18 16:13:55.835] [LOG] [module.js:189:7] calendar is suspended. 0|MagicMirror | [2025-01-18 16:13:55.917] [LOG] [module.js:189:7] MMM-YrThen is suspended. 0|MagicMirror | [2025-01-18 16:13:56.395] [LOG] [module.js:196:7] clock is resumed. 0|MagicMirror | [2025-01-18 16:13:56.439] [LOG] [module.js:196:7] MMM-MPlayer is resumed.
But I would need to see my module name in the payload (MMM-MPlayer in this case), to act on the correct page index.
Come to think of it, I also would need the keyword
suspended
orresumed
in the payload, in order to know what to do.Any thoughts on this ?
Best regards,
E.J.
-
@evroom sorry, don’t quite understand
your module would support the suspend/resume functions and be called at each appropriately
MMM-pages calls hide and show
there is also a ‘different’ way to configure pages
use an arbitrary name for each page
and then add that to the classes of the modules you want on that page
see https://github.com/sdetweil/MMM-pages?tab=readme-ov-file#class-based-configuration
-
from my SampleModule.js
// system notification your module is being hidden // typically you would stop doing UI updates (getDom/updateDom) if the module is hidden suspend: function(){ }, // system notification your module is being unhidden/shown // typically you would resume doing UI updates (getDom/updateDom) if the module is shown resume: function(){ },
-
@evroom my MMM-SleepWake uses an external trigger to cause modules to be shown/hidden (screen saver where the screen won’t turn off)
I provide a commandline command to interact with the module…
i use a webcam with the motion project daemon to trigger show/hide -
@sdetweil
Yeah, this module is kind of in my foster care.
I did not come up with the code; only made some tweaks and made it available.
There is not suspend or resume to been seen in the code.But I will study the stuff you mentioned and will try to implement that.
Thx.
-
As a workaround, I will make it a requirement to put the MMM-Player on the first page (page index 0).
When I receive 0, then I will start streaming, otherwise I will stop streaming.
That seems to work. -
@sdetweil
Short question:There are 2 versions of MMM-pages:
https://github.com/edward-shen/MMM-pages
https://github.com/sdetweil/MMM-pagesThey seem in-sync, but which one would be the preferred one to take?
-
@evroom the core function is the same
i added the ability to have different page display timesi wrote the doc on the fixed page name approach
as you are using a notification now
just move that to suspend (same as index=0)
and the resume wakes you back up -
@sdetweil
He has the MMM-MPlayer working in pages and I am now using pages and MPlayer in my main MM.
Kinda of cool to be able to show a RSTP camera or 2 again… -
@plainbroke cool