aeca12dc0e67a84b8ef73de04a83c650c62b0830
[enigma2.git] / lib / python / Plugins / Extensions / PicturePlayer / plugin.py
1 from enigma import ePicLoad, eTimer, getDesktop
2
3 from Screens.Screen import Screen
4 from Tools.Directories import resolveFilename, pathExists, SCOPE_MEDIA
5 from Plugins.Plugin import PluginDescriptor
6
7 from Components.Pixmap import Pixmap, MovingPixmap
8 from Components.ActionMap import ActionMap, NumberActionMap
9 from Components.Label import Label
10 from Components.Button import Button
11 from Components.FileList import FileList
12 from Components.AVSwitch import AVSwitch
13 from Components.Sources.List import List
14 from Components.ConfigList import ConfigList
15
16 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigEnableDisable, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry
17
18 def getScale():
19         return AVSwitch().getFramebufferScale()
20
21 config.pic = ConfigSubsection()
22 config.pic.framesize = ConfigInteger(default=30, limits=(5, 99))
23 config.pic.slidetime = ConfigInteger(default=10, limits=(10, 60))
24 config.pic.resize = ConfigSelection(default="1", choices = [("0", _("simple")), ("1", _("better"))])
25 config.pic.cache = ConfigEnableDisable(default=True)
26 config.pic.lastDir = ConfigText(default=resolveFilename(SCOPE_MEDIA))
27 config.pic.infoline = ConfigEnableDisable(default=True)
28 config.pic.loop = ConfigEnableDisable(default=True)
29 config.pic.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
30 config.pic.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
31
32 class picshow(Screen):
33         def __init__(self, session):
34                 self.skin = """<screen position="80,80" size="560,440" title="PicturePlayer" >
35                         <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/red.png" alphatest="on" />
36                         <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/green.png" alphatest="on" />
37                         <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/yellow.png" alphatest="on" />
38                         <ePixmap position="420,0" size="140,40" pixmap="skin_default/buttons/blue.png" alphatest="on" />
39                         <widget name="key_red" position="0,0" size="140,40" font="Regular;20" backgroundColor="#9f1313" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
40                         <widget name="key_green" position="140,0" size="140,40" font="Regular;20" backgroundColor="#1f771f" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
41                         <widget name="key_yellow" position="280,0" size="140,40" font="Regular;20" backgroundColor="#a08500" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
42                         <widget name="key_blue" position="420,0" size="140,40" font="Regular;20" backgroundColor="#18188b" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
43                         <widget name="label" position="5,55" size="350,140" font="Regular;19" />
44                         <widget name="thn" position="360,40" size="180,160" alphatest="on" />
45                         <widget name="filelist" position="5,205" zPosition="2" size="550,230" scrollbarMode="showOnDemand" />
46                         </screen>"""
47
48                 Screen.__init__(self, session)
49
50                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"],
51                 {
52                         "cancel": self.KeyExit,
53                         "red": self.KeyRed,
54                         "yellow": self.KeyYellow,
55                         "blue": self.KeyBlue,
56                         "ok": self.KeyOk
57                 }, -1)
58
59                 self["key_red"] = Button(_("Thumbnails"))
60                 self["key_green"] = Button()
61                 self["key_yellow"] = Button(_("Exif"))
62                 self["key_blue"] = Button(_("Setup"))
63                 self["label"] = Label()
64                 self["thn"] = Pixmap()
65
66                 currDir = config.pic.lastDir.value
67                 if not pathExists(currDir):
68                         currDir = "/"
69
70                 self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)")
71                 self["filelist"] = self.filelist
72                 self["filelist"].onSelectionChanged.append(self.selectionChanged)
73                 
74                 self.ThumbTimer = eTimer()
75                 self.ThumbTimer.callback.append(self.showThumb)
76
77                 self.picload = ePicLoad()
78                 self.picload.PictureData.get().append(self.showPic)
79                 
80                 self.onLayoutFinish.append(self.setConf)
81
82         def showPic(self, picInfo=""):
83                 ptr = self.picload.getData()
84                 if ptr != None:
85                         self["thn"].instance.setPixmap(ptr.__deref__())
86                         self["thn"].show()
87
88                 text = picInfo.split('\n',1)
89                 self["label"].setText(text[1])
90                 self["label"].show()
91                 
92         def showThumb(self):
93                 if not self.filelist.canDescent():
94                         if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1:
95                                 self.ThumbTimer.start(500, True)
96
97         def selectionChanged(self):
98                 if not self.filelist.canDescent():
99                         self.ThumbTimer.start(500, True)
100                 else:
101                         self["label"].hide()
102                         self["thn"].hide()
103                 
104         def KeyRed(self):
105                 #if not self.filelist.canDescent():
106                 self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
107         
108         def KeyYellow(self):
109                 if not self.filelist.canDescent():
110                         self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename()))
111         
112         def KeyBlue(self):
113                 self.session.openWithCallback(self.setConf ,Pic_Setup)
114
115         def KeyOk(self):
116                 if self.filelist.canDescent():
117                         self.filelist.descent()
118                 else:
119                         self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
120
121         def setConf(self):
122                 sc = getScale()
123                 #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB)
124                 self.picload.setPara((self["thn"].instance.size().width(), self["thn"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), "#00000000"))
125                 
126         def callbackView(self, val=0):
127                 if val > 0:
128                         self.filelist.moveToIndex(val)
129
130         def KeyExit(self):
131                 del self.picload
132
133                 if self.filelist.getCurrentDirectory() is None:
134                         config.pic.lastDir.value = "/"
135                 else:
136                         config.pic.lastDir.value = self.filelist.getCurrentDirectory()
137
138                 config.pic.save()
139                 self.close()
140
141 #------------------------------------------------------------------------------------------
142
143 class Pic_Setup(Screen):
144         def __init__(self, session):
145                 self.skin = """<screen position="120,180" size="480,210" title="Settings" >
146                                         <widget name="liste" position="5,5" size="470,200" />
147                                 </screen>"""
148                 Screen.__init__(self, session)
149
150                 self["actions"] = NumberActionMap(["SetupActions"],
151                 {
152                         "cancel": self.close,
153                         "left": self.keyLeft,
154                         "right": self.keyRight,
155                         "0": self.keyNumber,
156                         "1": self.keyNumber,
157                         "2": self.keyNumber,
158                         "3": self.keyNumber,
159                         "4": self.keyNumber,
160                         "5": self.keyNumber,
161                         "6": self.keyNumber,
162                         "7": self.keyNumber,
163                         "8": self.keyNumber,
164                         "9": self.keyNumber
165                 }, -1)
166                 
167                 list = []
168                 self["liste"] = ConfigList(list)
169                 list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime))
170                 list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize))
171                 list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache))
172                 list.append(getConfigListEntry(_("show Infoline"), config.pic.infoline))
173                 list.append(getConfigListEntry(_("Frame size in full view"), config.pic.framesize))
174                 list.append(getConfigListEntry(_("slide picture in loop"), config.pic.loop))
175                 list.append(getConfigListEntry(_("backgroundcolor"), config.pic.bgcolor))
176                 list.append(getConfigListEntry(_("textcolor"), config.pic.textcolor))
177                 
178         def keyLeft(self):
179                 self["liste"].handleKey(KEY_LEFT)
180
181         def keyRight(self):
182                 self["liste"].handleKey(KEY_RIGHT)
183                 
184         def keyNumber(self, number):
185                 self["liste"].handleKey(KEY_0 + number)
186
187 #---------------------------------------------------------------------------
188
189 class Pic_Exif(Screen):
190         def __init__(self, session, exiflist):
191                 self.skin = """<screen position="80,120" size="560,360" title="Info" >
192                                 <widget source="menu" render="Listbox" position="0,0" size="560,360" scrollbarMode="showOnDemand" selectionDisabled="1" >
193                                 <convert type="TemplatedMultiContent">
194                                         {"template": [  MultiContentEntryText(pos = (5, 5), size = (250, 30), flags = RT_HALIGN_LEFT, text = 0), MultiContentEntryText(pos = (260, 5), size = (290, 30), flags = RT_HALIGN_LEFT, text = 1)], "fonts": [gFont("Regular", 20)], "itemHeight": 30 }
195                                 </convert>
196                                 </widget>
197                         </screen>"""
198                 Screen.__init__(self, session)
199
200                 self["actions"] = ActionMap(["OkCancelActions"],
201                 {
202                         "cancel": self.close
203                 }, -1)
204                 
205                 exifdesc = [_("filename")+':', "EXIF-Version:", "Make:", "Camera:", "Date/Time:", "Width / Height:", "Flash used:", "Orientation:", "User Comments:", "Metering Mode:", "Exposure Program:", "Light Source:", "CompressedBitsPerPixel:", "ISO Speed Rating:", "X-Resolution:", "Y-Resolution:", "Resolution Unit:", "Brightness:", "Exposure Time:", "Exposure Bias:", "Distance:", "CCD-Width:", "ApertureFNumber:"]
206                 list = []
207
208                 for x in range(len(exiflist)):
209                         if x>0:
210                                 list.append((exifdesc[x], exiflist[x]))
211                         else:
212                                 name = exiflist[x].split('/')[-1]
213                                 list.append((exifdesc[x], name))
214                 self["menu"] = List(list)
215
216 #----------------------------------------------------------------------------------------
217
218 T_INDEX = 0
219 T_FRAME_POS = 1
220 T_PAGE = 2
221 T_NAME = 3
222 T_FULL = 4
223
224 class Pic_Thumb(Screen):
225         def __init__(self, session, piclist, lastindex, path):
226
227                 self.textcolor = config.pic.textcolor.value
228                 self.color = config.pic.bgcolor.value
229                 textsize = 20
230                 self.spaceX = 35
231                 self.picX = 190
232                 self.spaceY = 30
233                 self.picY = 200
234                 
235                 size_w = getDesktop(0).size().width()
236                 size_h = getDesktop(0).size().height()
237                 self.thumbsX = size_w / (self.spaceX + self.picX) # thumbnails in X
238                 self.thumbsY = size_h / (self.spaceY + self.picY) # thumbnails in Y
239                 self.thumbsC = self.thumbsX * self.thumbsY # all thumbnails
240                 
241                 self.positionlist = []
242                 skincontent = ""
243
244                 posX = -1
245                 for x in range(self.thumbsC):
246                         posY = x / self.thumbsX
247                         posX += 1
248                         if posX >= self.thumbsX:
249                                 posX = 0
250                         
251                         absX = self.spaceX + (posX*(self.spaceX + self.picX))
252                         absY = self.spaceY + (posY*(self.spaceY + self.picY))
253                         self.positionlist.append((absX, absY))
254                         skincontent += "<widget name=\"label" + str(x) + "\" position=\"" + str(absX+5) + "," + str(absY+self.picY-textsize) + "\" size=\"" + str(self.picX - 10) + ","  + str(textsize) + "\" font=\"Regular;14\" zPosition=\"2\" transparent=\"1\" noWrap=\"1\" foregroundColor=\"" + self.textcolor + "\" />"
255                 
256                         skincontent += "<widget name=\"thumb" + str(x) + "\" position=\"" + str(absX+5)+ "," + str(absY+5) + "\" size=\"" + str(self.picX -10) + "," + str(self.picY - (textsize*2)) + "\" zPosition=\"2\" transparent=\"1\" alphatest=\"on\" />"
257                 
258                 
259                 # Screen, backgroundlabel and MovingPixmap
260                 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
261                         <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\"" + self.color + "\" /><widget name=\"frame\" position=\"35,30\" size=\"190,200\" pixmap=\"pic_frame.png\" zPosition=\"1\" alphatest=\"on\" />"  + skincontent + "</screen>"
262                 
263                 Screen.__init__(self, session)
264                 
265                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
266                 {
267                         "cancel": self.Exit,
268                         "ok": self.KeyOk,
269                         "left": self.key_left,
270                         "right": self.key_right,
271                         "up": self.key_up,
272                         "down": self.key_down,
273                         "showEventInfo": self.StartExif,
274                 }, -1)
275                 
276                 self["frame"] = MovingPixmap()
277                 for x in range(self.thumbsC):
278                         self["label"+str(x)] = Label()
279                         self["thumb"+str(x)] = Pixmap()
280                         
281                 self.Thumbnaillist = []
282                 self.filelist = []
283                 self.currPage = -1
284                 self.dirlistcount = 0
285                 self.path = path
286
287                 index = 0
288                 framePos = 0
289                 Page = 0
290                 for x in piclist:
291                         if x[0][1] == False:
292                                 self.filelist.append((index, framePos, Page, x[0][0],  path + x[0][0]))
293                                 index += 1
294                                 framePos += 1
295                                 if framePos > (self.thumbsC -1):
296                                         framePos = 0
297                                         Page += 1
298                         else:
299                                 self.dirlistcount += 1
300                 
301                 self.maxentry = len(self.filelist)-1
302                 self.index = lastindex - self.dirlistcount
303                 if self.index < 0:
304                         self.index = 0
305
306                 self.picload = ePicLoad()
307                 self.picload.PictureData.get().append(self.showPic)
308                 
309                 self.onLayoutFinish.append(self.setPicloadConf)
310                 
311                 self.ThumbTimer = eTimer()
312                 self.ThumbTimer.callback.append(self.showPic)
313
314         def setPicloadConf(self):
315                 sc = getScale()
316                 self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), self.color])
317                 self.paintFrame()
318
319         def paintFrame(self):
320                 #print "index=" + str(self.index)
321                 if self.maxentry < self.index or self.index < 0:
322                         return
323
324                 pos = self.positionlist[self.filelist[self.index][T_FRAME_POS]]
325                 self["frame"].moveTo( pos[0], pos[1], 1)
326                 self["frame"].startMoving()
327                 
328                 if self.currPage != self.filelist[self.index][T_PAGE]:
329                         self.currPage = self.filelist[self.index][T_PAGE]
330                         self.newPage()
331
332         def newPage(self):
333                 self.Thumbnaillist = []
334                 #clear Labels and Thumbnail
335                 for x in range(self.thumbsC):
336                         self["label"+str(x)].setText("")
337                         self["thumb"+str(x)].hide()
338                 #paint Labels and fill Thumbnail-List
339                 for x in self.filelist:
340                         if x[T_PAGE] == self.currPage:
341                                 self["label"+str(x[T_FRAME_POS])].setText("(" + str(x[T_INDEX]+1) + ") " + x[T_NAME])
342                                 self.Thumbnaillist.append([0, x[T_FRAME_POS], x[T_FULL]])
343                                 
344                 #paint Thumbnail start
345                 self.showPic()
346
347         def showPic(self, picInfo=""):
348                 for x in range(len(self.Thumbnaillist)):
349                         if self.Thumbnaillist[x][0] == 0:
350                                 if self.picload.getThumbnail(self.Thumbnaillist[x][2]) == 1: #zu tun probier noch mal
351                                         self.ThumbTimer.start(500, True)
352                                 else:
353                                         self.Thumbnaillist[x][0] = 1
354                                 break
355                         elif self.Thumbnaillist[x][0] == 1:
356                                 self.Thumbnaillist[x][0] = 2
357                                 ptr = self.picload.getData()
358                                 if ptr != None:
359                                         self["thumb" + str(self.Thumbnaillist[x][1])].instance.setPixmap(ptr.__deref__())
360                                         self["thumb" + str(self.Thumbnaillist[x][1])].show()
361
362         def key_left(self):
363                 self.index -= 1
364                 if self.index < 0:
365                         self.index = self.maxentry
366                 self.paintFrame()
367                 
368         def key_right(self):
369                 self.index += 1
370                 if self.index > self.maxentry:
371                         self.index = 0
372                 self.paintFrame()
373                 
374         def key_up(self):
375                 self.index -= self.thumbsX
376                 if self.index < 0:
377                         self.index =self.maxentry
378                 self.paintFrame()
379                 
380         def key_down(self):
381                 self.index += self.thumbsX
382                 if self.index > self.maxentry:
383                         self.index = 0
384                 self.paintFrame()
385
386         def StartExif(self):
387                 if self.maxentry < 0:
388                         return
389                 self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.index][T_FULL]))
390
391         def KeyOk(self):
392                 if self.maxentry < 0:
393                         return
394                 self.old_index = self.index
395                 self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist, self.index, self.path)
396
397         def callbackView(self, val=0):
398                 self.index = val
399                 if self.old_index != self.index:
400                         self.paintFrame()
401         def Exit(self):
402                 del self.picload
403                 self.close(self.index + self.dirlistcount)
404
405 #---------------------------------------------------------------------------
406
407 class Pic_Full_View(Screen):
408         def __init__(self, session, filelist, index, path):
409
410                 self.textcolor = config.pic.textcolor.value
411                 self.bgcolor = config.pic.bgcolor.value
412                 space = config.pic.framesize.value
413                 size_w = getDesktop(0).size().width()
414                 size_h = getDesktop(0).size().height()
415                 
416                 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
417                         <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
418                         <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/record.png\" alphatest=\"on\" /> \
419                         <widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/ico_mp_play.png\"  alphatest=\"on\" /> \
420                         <widget name=\"file\" position=\""+ str(space+45) + "," + str(space) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
421
422                 Screen.__init__(self, session)
423                 
424                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
425                 {
426                         "cancel": self.Exit,
427                         "green": self.PlayPause,
428                         "yellow": self.PlayPause,
429                         "blue": self.nextPic,
430                         "red": self.prevPic,
431                         "left": self.prevPic,
432                         "right": self.nextPic,
433                         "showEventInfo": self.StartExif,
434                 }, -1)
435                 
436                 self["point"] = Pixmap()
437                 self["pic"] = Pixmap()
438                 self["play_icon"] = Pixmap()
439                 self["file"] = Label(_("please wait, loading picture..."))
440                 
441                 self.old_index = 0
442                 self.filelist = []
443                 self.lastindex = index
444                 self.currPic = []
445                 self.shownow = True
446                 self.dirlistcount = 0
447
448                 for x in filelist:
449                         if len(filelist[0]) == 3: #orig. filelist
450                                 if x[0][1] == False:
451                                         self.filelist.append(path + x[0][0])
452                                 else:
453                                         self.dirlistcount += 1
454                         else: # thumbnaillist
455                                 self.filelist.append(x[T_FULL])
456
457                 self.maxentry = len(self.filelist)-1
458                 self.index = index - self.dirlistcount
459                 if self.index < 0:
460                         self.index = 0
461                 
462                 self.picload = ePicLoad()
463                 self.picload.PictureData.get().append(self.finish_decode)
464                 
465                 self.slideTimer = eTimer()
466                 self.slideTimer.callback.append(self.slidePic)
467
468                 if self.maxentry >= 0:
469                         self.onLayoutFinish.append(self.setPicloadConf)
470
471         def setPicloadConf(self):
472                 sc = getScale()
473                 self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.pic.resize.value), self.bgcolor])
474                 
475                 self["play_icon"].hide()
476                 if config.pic.infoline.value == False:
477                         self["file"].hide()
478                 self.start_decode()
479
480         def ShowPicture(self):
481                 if self.shownow and len(self.currPic):
482                         self.shownow = False
483                         self["file"].setText(self.currPic[0])
484                         self.lastindex = self.currPic[1]
485                         self["pic"].instance.setPixmap(self.currPic[2].__deref__())
486                         self.currPic = []
487                         
488                         self.next()
489                         self.start_decode()
490         
491         def finish_decode(self, picInfo=""):
492                 self["point"].hide()
493                 ptr = self.picload.getData()
494                 if ptr != None:
495                         text = ""
496                         try:
497                                 text = picInfo.split('\n',1)
498                                 text = "(" + str(self.index+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1]
499                         except:
500                                 pass
501                         self.currPic = []
502                         self.currPic.append(text)
503                         self.currPic.append(self.index)
504                         self.currPic.append(ptr)
505                         self.ShowPicture()
506
507         def start_decode(self):
508                 self.picload.startDecode(self.filelist[self.index])
509                 self["point"].show()
510
511         def next(self):
512                 self.index += 1
513                 if self.index > self.maxentry:
514                         self.index = 0
515
516         def prev(self):
517                 self.index -= 1
518                 if self.index < 0:
519                         self.index = self.maxentry
520
521         def slidePic(self):
522                 print "slide to next Picture index=" + str(self.lastindex)
523                 if config.pic.loop.value==False and self.lastindex == self.maxentry:
524                         self.PlayPause()
525                 self.shownow = True
526                 self.ShowPicture()
527
528         def PlayPause(self):
529                 if self.slideTimer.isActive():
530                         self.slideTimer.stop()
531                         self["play_icon"].hide()
532                 else:
533                         self.slideTimer.start(config.pic.slidetime.value*1000)
534                         self["play_icon"].show()
535                         self.nextPic()
536
537         def prevPic(self):
538                 self.currPic = []
539                 self.index = self.lastindex
540                 self.prev()
541                 self.start_decode()
542                 self.shownow = True
543
544         def nextPic(self):
545                 self.shownow = True
546                 self.ShowPicture()
547                 
548         def StartExif(self):
549                 if self.maxentry < 0:
550                         return
551                 self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.lastindex]))
552
553         def Exit(self):
554                 del self.picload
555                 self.close(self.lastindex + self.dirlistcount)
556
557 #------------------------------------------------------------------------------------------
558
559 def main(session, **kwargs):
560         session.open(picshow)
561
562 def filescan_open(list, session, **kwargs):
563         # Recreate List as expected by PicView
564         filelist = [((file.path, False), None) for file in list]
565         session.open(Pic_Full_View, filelist, 0, file.path)
566
567 def filescan(**kwargs):
568         from Components.Scanner import Scanner, ScanPath
569
570         # Overwrite checkFile to only detect local
571         class LocalScanner(Scanner):
572                 def checkFile(self, file):
573                         return fileExists(file.path)
574
575         return \
576                 LocalScanner(mimetypes = ["image/jpeg", "image/png", "image/gif", "image/bmp"],
577                         paths_to_scan = 
578                                 [
579                                         ScanPath(path = "DCIM", with_subdirs = True),
580                                         ScanPath(path = "", with_subdirs = False),
581                                 ],
582                         name = "Pictures", 
583                         description = "View Photos...",
584                         openfnc = filescan_open,
585                 )
586
587 def Plugins(**kwargs):
588         return \
589                 [PluginDescriptor(name=_("PicturePlayer"), description=_("fileformats (BMP, PNG, JPG, GIF)"), icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
590                  PluginDescriptor(name=_("PicturePlayer"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)]