Startup.xml - Video loaded on start up keeps playing in loop
#1
I have tried to configure startup.xml to run a video at startup and then go to the Video, Files section.

If I leave out <onfocus>ReplaceWindow(video,files,return)</onfocus> then the video will just run once. If I add the second control to open the Video, Files section, the video plays in a loop.

Please find my code below. I'm doing something wrong but I can't figure out what. I have tried to give the second control a different button ID but this didn't help.

Code:
<window>
    <defaultcontrol always="true">10</defaultcontrol>
    <allowoverlay>no</allowoverlay>

    <controls>
        <control type="button" id="10">
            <description>trigger</description>
            <onfocus>PlayMedia(special://userdata/Intro4sec1080p.mp4)</onfocus>
            <texturenofocus>-</texturenofocus>
            <texturefocus>-</texturefocus>
            <visible>!Skin.HasSetting(Use_Startup_Playlist)</visible>
        </control>
        <control type="button" id="10">
            <description>trigger</description>
            <onfocus>ReplaceWindow(video,files,return)</onfocus>
            <texturenofocus>-</texturenofocus>
            <texturefocus>-</texturefocus>
            <visible>!Skin.HasSetting(Use_Startup_Playlist)</visible>
        </control>
        <control type="button" id="10">
            <description>trigger with startup Playlist</description>
            <onfocus>XBMC.PlayMedia($INFO[Skin.String(Startup_Playlist_Path)])</onfocus>
            <onfocus>ReplaceWindow($INFO[System.StartupWindow])</onfocus>
            <texturenofocus>-</texturenofocus>
            <texturefocus>-</texturefocus>
            <visible>Skin.HasSetting(Use_Startup_Playlist)</visible>
        </control>
        <include>CommonBackground</include>
    </controls>
</window>

Your help is much appreciated.
Reply
#2
you should avoid having two buttons with the same ID visible at the same time.
kodi will only use the first button of the two visible ones, this means the videos window won't be activated.

when the video ends, kodi goes back to the previous window: startup.
focuses button 10 again, and the video will start again.
so you basically created a loop.


you can add multiple onfocus actions to a single button, so merge the first two buttons:
Code:
<control type="button" id="10">
            <description>trigger</description>
            <onfocus>PlayMedia(special://userdata/Intro4sec1080p.mp4)</onfocus>
            <onfocus>ReplaceWindow(video,files,return)</onfocus>
            <texturenofocus>-</texturenofocus>
            <texturefocus>-</texturefocus>
            <visible>!Skin.HasSetting(Use_Startup_Playlist)</visible>
        </control>
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#3
taking it one step further, you could probably simplify the code by using onload actions.

Code:
<window>
    <onload condition="!Skin.HasSetting(Use_Startup_Playlist)">PlayMedia(special://userdata/Intro4sec1080p.mp4)</onload>
    <onload condition="!Skin.HasSetting(Use_Startup_Playlist)">ReplaceWindow(video,files,return)</onload>
    <onload condition="Skin.HasSetting(Use_Startup_Playlist)">XBMC.PlayMedia($INFO[Skin.String(Startup_Playlist_Path)])</onload>
    <onload condition="Skin.HasSetting(Use_Startup_Playlist)">ReplaceWindow($INFO[System.StartupWindow])</onload>
</window>
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#4
Thank you very much for your help ronie!

The first option you suggested worked like a charm. This was very helpful.
Reply

Logout Mark Read Team Forum Stats Members Help
Startup.xml - Video loaded on start up keeps playing in loop0