Release - Banners - (Display ad-banners over full screen video)
#76
So I updated the code to something like this:
Code:
def _get_skin_resolution(self):
    aspect_ratio = xbmc.getInfoLabel('Skin.AspectRatio')

    xml = os.path.join(xbmc.translatePath("special://skin/"), "addon.xml")
    with open(xml) as f:
        xml_file = f.read()
    res_extension_point = common.parseDOM(xml_file, 'extension', attrs={'point': 'xbmc.gui.skin'})[0]

    res_lines = res_extension_point.splitlines()

    skin_resolution = [res for res in res_lines if aspect_ratio in res][0]

    xval = int(re.findall('width="(\d{3,4})"', skin_resolution)[0])
    yval = int(re.findall('height="(\d{3,4})"', skin_resolution)[0])

    return xval, yval

Its using parsedom instead of minidom and regex pattern. It has been tested.
Follow me on Twitter: https://twitter.com/TwilightZer0
Reply
#77
Nice, I'll test it. From what I've read, Kodi tries to find closest resolution in the skin, if it is not there, it uses next lower one.

This gets the first resolution with corresponding aspect ratio?
Kodi addons: Lanik repo
Reply
#78
(2018-01-09, 20:10)DaLanik Wrote: Nice, I'll test it. From what I've read, Kodi tries to find closest resolution in the skin, if it is not there, it uses next lower one.

This gets the first resolution with corresponding aspect ratio?
Yes and no. Yes because it gets current used aspect ratio and finds matching resolution from a skin. No because the code will probably need a fallback in case there is no match, a rare occasion but can happen at some setups, especially on raspberry pis with CRT monitors.
Follow me on Twitter: https://twitter.com/TwilightZer0
Reply
#79
Hmm, thinking of it, aspect_ratio = xbmc.getInfoLabel('Skin.AspectRatio') gets SKIN a/r... so it must be something from the skin's addon.xml file? Then there MUST be a match in listed resolutions...
Kodi addons: Lanik repo
Reply
#80
OK, came up with something like this, just in case Smile

Code:
    def _get_skin_resolution(self):
        aspect_ratio = xbmc.getInfoLabel('Skin.AspectRatio')

        xmlFile = os.path.join(xbmc.translatePath("special://skin/"), "addon.xml")

        with open(xmlFile) as f:
            xml_file = f.read()

        res_extension_point = common.parseDOM(xml_file, 'extension', attrs={'point': 'xbmc.gui.skin'})[0]
        res_lines = res_extension_point.splitlines()

        try:
            skin_resolution = [res for res in res_lines if aspect_ratio in res][0]
        except IndexError:
            xmldoc = minidom.parse(xmlFile)
            res = xmldoc.getElementsByTagName("res")
            xval = int(res[0].attributes["width"].value)
            yval = int(res[0].attributes["height"].value)
        else:
            xval = int(re.findall('width="(\d{3,4})"', skin_resolution)[0])
            yval = int(re.findall('height="(\d{3,4})"', skin_resolution)[0])

        return xval, yval
Kodi addons: Lanik repo
Reply
#81
(2018-01-09, 21:18)DaLanik Wrote: Hmm, thinking of it, aspect_ratio = xbmc.getInfoLabel('Skin.AspectRatio') gets SKIN a/r... so it must be something from the skin's addon.xml file? Then there MUST be a match in listed resolutions...
It gets current resolution used, not the skin's. Kodi uses an aspect ratio that suits for current surface and if there is no matching one, the closest one is used. Estuary has most common aspect ratios, while confluence has just one.

IMHO this is a lot simpler, without the additional overhead of handling an exception, adding just an else into the list comprehension:
Code:
def _get_skin_resolution(self):

    aspect_ratio = xbmc.getInfoLabel('Skin.AspectRatio')

    xml = os.path.join(xbmc.translatePath("special://skin/"), "addon.xml")
    with open(xml) as f:
        xml_file = f.read()
    res_extension_point = common.parseDOM(xml_file, 'extension', attrs={'point': 'xbmc.gui.skin'})[0]

    res_lines = res_extension_point.splitlines()

    skin_resolution = [res if aspect_ratio in res else res_lines for res in res_lines][0]

    xval = int(re.findall('width="(\d{3,4})"', skin_resolution)[0])
    yval = int(re.findall('height="(\d{3,4})"', skin_resolution)[0])

    return xval, yval
Follow me on Twitter: https://twitter.com/TwilightZer0
Reply
#82
I took the liberty and forked your addon because I desperately needed a few changes asap.

https://github.com/Twilight0/service.banners.mod

It also looks like PIL doesn't like indexed pngs.
Follow me on Twitter: https://twitter.com/TwilightZer0
Reply
#83
(2018-01-09, 22:10)twilight0 Wrote:
Code:
skin_resolution = [res if aspect_ratio in res else res_lines for res in res_lines][0]
 This crashes...
Kodi addons: Lanik repo
Reply
#84
(2018-01-10, 11:42)DaLanik Wrote:
(2018-01-09, 22:10)twilight0 Wrote:
Code:
skin_resolution = [res if aspect_ratio in res else res_lines for res in res_lines][0]
 This crashes... 
Provide your log so we can sort it out. Also, which skin your using, kodi version, your aspect radio and finally screen resolution.
Follow me on Twitter: https://twitter.com/TwilightZer0
Reply
#85
Hi DaLanik, i've been looking around your code trying to get my head around it to make a few changes for a local project i'm working on for a non-profit.
Im trying to make the banner display cover the entire width of the screen, and be a bit taller, touching the bottom of the display.
I've found where the overlay class is created but can't work out how the height and width is written - especially when called via JSON rather than a rotation.
Would you be able to point me at some line numbers?
Reply
#86
Ugh, been awhile since I delved into code there Smile The function is scaleimage(self, width, height, yoffset)
Kodi addons: Lanik repo
Reply
#87
Thanks man, it's a bit over my head atm (im still new to python) but hopefully will make some progress with a friend tomorrow
Reply
#88
I think it should be enough to set width to viewport_w (that's the width of the screen), but then you have to calculate height to be proportional to width...
Kodi addons: Lanik repo
Reply
#89
Much appreciated, have managed to get an MVP going by increasing image size and setting image bottom to bottom of the viewport.
Will throw over a donation at the end of the month
Reply
 
Thread Rating:
  • 1 Vote(s) - 5 Average



Logout Mark Read Team Forum Stats Members Help
Banners - (Display ad-banners over full screen video)51