Automatically close dialog xml after certain time
#1
How can I automatically close an opened dialog xml after a certain amount of time? Preferably an idle time (if no button on the dialog xml is pressed) or else a fixed time. So far I managed to hide it using <visible>!System.IdleTime(10)</visible>, but then, of course, after pressing a key it comes back. I want it closed instead.
Reply
#2
(2021-07-06, 17:53)unformatted Wrote: How can I automatically close an opened dialog xml after a certain amount of time? Preferably an idle time (if no button on the dialog xml is pressed) or else a fixed time. So far I managed to hide it using <visible>!System.IdleTime(10)</visible>, but then, of course, after pressing a key it comes back. I want it closed instead.

i think the easiest is a "monitor" as custom dialog.

xml:

<?
xml version="1.0" encoding="UTF-8"?>
<window type="dialog" id="1194">
<visible>System.IdleTime(10) + Window.IsActive(**dialog name**) </visible>
<onload>Diaolog.Close(**dialog name**)</onload>
<animation effect="fade" start="100" end="0" time="100">WindowClose</animation>
<controls />
</window>
Skins |  Titan M O D   •   S W A N (WIP)
Reply
#3
That means an extra monitor xml which will be "running" all the time. Not sure if I want that because I have more dialogs which I want to automatically close after a couple of seconds. So there's no way to do this from within the dialog xml itself?
Reply
#4
(2021-07-07, 12:39)unformatted Wrote: Not sure if I want that because I have more dialogs which I want to automatically close after a couple of seconds.

Just add them to the visible condition and use conditional onloads for each.
Reply
#5
(2021-07-07, 12:55)Hitcher Wrote:
(2021-07-07, 12:39)unformatted Wrote: Not sure if I want that because I have more dialogs which I want to automatically close after a couple of seconds.

Just add them to the visible condition and use conditional onloads for each.
I'm sorry but I don't understand what you mean with "conditional onloads".
Reply
#6
xml:
<onload condition="Window.IsVisible(**dialog 1**)">Diaolog.Close(**dialog 1**)</onload>
<onload condition="Window.IsVisible(**dialog 2**)">Diaolog.Close(**dialog 2**)</onload>
<onload condition="Window.IsVisible(**dialog 3**)">Diaolog.Close(**dialog 3**)</onload>
Reply
#7
(2021-07-07, 14:23)Hitcher Wrote:
xml:
<onload condition="Window.IsVisible(**dialog 1**)">Diaolog.Close(**dialog 1**)</onload>
<onload condition="Window.IsVisible(**dialog 2**)">Diaolog.Close(**dialog 2**)</onload>
<onload condition="Window.IsVisible(**dialog 3**)">Diaolog.Close(**dialog 3**)</onload>

Thanks a lot you guys for pointing this noob in the right direction. I'm going fiddle with this and see how it works.
Reply
#8
@mardukL

I've created a custom dialog as monitor, as per your suggestion, implemented it and it works fine. However I'm experiencing a problem now which I can't figure out. Let me explain as detailed as possible.

I have a keymaps.xml which invokes my remote's power button to show a custom dialog with buttons (labels actually) with id 1150.
xml:

<keymap>
    <global>
        <keyboard>
            <key id="61662">ActivateWindow(1150)</key>
            <key id="61656" mod="longpress">Action(info)</key>
            <key id="61624">ReloadSkin()</key>
            <key id="61625">Skin.ToggleDebug()</key>
        </keyboard>
    </global>
</keymap>

In the estuary skin folder (/usr/share/kodi/addons/skin.estuary/xml) this is the file "Custom_1150_Menu.xml":
xml:

<?xml version="1.0" encoding="utf-8"?>
<window id="1150" type="dialog">
    <onload>RunScript(/home/user/.kodi/userdata/monitoron0.py)</onload>
    <onload>ActivateWindow(1159)</onload>
    <defaultcontrol>1</defaultcontrol>
    <include>Animation_DialogPopupOpenClose</include>
    <controls>
        <control type="group">
            <centerleft>50%</centerleft>
            <width>600</width>
            <centertop>50%</centertop>
            <height>700</height>
            <include content="DialogBackgroundCommons">
                <param name="darken_bg" value="false" />
                <param name="width" value="600" />
                <param name="height" value="80" />
                <param name="header_label" value="Choose an option" />
                <param name="header_id" value="1" />
            </include>
            <control type="panel" id="1">
                <include>ButtonMenuList</include>
                <content>
                    <item>
                        <label>Suspend</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>ActivateScreensaver</onclick>
                        <onclick>SetVolume(0, showvolumebar)</onclick>
                        <onclick>PlayerControl(stop)</onclick>
                        <onclick>Dialog.Close(all,true)</onclick>
                        <onclick>ActivateWindow(home)</onclick>
                        <onclick>SetFocus(9000)</onclick>
                        <onclick>RunScript(/home/user/.kodi/userdata/kodiidle.py)</onclick>
                        <visible>true</visible>
                    </item>
                    <item>
                        <label>Monitor off</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>RunScript(/home/user/.kodi/userdata/monitoroff0.py)</onclick>
                        <visible>true</visible>
                    </item>
                    <item>
                        <label>Speakers</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>RunScript(/home/user/.kodi/userdata/speakerselect.py)</onclick>
                        <visible>true</visible>
                    </item>
                    <item>
                        <label>Ambilight</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>ActivateWindow(1151)</onclick>
                        <visible>true</visible>
                    </item>
                    <item>
                        <label>Player process info</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>ActivateWindow(playerprocessinfo)</onclick>
                        <visible>true</visible>
                    </item>
                    <item>
                        <label>Storage</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>RunScript(/home/user/.kodi/userdata/storage.py)</onclick>
                        <visible>false</visible>
                    </item>
                    <item>
                        <label>Favourites</label>
                        <onclick>Dialog.Close(1150)</onclick>
                        <onclick>ActivateWindow(Favourites)</onclick>
                        <visible>true</visible>
                    </item>
                </content>
            </control>
        </control>
    </controls>
</window>

This also loads the monitor dialog "Custom_1159_MenuMonitor.xml":
xml:

<?xml version="1.0" encoding="utf-8"?>
<window id="1159" type="dialog">
    <visible>System.IdleTime(10) + Window.IsActive(1151)</visible>
    <onload condition="Window.IsVisible(1151)">Dialog.Close(1151)</onload>
    <controls></controls>
</window>

This dialog monitors, when the ambilight button is pressed, the "Custom_1151_MenuAmbilight.xml":
xml:

<?xml version="1.0" encoding="utf-8"?>
<window id="1151" type="dialog">
    <defaultcontrol>1</defaultcontrol>
    <include>Animation_DialogPopupOpenClose</include>
    <controls>
        <control type="group">
            <centerleft>50%</centerleft>
            <width>600</width>
            <centertop>50%</centertop>
            <height>700</height>
            <include content="DialogBackgroundCommons">
                <param name="darken_bg" value="false" />
                <param name="width" value="600" />
                <param name="height" value="80" />
                <param name="header_label" value="Ambilight" />
                <param name="header_id" value="1" />
            </include>
            <control type="panel" id="1">
                <include>ButtonMenuList</include>
                <content>
                     <item>
                         <label>Power</label>
                         <onclick>RunScript(/home/user/.kodi/userdata/ambilightselect.py)</onclick>
                         <onclick>Action(Down)</onclick>
                         <visible>true</visible>
                     </item>
                     <item>
                         <label>Mode</label>
                         <onclick>RunScript(/home/user/.kodi/userdata/ambilightmode.py)</onclick>
                         <onclick>Action(Down)</onclick>
                         <visible>true</visible>
                     </item>
                     <item>
                         <label>Up</label>
                         <onclick>RunScript(/home/user/.kodi/userdata/ambilightup.py)</onclick>
                         <visible>true</visible>
                     </item>
                     <item>
                         <label>Down</label>
                         <onclick>RunScript(/home/user/.kodi/userdata/ambilightdown.py)</onclick>
                         <visible>true</visible>
                     </item>
                </content>
            </control>
        </control>
    </controls>
</window>

As soon as this dialog is up, the monitor dialog (1159) closes the ambilight dialog (1151) when no key is pressed after 10 seconds. Just as expected.

But now I want to do more development on the 1150 and 1151 dialogs so I decided to remove the monitor dialog for the time being by removing the line
xml:

<onload>ActivateWindow(1159)</onload>
from the 1150 dialog.

I then rebooted and to my suprise the monitor dialog (1159) is still working even though it is not called from my custom dialogs! When I look at the kodi log it shows that the monitor dialog "Custom_1150_Menu.xml" is loaded on GUI init:
xml:

..
2021-07-09 10:06:48.582 T:434      INFO <general>: Unloaded skin
2021-07-09 10:06:48.585 T:434      INFO <general>:   load skin from: /usr/share/kodi/addons/skin.estuary/ (version: 3.0.5)
2021-07-09 10:06:48.585 T:434      INFO <general>:   load fonts for skin...
2021-07-09 10:06:48.588 T:434      INFO <general>: Loading skin includes from /usr/share/kodi/addons/skin.estuary/xml/Includes.xml
2021-07-09 10:06:48.669 T:434      INFO <general>: Loading fonts from /usr/share/kodi/addons/skin.estuary/xml/Font.xml
2021-07-09 10:06:48.783 T:434      INFO <general>:   load new skin...
2021-07-09 10:06:48.783 T:434      INFO <general>: Loading custom window XMLs from skin path /usr/share/kodi/addons/skin.estuary/xml
2021-07-09 10:06:48.799 T:434      INFO <general>:   initialize new skin...
2021-07-09 10:06:48.799 T:434      INFO <general>: Loading skin file: Custom_1109_TopBarOverlay.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.823 T:434      INFO <general>: Loading skin file: DialogBusy.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.826 T:434      INFO <general>: Loading skin file: DialogNotification.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.828 T:434      INFO <general>: Loading skin file: DialogSeekBar.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.846 T:434      INFO <general>: Loading skin file: Custom_1159_MenuMonitor.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.846 T:434      INFO <general>: Loading skin file: DialogExtendedProgressBar.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.849 T:434      INFO <general>: Loading skin file: Pointer.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.851 T:434      INFO <general>: Loading skin file: DialogBusy.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.852 T:434      INFO <general>: Loading skin file: DialogVolumeBar.xml, load type: LOAD_ON_GUI_INIT
2021-07-09 10:06:48.855 T:434      INFO <general>: Loading resource://resource.uisounds.kodi/sounds.xml
2021-07-09 10:06:48.938 T:434      INFO <general>:   skin loaded...
2021-07-09 10:06:48.938 T:434      INFO <general>: Loading skin file: Startup.xml, load type: LOAD_EVERY_TIME
2021-07-09 10:06:48.939 T:434      INFO <general>: Loading skin file: Home.xml, load type: KEEP_IN_MEMORY
..

Before I start messing things up I'd like to know what's happening here. Why is the monitor dialog loaded on GUI init?
Reply
#9
Remove <onload>ActivateWindow(1159)</onload> from Custom_1150_Menu.xml as it's not needed. That dialog will open automatically after 10 seconds of idle.
Reply
#10
(2021-07-09, 18:56)Hitcher Wrote: Remove <onload>ActivateWindow(1159)</onload> from Custom_1150_Menu.xml as it's not needed. That dialog will open automatically after 10 seconds of idle.

Meanwhile I figured out why that is, I noticed that the xml from the kodi log all have the <visible> tag in the window header. As soon as I remove this tag from my monitor dialog and reboot then the monitor dialog is not loaded anymore. So any dialogs in the xml folder with a <visible> tag in the window header are automatically loaded when kodi starts. I couldn't find any of this in the wiki but now it all makes sense. Thanks again.
Reply
#11
The following custom dialog closes the video OSD (which opens when pressing "OK" while playing a movie) after 10 seconds idle time.
xml:

        <?xml version="1.0" encoding="utf-8"?>
        <window id="1159" type="dialog">
            <visible>System.IdleTime(10) + Window.IsActive(videoosd)</visible>
            <onload condition="Window.IsVisible(videoosd)">Dialog.Close(all,true)</onload>
        </window>
This works even when Settings, Subtitles and Bookmarks dialogs are opened, but NOT when Information is opened.

How can I close this "Information" window? I don't see any corresponding xml in the estuary skin folder. All I can find in the VideoOSD.xml is that the information button (id 70043) has <onclick>Info</onclick>.
Reply
#12
(2021-07-11, 11:40)unformatted Wrote: The following custom dialog closes the video OSD (which opens when pressing "OK" while playing a movie) after 10 seconds idle time.
xml:

        <?xml version="1.0" encoding="utf-8"?>
        <window id="1159" type="dialog">
            <visible>System.IdleTime(10) + Window.IsActive(videoosd)</visible>
            <onload condition="Window.IsVisible(videoosd)">Dialog.Close(all,true)</onload>
        </window>
This works even when Settings, Subtitles and Bookmarks dialogs are opened, but NOT when Information is opened.

How can I close this "Information" window? I don't see any corresponding xml in the estuary skin folder. All I can find in the VideoOSD.xml is that the information button (id 70043) has <onclick>Info</onclick>.
<onclick>Info</onclick> is bit different handled

If fullscreenvideo is active it opens 'fullscreeninfo'
if videoosd' window is active (maybe also also dialogseekbar ? and other dialogs which are opened when fullscreenvideo is active but not the main window) it toogles ' Player.ShowInfo ' Boolean Condition/Setting true/false

So you can check either

   
xml:
<window id="1159" type="dialog">
            <visible>System.IdleTime(10) + [Window.IsActive(videoosd) | Window.IsActive(fullscreeninfo)]</visible>
            <onload condition="Window.IsVisible(videoosd) | Window.IsActive(fullscreeninfo)">Dialog.Close(all,true)</onload>
        </window>

BUT i recommend not do this for that case, i recommend using an onclick and onfocus conditions for your OSD Control Buttrons (this way you have better control on which button you want it)


eg
for osd button which use player control actions
xml:
<include condition="true" content="Close_OSD_onfocus" />

for osd button player setting control (non playback related)
xml:
<include condition="false" content="Close_OSD_onfocus" />

<include name="Close_OSD_onfocus">
        <onclick condition="player.paused">AlarmClock(timeout_close_videoosd,dialog.close(videoosd),00:10,silent)</onclick>
        <onunfocus condition="System.HasAlarm(timeout_close_videoosd)">CancelAlarm(timeout_close_videoosd,silent)</onunfocus>
    </include>


EDIT:

The onclick set an timeout and force close osd after 10seconds in that case
But if you navigate to another button this alarm get canceld till you hit a button again which using thias actions.
I think thats more relevant as it save you a dialog and you have better control.

A String for the timeout is also valid, e.g. i use skinstring, which is set before
       
xml:
<onclick condition="player.paused">AlarmClock(timeout_close_videoosd,dialog.close(videoosd),00:0$INFO[Skin.String(timeout_close_videoosd)],silent)</onclick>
        <onunfocus condition="System.HasAlarm(timeout_close_videoosd)">CancelAlarm(timeout_close_videoosd,silent)</onunfocus>
Skins |  Titan M O D   •   S W A N (WIP)
Reply
#13
Not sure that I can follow you, I don't have much experience with this skinning stuff. What you are saying is that I should change something to the OSD button controls as well? I'm affraid that's a little beyond what I had in mind, just this one custom xml script. But anyway I'm still trying to "capture" the status of this information overlay. So I tried a few things:

xml:

<window id="1159" type="dialog">
    <visible>System.IdleTime(10)</visible>
    <onload>Info</onload>
</window>
When playing video, this will show the information overlay after 10 seconds idle, after pressing a key and another 10 seconds the overlay disappears.

If I use
xml:

<onload>ActivateWindow(fullscreeninfo)</onload>
instead, the information overlay shows after 10 seconds idle, but after pressing a key and another 10 seconds it will not disapear.

So then I thought if I use this:
xml:

<window id="1159" type="dialog">
    <visible>System.IdleTime(10) + WindowIsActive(fullscreeninfo)</visible>
    <onload>Notification(Test, hello)</onload>
</window>
,
play a video, press the OK button to enter the video OSD and press the information button and wait 10 seconds then I would expect the notification to pop up but alais, nothing.

Thanks again for your suggestions, I'm still trying to get my head around this and learn along the way. Cheers.
Reply
#14
Hm....


I read here -> https://forum.kodi.tv/showthread.php?tid...pid3048726

That you want to close the osd AND the vidoefullscrenn info after 10 seconds.

If so you should just use that monitor method
xml:
<window id="1159" type="dialog"> <visible>System.IdleTime(10) + [Window.IsActive(videoosd) | Window.IsActive(fullscreeninfo)]</visible> <onload condition="Window.IsVisible(videoosd) | Window.IsActive(fullscreeninfo)">Dialog.Close(all,true)</onload> </window>


But its better to use the alarm function, so you can place it to corresponding button control.
txt:

AlarmClock(name,command,time[,silent,loop])
   - Pops up a dialog asking for the length of time (mmConfuseds) for the alarm (unless the parameter time is specified), and starts a timer. When the timer runs out, it'll execute the built-in command (the parameter command) if it is specified, otherwise it'll pop up an alarm notice. Add silent to hide the alarm notification. Add loop for the alarm to execute the command each time the specified time interval expires.


CancelAlarm(name[,silent])
   - Cancel a running alarm. Set silent to true to hide the alarm notification.


So, it can look something like that
play or pause
xml:
<control type="togglebutton" id="100">
   <visible>Player.HasVideo</visible>
   <onclick condition="player.paused">AlarmClock(timeout_close_videoosd,dialog.close(videoosd),00:10,silent)</onclick>
    <onunfocus condition="System.HasAlarm(timeout_close_videoosd)">CancelAlarm(timeout_close_videoosd,silent)</onunfocus>
    <usealttexture>!Player.Paused</usealttexture>
   <onclick>PlayerControl(play)</onclick>
</control>

<control type="button" id="101">
   <width>60</width>
   <height>60</height>
here dont like to use the alarm , so omit it
  <onclick>ActivateWindow(osdsubtitlesettings)</onclick>
</control>
Skins |  Titan M O D   •   S W A N (WIP)
Reply

Logout Mark Read Team Forum Stats Members Help
Automatically close dialog xml after certain time0