Update OSD properties after starting stream playback
#1
Hi,

I'm writing an internet radio plugin for Kodi which allows me to specify custom streams, artwork and metadata and present them nicely in Kodi's native interface.

So far I've used xbmcplugin.AddDirectoryItem() to create a list of radio streams in Kodi from sources listed in an xml file. The streams show up correctly, with the artwork and information I've specified.

Image

My next aim is to scrape the current artist and track information from the radio station's website, and update the OSD in Kodi to match. Getting the data should be pretty straightforward, but I don't know where to start with feeding it to Kodi. Is there a method for updating the OSD during playback, or will I need to take more control of the way the stream is played in order to achieve this?

My addon can be found over at GitHub, for reference.

Thanks in advance.

Cheers,
Jon
Reply
#2
I've had a crack at getting this working today, and I've made some progress at least.

I've modified my addon so that the list item URL references the addon, and the actual stream URL is set using xbmcplugin.setResolvedUrl(). This allows me to continue executing code after Kodi has started fetching the stream.

So far, so good...

The hard part seems to be getting Kodi to update any of the list item properties after the playback has started. I've tried updating the list item object with setArt() before calling setResolvedUrl() again with the same URL, but this doesn't do anything. Passing the modified list item object to xbmc.Player().play() after playback has started will update the artwork in the OSD, with the obvious disadvantage of having the playback stop for a few seconds while the stream is closed and reopened.

Still thinking...
Reply
#3
I'm doing something similar in my bluray iso utils addon. Get a look at the code at github, maybe you can use the method I use...

In short: play the stream and pause/stop it directly (should not play for a few millisec/hear anything). Populate all needed listitems and then play the stream again with all the listitems set.

Wim
Add-on : Bluray iso utils Rewrite of BR_iso_enhancements
Add-on : BR_iso_Enhancements Give theatrical & directors cut from the same bluray iso each their own library entry, use bluray iso's of tv shows as if they are already ripped.
Reply
#4
(2016-08-20, 09:02)Wimpie Wrote: I'm doing something similar in my bluray iso utils addon.

Thanks Wim, I'll have to take a look at that.

Do you think it would work if I want to change the properties more than once while playing a single file? I want to change the artwork and information every time a new song starts playing on the radio stream.
Reply
#5
I think it would work (hunch, not certain), just change the listitems while going from one song to the next (not while song is playing 5 seconds or more).
Add-on : Bluray iso utils Rewrite of BR_iso_enhancements
Add-on : BR_iso_Enhancements Give theatrical & directors cut from the same bluray iso each their own library entry, use bluray iso's of tv shows as if they are already ripped.
Reply
#6
Hi Jonathan,

I am working at the exact same thing (developing a plugin for an internet radio station with HD slideshow) by the moment and had no success updating the artwork while playing. Sad

I tested wimpies solution, but the short gap in playback isnt acceptable, especially when the update should be done 5-6 times during a song.

I am thinking about doing a vizualisation plugin, that does the job, which is feeded with picturedata of the audio plugin. I have no clue by the moment how to do this, the only thing i know is that data exchange between plugins is possible via folders.

Maybe we can do the viz plugin together? If you are comfortable with, pls contact me. Smile

Greets
Reply
#7
Updating listitems while playing a song will probably always be noticeable.

Don't do that. Update the listitems in the silent space between end previous song and start next song.

If you want to change artwork multiple times while playing the song, then you need something else. I just have no idea what...
Add-on : Bluray iso utils Rewrite of BR_iso_enhancements
Add-on : BR_iso_Enhancements Give theatrical & directors cut from the same bluray iso each their own library entry, use bluray iso's of tv shows as if they are already ripped.
Reply
#8
(2016-08-20, 14:05)selli69 Wrote: Hi Jonathan,

I am working at the exact same thing (developing a plugin for an internet radio station with HD slideshow) by the moment and had no success updating the artwork while playing. Sad

I tested wimpies solution, but the short gap in playback isnt acceptable, especially when the update should be done 5-6 times during a song.

I am thinking about doing a vizualisation plugin, that does the job, which is feeded with picturedata of the audio plugin. I have no clue by the moment how to do this, the only thing i know is that data exchange between plugins is possible via folders.

Maybe we can do the viz plugin together? If you are comfortable with, pls contact me. Smile

Greets


Data exchange can also be done via window properties, these can be used like global variables.


Sent from my iPhone
Reply
#9
(2016-08-20, 14:05)selli69 Wrote: I am working at the exact same thing and had no success updating the artwork while playing. Sad I tested wimpies solution, but the short gap in playback isnt acceptable, especially when the update should be done 5-6 times during a song.

I am thinking about doing a vizualisation plugin, that does the job, which is feeded with picturedata of the audio plugin.

Hi selli,

I guess a visualisation might work ok if you're just updating the fanart, but I'm trying to update the song title, artist and thumbnail on the OSD at the same time. I'm still looking for a solution, and if I find one, I imagine it'll work for the fanart as well.

At the moment I'm looking at using the xbmcgui module to directly modify the properties in the skin. I can get the OSD as a WindowDialog object, using xbmcgui.Window(xbmcgui.getCurrentWindowId()), and I'm hoping the properties I'm after will be accessible using the getProperty() and setProperty() methods. The thing is, I can't find the properties documented anywhere. The PyDocs says a window property is similar to an InfoLabel, but are they standardised at all, or does the skin designer choose them?

I tried passing InfoLabels such as MusicPlayer.Title to the getProperty() method, but I only get empty strings back.
Reply
#10
hi jonathan,

Thanks for your reply! I have read a lot yesterday and found out that a vizualisation isnt the right way to do this kinda stuff. Next, my idea was to make a screensaver addon, which responds to input of the audio plugin. Then i read the hint of "spouser" here in the thread and I read about windows, my new idea is to do all the stuff in the audio plugin. "xbmcgui.WindowXMLDialog" may be the key to a solution. I keep you informed.
Reply
#11
HI selli,

As far as I can tell, the difference between xbmcgui.WindowXML() and xbmcgui.Window() (or their dialog versions) is that WindowXML uses an XML file to build the window, whereas Window objects must be constructed in Python, or (hopefully) loaded from an existing window.

It's that last bit that I'm struggling with. This is what I'm trying to do:

Code:
window = xbmcgui.Window(xbmcgui.getCurrentWindowId())
control_id = get_OSD_control_ID()
control = window.getControl(control_id)
control.setLabel("New text for OSD")

Where get_OSD_control_ID() would be a function which would find the ID of the correct control, independent of skin, by looking at each control and, in this case, comparing its label with the text originally set in the list item.

However, I'm not sure that the window that's being returned actually contains the OSD. Calling window.getProperty("xmlfile"), as per the InfoLabels wiki article, returns MusicVisualisation.xml. After looking through this file, and various other files referenced in includes in my test skin (Xperience1080) I can't see the controls that I'm trying to modify. I even tried getting each control in the window with an ID between 0 and 10000 in a loop, but every one resulted in an exception.

Can anyone with the right knowledge suggest whether what I'm trying here should be possible?

Cheers,
Jon
Reply
#12
Just do it with Window(win_id).setProperty(prop_id, value) in the script and then read them in the skin with $INFO[Window(win_id).getProperty(prop_id)] which will become 'value'

I've built a helper addon for streaming radio because I didn't like the way all the data is lumped into the track info. See 289314 (thread) for more info and the github link if you want to checkout the code Smile
Learning Linux the hard way !!
Reply
#13
(2016-09-03, 12:01)black_eagle Wrote: Just do it with Window(win_id).setProperty(prop_id) in the script and then read them in the skin with $INFO[Window(win_id).getProperty(prop_id)]

This is interesting, but does it mean the skin requires modification in order to pick up the new window properties?
Reply
#14
Unfortunately, yes. However, you could create a transparent full screen dialog window which would overlay anything underneath and present your info there.

I had a quick look at that station and there doesn't appear to be any track or artist info embedded in the stream, unless I didn't let it play long enough. This might be an issue as you would have to keep hitting the website to know when a track has changed.
Learning Linux the hard way !!
Reply
#15
(2016-09-03, 12:01)black_eagle Wrote: Just do it with Window(win_id).setProperty(prop_id, value) in the script and then read them in the skin with $INFO[Window(win_id).getProperty(prop_id)] which will become 'value'

Ok, so if we imagine for a moment that there existed a standardised list of window properties, that could be attached to a particular window, and that skin designers were recommended to support these properties (if they're set) then we would have a skin-independant method of updating the OSD info, without having to modify the Kodi code base at all.

Support for individual skins could be added as required, with a simple fallback being that the default information would be displayed when not supported by the skin (as per the screenshot at the top of this thread).

Given that there are at least three addon developers trying to achieve exactly the same thing, do you think it would be worth proposing such a list of window properties?

Cheers,
Jon
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Update OSD properties after starting stream playback00
This forum uses Lukasz Tkacz MyBB addons.