Kodi Community Forum

Full Version: Skin timer question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I've been experimenting with an auto-play function for trailers.

Currently I have it in a hidden button that's delayed for three seconds using an animation. It works with the following onfocus line:

xml:

<onfocus>PlayMedia($INFO[ListItem.Trailer],1,noresume)</onfocus>

I thought it might be more elegant to achieve this with the following skin timer so I'm not relying on a hidden button which causes warnings in the log and the effect is not reliant on the list being focused.

xml:

  <timer>
    <name>trailer_autoplay_idle_timer</name>
    <start reset="true">System.IdleTime(3) + Window.IsVisible(videos) + !Player.HasMedia + !String.IsEmpty(ListItem.Trailer)</start>
    <onstart>PlayMedia($INFO[ListItem.Trailer],1,noresume)</onstart>
    <stop>Player.HasMedia</stop>
  </timer>

But this is resulting in a playback error. I thought it might be because ListItem.Trailer couldn't be passed to the skin timer, but if I substitute the onstart line for the following, it appears to be able to display the trailer path just fine:

xml:

    <onstart>Notification(This shows the trailer path fine, $INFO[ListItem.Trailer],4000)</onstart>

The error I get looks like this. I've tried with $INFO and $ESCINFO

xml:

2022-09-09 13:35:49.479 T:10720    INFO <general>: VideoPlayer::OpenFile: $ESCINFO[ListItem.Trailer]
2022-09-09 13:35:49.495 T:9316    ERROR <general>: CApplication::OnApplicationMessage: Unhandled threadmessage sent, 1073741855
2022-09-09 13:35:51.481 T:10720   ERROR <general>: CRenderManager:TonguereInit - timed out waiting for renderer to preinit
2022-09-09 13:35:51.481 T:15992   DEBUG <general>: Thread VideoPlayer start, auto delete: false
2022-09-09 13:35:51.481 T:10720   DEBUG <general>: CApplicationPlayerCallback::OnPlayBackStarted: CApplication::OnPlayBackStarted
2022-09-09 13:35:51.482 T:15992    INFO <general>: Creating InputStream
2022-09-09 13:35:51.482 T:10720   DEBUG <general>: CAddonDatabase: SELECT repo.id FROM repo .. took 0 ms
2022-09-09 13:35:51.484 T:7868    DEBUG <general>: Loading settings for $ESCINFO[ListItem.Trailer]
2022-09-09 13:35:51.488 T:10720   DEBUG <general>: CAddonDatabase: query  SELECT addons.*, repo.addonID AS repoID FROM addons JOIN addonlinkrepo ON addons.id=addonlinkrepo.idAddon JOIN repo ON repo.id=addonlinkrepo.idRepo WHERE addonlinkrepo.idRepo IN (1,2,3) ORDER BY repo.addonID, addons.addonID returned 955 rows in 5 ms
2022-09-09 13:35:51.536 T:10720   DEBUG <general>: CAddonDatabase::GetAddons took 53 ms
2022-09-09 13:35:51.541 T:10720   DEBUG <general>: ADDONS: repository.castagnait - 3 addon(s) loaded
2022-09-09 13:35:51.541 T:10720   DEBUG <general>: ADDONS: repository.jurialmunkey - 15 addon(s) loaded
2022-09-09 13:35:51.541 T:10720   DEBUG <general>: ADDONS: repository.xbmc.org - 928 addon(s) loaded
2022-09-09 13:35:51.549 T:15992   ERROR <general>: CVideoPlayer::OpenInputStream - error opening [$ESCINFO[ListItem.Trailer]]
2022-09-09 13:35:51.549 T:15992    INFO <general>: CVideoPlayer::OnExit()
2022-09-09 13:35:51.549 T:15992   DEBUG <general>: Thread VideoPlayer 15992 terminating
2022-09-09 13:35:51.551 T:8032    DEBUG <general>: CApplicationPlayerCallback::OnPlayBackStopped: CApplication::OnPlayBackStopped

Full log here: https://pastebin.com/gPsAKfHD

Anyone have any ideas why this isn't working?
I noticed in the log with the first method that works, the OpenFile line has the actual path, so it appears that the skin timer onstart command for PlayMedia can't translate $INFO[ListItem.Trailer] but I'm not sure why, as it displays correctly with Notification...

xml:

INFO <general>: VideoPlayer::OpenFile: plugin://plugin.video.youtube/?action=play_video&videoid=7HGqcifonvs
(2022-09-09, 14:40)QuizKid Wrote: [ -> ]I've been experimenting with an auto-play function for trailers.

Currently I have it in a hidden button that's delayed for three seconds using an animation. It works with the following onfocus line:

xml:

<onfocus>PlayMedia($INFO[ListItem.Trailer],1,noresume)</onfocus>

I thought it might be more elegant to achieve this with the following skin timer so I'm not relying on a hidden button which causes warnings in the log and the effect is not reliant on the list being focused.

xml:

  <timer>
    <name>trailer_autoplay_idle_timer</name>
    <start reset="true">System.IdleTime(3) + Window.IsVisible(videos) + !Player.HasMedia + !String.IsEmpty(ListItem.Trailer)</start>
    <onstart>PlayMedia($INFO[ListItem.Trailer],1,noresume)</onstart>
    <stop>Player.HasMedia</stop>
  </timer>

But this is resulting in a playback error. I thought it might be because ListItem.Trailer couldn't be passed to the skin timer, but if I substitute the onstart line for the following, it appears to be able to display the trailer path just fine:

xml:

    <onstart>Notification(This shows the trailer path fine, $INFO[ListItem.Trailer],4000)</onstart>

The error I get looks like this. I've tried with $INFO and $ESCINFO

xml:

2022-09-09 13:35:49.479 T:10720    INFO <general>: VideoPlayer::OpenFile: $ESCINFO[ListItem.Trailer]
2022-09-09 13:35:49.495 T:9316    ERROR <general>: CApplication::OnApplicationMessage: Unhandled threadmessage sent, 1073741855
2022-09-09 13:35:51.481 T:10720   ERROR <general>: CRenderManager:TonguereInit - timed out waiting for renderer to preinit
2022-09-09 13:35:51.481 T:15992   DEBUG <general>: Thread VideoPlayer start, auto delete: false
2022-09-09 13:35:51.481 T:10720   DEBUG <general>: CApplicationPlayerCallback::OnPlayBackStarted: CApplication::OnPlayBackStarted
2022-09-09 13:35:51.482 T:15992    INFO <general>: Creating InputStream
2022-09-09 13:35:51.482 T:10720   DEBUG <general>: CAddonDatabase: SELECT repo.id FROM repo .. took 0 ms
2022-09-09 13:35:51.484 T:7868    DEBUG <general>: Loading settings for $ESCINFO[ListItem.Trailer]
2022-09-09 13:35:51.488 T:10720   DEBUG <general>: CAddonDatabase: query  SELECT addons.*, repo.addonID AS repoID FROM addons JOIN addonlinkrepo ON addons.id=addonlinkrepo.idAddon JOIN repo ON repo.id=addonlinkrepo.idRepo WHERE addonlinkrepo.idRepo IN (1,2,3) ORDER BY repo.addonID, addons.addonID returned 955 rows in 5 ms
2022-09-09 13:35:51.536 T:10720   DEBUG <general>: CAddonDatabase::GetAddons took 53 ms
2022-09-09 13:35:51.541 T:10720   DEBUG <general>: ADDONS: repository.castagnait - 3 addon(s) loaded
2022-09-09 13:35:51.541 T:10720   DEBUG <general>: ADDONS: repository.jurialmunkey - 15 addon(s) loaded
2022-09-09 13:35:51.541 T:10720   DEBUG <general>: ADDONS: repository.xbmc.org - 928 addon(s) loaded
2022-09-09 13:35:51.549 T:15992   ERROR <general>: CVideoPlayer::OpenInputStream - error opening [$ESCINFO[ListItem.Trailer]]
2022-09-09 13:35:51.549 T:15992    INFO <general>: CVideoPlayer::OnExit()
2022-09-09 13:35:51.549 T:15992   DEBUG <general>: Thread VideoPlayer 15992 terminating
2022-09-09 13:35:51.551 T:8032    DEBUG <general>: CApplicationPlayerCallback::OnPlayBackStopped: CApplication::OnPlayBackStopped

Full log here: https://pastebin.com/gPsAKfHD

Anyone have any ideas why this isn't working?


hm.just a quick look.
[mthe listitem.trailer ' ~ path' seams not translated into a valid url
CVideoPlayer::OpenInputStream - error opening [$ESCINFO[ListItem.Trailer]]

did you try also without escaping the infolabel,as for the notification you use no ESCINFO

edit: overread,sorry...


offtopic, another approach without hidden buttons is a custom skin dislog as monitor.
( based on current view and just if container(foo) has focus )

xml:

<window type="dialog" id="1194">
<visible>System.IdleTime(5) + !Player.HasMedia</visible>
<visible>[Window.IsActive(videos) +
[String.IsEqual(System.CurrentControlID,50) + Skin.HasSetting(View_50_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,56) + Skin.HasSetting(View_56_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,502) + Skin.HasSetting(View_502_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,503) + Skin.HasSetting(View_503_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,504) + Skin.HasSetting(View_504_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,510) + Skin.HasSetting(View_510_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,511) + Skin.HasSetting(View_511_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,512) + Skin.HasSetting(View_512_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,513) + Skin.HasSetting(View_513_AutoPlayTrailer)] |
[String.IsEqual(System.CurrentControlID,520) + Skin.HasSetting(View_520_AutoPlayTrailer)]] |
[[Window.IsActive(home) + String.StartsWith(System.CurrentControlID,50)] + Skin.HasSetting(autoplay_trailer_home)]</visible>
<visible>String.IsEmpty(Window(Home).Property(trailer_isplaying)) + !String.IsEmpty(Window(home).Property(listitemtrailer))</visible>

<onload condition="!String.IsEmpty(Window(home).Property(listitemtrailer))">PlayMedia($INFO[Window(home).Property(listitemtrailer)],1)</onload>
<onload>SetProperty(trailer_isplaying,true,home)</onload>
<onload condition="Window.IsActive(home) + !Skin.HasSetting(home_trailer_showwidget) + !String.IsEqual(Skin.String(HomeLayout),Spotlight)">ActivateWindow(1122)</onload>

<animation effect="fade" start="100" end="0" time="325">WindowClose</animation>

<controls />
</window>
thanks @mardukL - always appreciate your help and suggestions! Will give your alternative method a go thanks
(2022-09-09, 20:53)QuizKid Wrote: [ -> ]thanks @mardukL - always appreciate your help and suggestions! Will give your alternative method a go thanks

thanks, i did a quick test
with
xml:

timer>
  <name>trailer_autoplay_idle_timer</name>
  <start reset="true">System.IdleTime(3) + Window.IsVisible(videos) + !Player.HasMedia + !String.IsEmpty(ListItem.Trailer)</start>
<onstart>Notification(skintimer try play, $INFO[ListItem.Trailer], 1000)</onstart>
  <onstart>PlayMedia($INFO[ListItem.Trailer],1,noresume)</onstart>

<!--
<onstop>Notification(skintimer stopaction , Player.HasMedia, 1000)</onstop>
  <stop>Player.HasMedia</stop>
-->
</timer>


- it lead me to think thats something wrong with label parsing , just for (this?) specific built in command.

booth, notifiaction() and playmedia() as actions are working, booth contains parenthesis and commatas, but for playmedia() the listitem is not 'parsed' correct, where it is parsed correct for notification()...

seems buggy...

https://github.com/xbmc/xbmc/pull/21320/...1656717721


my poor understanding let me think the issue is created here ( ? as i think
the notification dialog itself can handle the info string, in another way than a gui action )
https://github.com/xbmc/xbmc/blob/master...p#L17-#L18

may @enen92 can take a look ?!

and sorry if i am misleading.
i just think with 'open mouth'
It definitely seems strange that the infolabel is handled differently for playmedia
Can you please open an issue for this in https://github.com/xbmc/xbmc? Seems like a bug to me, not related to skin timers but rather to the PlayMedia builtin
(2022-09-10, 21:29)QuizKid Wrote: [ -> ]It definitely seems strange that the infolabel is handled differently for playmedia

I've taken a look and it's not strange.The PlayMedia builtin is a player builtin (and as such, should not depend on GUI) while Notification is a GUI builtin. PlayMedia does not know anything about infolabels (GUI resource) nor the currently focused "context" on the GUI/window.

I think the proper way to do what you're intending to do is to extend the GUI.Action builtin to provide a path to play a trailer so that on your timer you can simple use  
xml:
<onstart>Action(playtrailer)</onstart>
.
Unfortunately this doesn't exist in Kodi and requires a small refactoring step to be added first(done in https://github.com/xbmc/xbmc/pull/21886).
I'll add it once the linked PR is reviewed and merged.
Thanks for looking into this @enen92

What do you mean that PlayMedia does not know anything about infolabels? Because PlayMedia($INFO[ListItem.Trailer],1,noresume) seems to work fine in other contexts, such as if it's an onfocus action of a button, which is why I thought it was strange that it sometimes can parse the infolabel and it sometimes cannot.

Apologies if I've misunderstood your point.
(2022-09-21, 11:19)QuizKid Wrote: [ -> ]Thanks for looking into this @enen92

What do you mean that PlayMedia does not know anything about infolabels? Because PlayMedia($INFO[ListItem.Trailer],1,noresume) seems to work fine in other contexts, such as if it's an onfocus action of a button, which is why I thought it was strange that it sometimes can parse the infolabel and it sometimes cannot.

Apologies if I've misunderstood your point.

I think you are right, the differences in behaviour are actually related to the way we use builtins in skin timers (simple strings) while windows register actions directly and bind the window context to the action. In this case we don't really have a window context but we can use the same type of implementation and send the builtin with the default context which will pretty much use the focused window.
I'll try to implement this, will take a few days though as I am quite stuffed with work.
Thanks!
There you go: https://github.com/xbmc/xbmc/pull/21924 (includes the refactoring from https://github.com/xbmc/xbmc/pull/21921)
This should add support for multiple onstop/onstart actions just like other parts of the gui code. Also the builtins are now context-aware (piped to the default context/control)
Feedback is appreciated

Testbuilds:
win-64: https://mirrors.kodi.tv/test-builds/wind...ti-x64.exe
android arm: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
osx: https://mirrors.kodi.tv/test-builds/osx/...x86_64.dmg
(2022-09-26, 20:55)enen92 Wrote: [ -> ]There you go: https://github.com/xbmc/xbmc/pull/21924 (includes the refactoring from https://github.com/xbmc/xbmc/pull/21921)
This should add support for multiple onstop/onstart actions just like other parts of the gui code. Also the builtins are now context-aware (piped to the default context/control)
Feedback is appreciated

Testbuilds:
win-64: https://mirrors.kodi.tv/test-builds/wind...ti-x64.exe
android arm: https://mirrors.kodi.tv/test-builds/andr...bi-v7a.apk
osx: https://mirrors.kodi.tv/test-builds/osx/...x86_64.dmg

Thanks, I'll test this at the weekend! Appreciate you looking into this
hi @enen92 thanks for this - did some testing.

1) The use case discussed above with playing trailers on a timer works very well on your test build.

2) I noticed some infolabels don't get parsed still, for example $INFO[ListItem.Art(fanart)] works, but $INFO[ListItem.Art(fanart1)] doesn't, even when it is present.

3) This new functionality gives skinners a powerful way of refreshing a window property at an interval to use infolabels from one window in another e.g.

  <timer>
    <name>test_multiart</name>
    <start>Window.IsVisible(videos)</start>
    <stop>Integer.IsGreaterOrEqual(Skin.TimerElapsedSecs(test_multiart),1)</stop>
    <onstart>SetProperty(TEST_Multiart_1,$INFO[ListItem.Art(fanart)],home)</onstart>
  </timer>

One question here - is it possible to deal with the timer in smaller than 1 second increments, i.e. in miliseconds instead?
(2022-09-29, 14:16)QuizKid Wrote: [ -> ]hi @enen92 thanks for this - did some testing.

....

See https://github.com/xbmc/xbmc/pull/21924#...1263526380
Maybe I'm doing something wrong in my tests?
Pages: 1 2