Execut a callback just before showing a picture
#1
Hello !
I currently developed a Picture plugin for xbmc, it's my first one then i need a few help.
My idea is to get picture information from a mysql database.
This very simple example work properly.
But now i want to improve this by increase of one the number of access in the mysql database, for the moment i found no ways to execute a callback each time a picture is display. I try context menu, url but for the moment nothing work properly
thanks for you help !

PHP Code:
import sys
import urllib
import urlparse
import xbmcgui
import xbmcplugin

sys
.path.append('C:\\Python27\\Lib\\site-packages\\')
import MySQLdb


class Example(xbmcgui.WindowDialog):
    
def __init__(selfurl):
      
##  self.abouttitle = xbmcgui.ControlLabel(340, 135, 300, 30, str(sys.argv))
        
self.addControl(xbmcgui.ControlImage(00720480url))
        
##self.addControl(self.abouttitle)

    
def onControl(selfc):
        if 
self.h1 == c:
            print 
"hey"
        
if self.something == c:
            print 
"you press med"
        
if self.btn_quit == c:
            
self.close()


base_url sys.argv[0]


def build_url(query):
    return 
base_url '?' urllib.urlencode(query)


if 
sys.argv[1] == 'show':
    
Z=Example('empty')
    
Z.doModal()
    
del Z
else:
    
addon_handle int(sys.argv[1])
    
args urlparse.parse_qs(sys.argv[2][1:])
    
xbmcplugin.setContent(addon_handle'picture')
    
mode args.get('mode'None)

    if 
mode is None:
        
url build_url({'mode''folder''foldername''Image internet'})
        
li xbmcgui.ListItem('Image internet')
        
xbmcplugin.addDirectoryItem(handle=addon_handleurl=url,
                                    
listitem=liisFolder=True)

        
url build_url({'mode''folder''foldername''Image personel'})
        
li xbmcgui.ListItem('Image personel',
                              
iconImage='N:\\Image\\Nos Photos\\2013\\03-mars 2013\\02_03_2013_divers\\P1010250.JPG',
                              
thumbnailImage='N:\\Image\\Nos Photos\\2013\\03-mars 2013\\02_03_2013_divers\\P1010250.JPG',
                              
path='N:\\Image\\Nos Photos\\2013\\03-mars 2013\\02_03_2013_divers\\P1010250.JPG')
        
xbmcplugin.addDirectoryItem(handle=addon_handleurl=url,
                                    
listitem=liisFolder=True)

        
xbmcplugin.endOfDirectory(addon_handle)

    
elif mode[0] == 'folder':
        
db MySQLdb.connect(host="127.0.0.1",
                             
user="root",
                             
passwd="",
                             
db="my_files")
        
cur db.cursor()

        
cur.execute("SELECT PATH FROM `multimedia_file` WHERE type=2 LIMIT 10020,10040")

        for 
row in cur.fetchall():
            
commands = []
            
argsToPass 'show'
            
scriptToRun "special://home/addons/plugin.image.smardtv/default.py"
            
runner "XBMC.RunScript({0}, {1})".format(scriptToRunargsToPass)
            
name 'show'
            
commands.append((namerunner, ))
            
url row[0].replace('/''\\')
            
url2 build_url({'file'url'mode''file''foldername''Image personel'})
            
li xbmcgui.ListItem(row[0], iconImage=urlthumbnailImage=urlpath=url)
            
li.addContextMenuItems(commands)
            
xbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=liisFolder=False)

        
xbmcplugin.endOfDirectory(addon_handle)

    
elif mode[0] == 'file':
       
url args['file'][0]
       
li xbmcgui.ListItem(urliconImage=url)
       
xbmcplugin.addDirectoryItem(handle=addon_handleurl=urllistitem=li)
       
xbmcplugin.endOfDirectory(addon_handle
Reply

Logout Mark Read Team Forum Stats Members Help
Execut a callback just before showing a picture0