[InternetRadio] fixed google cover display
[enigma2-plugins.git] / internetradio / src / InternetRadioScreen.py
1 #
2 # InternetRadio E2
3 #
4 # Coded by Dr.Best (c) 2012
5 # Support: www.dreambox-tools.info
6 # E-Mail: dr.best@dreambox-tools.info
7 #
8 # This plugin is open source but it is NOT free software.
9 #
10 # This plugin may only be distributed to and executed on hardware which
11 # is licensed by Dream Multimedia GmbH.
12 # In other words:
13 # It's NOT allowed to distribute any parts of this plugin or its source code in ANY way
14 # to hardware which is NOT licensed by Dream Multimedia GmbH.
15 # It's NOT allowed to execute this plugin and its source code or even parts of it in ANY way
16 # on hardware which is NOT licensed by Dream Multimedia GmbH.
17 #
18 # If you want to use or modify the code or parts of it,
19 # you have to keep MY license and inform me about the modifications by mail.
20 #
21
22 from Screens.Screen import Screen
23 from Components.ActionMap import ActionMap
24 from Components.Label import Label
25 from Components.Pixmap import Pixmap
26 from Components.config import config
27 from enigma import getDesktop, eTimer, eConsoleAppContainer, eActionMap, eMusicPlayer
28 from Screens.MessageBox import MessageBox
29 from Components.Sources.StaticText import StaticText
30 from urllib import quote
31 from twisted.web.client import downloadPage
32 from Screens.ChoiceBox import ChoiceBox
33 from Screens.VirtualKeyBoard import VirtualKeyBoard
34 from Components.Input import Input
35 from Screens.InputBox import InputBox
36 from timer import TimerEntry
37 from Components.ProgressBar import ProgressBar
38 from Components.SystemInfo import SystemInfo
39 import os
40 import string
41 import xml.etree.cElementTree
42 from Tools.BoundFunction import boundFunction
43 from simplejson import loads as simplejson_loads
44
45 from InternetRadioFavoriteConfig import InternetRadioFavoriteConfig
46 from InternetRadioInformationScreen import InternetRadioInformationScreen
47 from InternetRadioOledDisplay import InternetRadioOledDisplay
48 from InternetRadioSetup import InternetRadioSetup
49 from InternetRadioCover import InternetRadioCover
50 from InternetRadioList import InternetRadioList
51 from InternetRadioWebFunctions import sendUrlCommand
52 from InternetRadioClasses import InternetRadioFilter, InternetRadioStation
53 from InternetRadioVisualization import InternetRadioVisualization
54 from InternetRadioPiPTVPlayer import InternetRadioPiPTVPlayer
55
56 # for localized messages
57 from . import _
58
59
60 containerStreamripper = None
61
62 class InternetRadioScreen(Screen, InternetRadioVisualization, InternetRadioPiPTVPlayer):
63
64         FILTERLIST = 0
65         STATIONLIST = 1
66         FAVORITELIST = 2
67         SEARCHLIST = 3
68         STREAMRIPPER_BIN = '/usr/bin/streamripper'
69         
70         sz_w = getDesktop(0).size().width()
71         if sz_w == 1280:
72                 # helper for skinning ;)
73 #               count = 16
74 #               skincontent = ""
75 #               skincontent2 = ""
76 #               posx = 830
77 #               x = 0
78 #               while True:
79 #                       skincontent += "<widget name=\"progress_%d\" zPosition=\"3\" position=\"%d,470\" size=\"25,200\" transparent=\"1\" orientation=\"orBottomToTop\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png\" />\n" % (x,posx)
80 #                       skincontent2 += "<widget name=\"top_%d\" position=\"%d,465\" zPosition=\"6\" size=\"25,5\" transparent=\"1\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png\" />\n" % (x,posx)
81
82 #                       posx += 25
83 #                       x += 1
84 #                       if x == count:
85 #                               break
86
87                 skin = """
88                         <screen name="InternetRadioScreen" position="0,0" size="1280,720" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
89                                 <widget transparent="1" name="video" position="0,0" size="1280,720" zPosition="1"/>
90                                 <ePixmap position="50,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
91                                 <ePixmap position="200,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
92                                 <ePixmap position="350,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
93                                 <ePixmap position="500,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
94                                 <widget render="Label" source="key_red" position="50,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
95                                 <widget render="Label" source="key_green" position="200,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
96                                 <widget render="Label" source="key_yellow" position="350,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
97                                 <widget render="Label" source="key_blue" position="500,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
98                                 <widget name="headertext" position="50,77" zPosition="1" size="1180,23" font="Regular;20" transparent="1"  foregroundColor="#fcc000" backgroundColor="#00000000"/>
99                                 <widget name="list" position="50,110" zPosition="2" size="1180,340" scrollbarMode="showOnDemand" transparent="0"  backgroundColor="#00000000"/>
100                                 <widget name="statustext" position="50,470" zPosition="1" size="1240,18" font="Regular;16" transparent="0"  backgroundColor="#00000000"/>
101                                 <widget name="cover" zPosition="2" position="50,490" size="51,55" />
102                                 <eLabel name="stationCap" position="50,550" size="85,20" text="Station:" font="Regular;18" transparent="1"  zPosition="1" backgroundColor="#00000000"/>
103                                 <widget name="station" position="125,550" zPosition="1" size="825,20" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
104                                 <eLabel name="titleCap" position="50,575" size="65,20" text="Title:" font="Regular;18" transparent="1"  zPosition="1" backgroundColor="#00000000"/>
105                                 <widget name="title" position="105,575" zPosition="1" size="720,40" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
106                                 <widget name="console" position="50,620" zPosition="1" size="900,50" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
107                                 <widget name="progress_0" zPosition="3" position="830,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
108                                 <widget name="progress_1" zPosition="3" position="855,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
109                                 <widget name="progress_2" zPosition="3" position="880,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
110                                 <widget name="progress_3" zPosition="3" position="905,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
111                                 <widget name="progress_4" zPosition="3" position="930,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
112                                 <widget name="progress_5" zPosition="3" position="955,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
113                                 <widget name="progress_6" zPosition="3" position="980,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
114                                 <widget name="progress_7" zPosition="3" position="1005,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
115                                 <widget name="progress_8" zPosition="3" position="1030,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
116                                 <widget name="progress_9" zPosition="3" position="1055,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
117                                 <widget name="progress_10" zPosition="3" position="1080,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
118                                 <widget name="progress_11" zPosition="3" position="1105,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
119                                 <widget name="progress_12" zPosition="3" position="1130,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
120                                 <widget name="progress_13" zPosition="3" position="1155,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
121                                 <widget name="progress_14" zPosition="3" position="1180,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
122                                 <widget name="progress_15" zPosition="3" position="1205,470" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
123                                 <widget name="top_0" position="830,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
124                                 <widget name="top_1" position="855,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
125                                 <widget name="top_2" position="880,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
126                                 <widget name="top_3" position="905,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
127                                 <widget name="top_4" position="930,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
128                                 <widget name="top_5" position="955,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
129                                 <widget name="top_6" position="980,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
130                                 <widget name="top_7" position="1005,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
131                                 <widget name="top_8" position="1030,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
132                                 <widget name="top_9" position="1055,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
133                                 <widget name="top_10" position="1080,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
134                                 <widget name="top_11" position="1105,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
135                                 <widget name="top_12" position="1130,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
136                                 <widget name="top_13" position="1155,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
137                                 <widget name="top_14" position="1180,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
138                                 <widget name="top_15" position="1205,465" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
139                         </screen>"""
140
141         elif sz_w == 1024:
142                 skin = """
143                         <screen name="InternetRadioScreen" position="0,0" size="1024,576" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
144                                 <widget transparent="1" name="video" position="0,0" size="1024,576" zPosition="1"/>
145                                 <ePixmap position="50,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
146                                 <ePixmap position="200,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
147                                 <ePixmap position="350,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
148                                 <ePixmap position="500,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
149                                 <widget render="Label" source="key_red" position="50,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
150                                 <widget render="Label" source="key_green" position="200,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
151                                 <widget render="Label" source="key_yellow" position="350,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
152                                 <widget render="Label" source="key_blue" position="500,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
153                                 <widget name="headertext" position="50,77" zPosition="1" size="900,23" font="Regular;20" transparent="1"  foregroundColor="#fcc000" backgroundColor="#00000000"/>
154                                 <widget name="list" position="50,120" zPosition="2" size="940,249" scrollbarMode="showOnDemand" transparent="0"  backgroundColor="#00000000"/>
155                                 <widget name="statustext" position="50,370" zPosition="1" size="940,20" font="Regular;16" transparent="0"  backgroundColor="#00000000"/>
156                                 <widget name="title" position="50,400" zPosition="1" size="825,40" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
157                                 <widget name="station" position="50,445" zPosition="1" size="825,40" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
158                                 <widget name="console" position="50,490" zPosition="1" size="850,50" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
159                                 <widget name="progress_0" zPosition="3" position="810,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
160                                 <widget name="progress_1" zPosition="3" position="820,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
161                                 <widget name="progress_2" zPosition="3" position="830,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
162                                 <widget name="progress_3" zPosition="3" position="840,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
163                                 <widget name="progress_4" zPosition="3" position="850,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
164                                 <widget name="progress_5" zPosition="3" position="860,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
165                                 <widget name="progress_6" zPosition="3" position="870,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
166                                 <widget name="progress_7" zPosition="3" position="880,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
167                                 <widget name="progress_8" zPosition="3" position="890,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
168                                 <widget name="progress_9" zPosition="3" position="900,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
169                                 <widget name="progress_10" zPosition="3" position="910,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
170                                 <widget name="progress_11" zPosition="3" position="920,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
171                                 <widget name="progress_12" zPosition="3" position="930,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
172                                 <widget name="progress_13" zPosition="3" position="940,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
173                                 <widget name="progress_14" zPosition="3" position="950,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
174                                 <widget name="progress_15" zPosition="3" position="960,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
175                                 <widget name="top_0" position="810,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
176                                 <widget name="top_1" position="820,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
177                                 <widget name="top_2" position="830,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
178                                 <widget name="top_3" position="840,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
179                                 <widget name="top_4" position="850,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
180                                 <widget name="top_5" position="860,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
181                                 <widget name="top_6" position="870,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
182                                 <widget name="top_7" position="880,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
183                                 <widget name="top_8" position="890,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
184                                 <widget name="top_9" position="900,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
185                                 <widget name="top_10" position="910,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
186                                 <widget name="top_11" position="920,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
187                                 <widget name="top_12" position="930,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
188                                 <widget name="top_13" position="940,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
189                                 <widget name="top_14" position="950,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
190                                 <widget name="top_15" position="960,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
191                         </screen>"""
192         else:
193                 skin = """
194                         <screen name="InternetRadioScreen" position="0,0" size="720,576" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
195                                 <widget transparent="1" name="video" position="0,0" size="720,576" zPosition="1"/>
196                                 <ePixmap position="50,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
197                                 <ePixmap position="210,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
198                                 <ePixmap position="370,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
199                                 <ePixmap position="530,30" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
200                                 <widget render="Label" source="key_red" position="50,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
201                                 <widget render="Label" source="key_green" position="210,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
202                                 <widget render="Label" source="key_yellow" position="370,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
203                                 <widget render="Label" source="key_blue" position="530,30" size="140,40" zPosition="5" valign="center" halign="center" backgroundColor="red" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
204                                 <widget name="headertext" position="50,77" zPosition="1" size="620,23" font="Regular;20" transparent="1"  foregroundColor="#fcc000" backgroundColor="#00000000"/>
205                                 <widget name="list" position="50,120" zPosition="2" size="620,249" scrollbarMode="showOnDemand" transparent="0"  backgroundColor="#00000000"/>
206                                 <widget name="statustext" position="50,370" zPosition="1" size="620,20" font="Regular;16" transparent="0"  backgroundColor="#00000000"/>
207                                 <widget name="title" position="50,400" zPosition="1" size="525,40" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
208                                 <widget name="station" position="50,445" zPosition="1" size="525,40" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
209                                 <widget name="console" position="50,490" zPosition="1" size="450,50" font="Regular;18" transparent="1"  backgroundColor="#00000000"/>
210                                 <widget name="progress_0" zPosition="3" position="510,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
211                                 <widget name="progress_1" zPosition="3" position="520,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
212                                 <widget name="progress_2" zPosition="3" position="530,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
213                                 <widget name="progress_3" zPosition="3" position="540,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
214                                 <widget name="progress_4" zPosition="3" position="550,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
215                                 <widget name="progress_5" zPosition="3" position="560,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
216                                 <widget name="progress_6" zPosition="3" position="570,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
217                                 <widget name="progress_7" zPosition="3" position="580,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
218                                 <widget name="progress_8" zPosition="3" position="590,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
219                                 <widget name="progress_9" zPosition="3" position="600,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
220                                 <widget name="progress_10" zPosition="3" position="610,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
221                                 <widget name="progress_11" zPosition="3" position="620,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
222                                 <widget name="progress_12" zPosition="3" position="630,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
223                                 <widget name="progress_13" zPosition="3" position="640,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
224                                 <widget name="progress_14" zPosition="3" position="650,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
225                                 <widget name="progress_15" zPosition="3" position="660,440" size="10,100" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small-fs8.png" />
226                                 <widget name="top_0" position="510,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
227                                 <widget name="top_1" position="520,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
228                                 <widget name="top_2" position="530,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
229                                 <widget name="top_3" position="540,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
230                                 <widget name="top_4" position="550,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
231                                 <widget name="top_5" position="560,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
232                                 <widget name="top_6" position="570,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
233                                 <widget name="top_7" position="580,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
234                                 <widget name="top_8" position="590,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
235                                 <widget name="top_9" position="600,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
236                                 <widget name="top_10" position="610,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
237                                 <widget name="top_11" position="620,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
238                                 <widget name="top_12" position="630,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
239                                 <widget name="top_13" position="640,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
240                                 <widget name="top_14" position="650,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
241                                 <widget name="top_15" position="660,440" zPosition="6" size="10,3" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/green_small_top-fs8.png" />
242                         </screen>"""
243         
244         def __init__(self, session, url = None, radioStation = None):
245                 self.session = session
246                 Screen.__init__(self, session)
247                 InternetRadioVisualization.__init__(self)
248                 self.currentService = self.session.nav.getCurrentlyPlayingServiceReference()
249                 InternetRadioPiPTVPlayer.__init__(self,session, self.currentService, self.setPiPPlayerEnabled)
250                 self.session.nav.stopService()
251                 self["cover"] = InternetRadioCover(self.coverLoaded)
252                 self["key_red"] = StaticText(_("Record"))
253                 self["key_green"] = StaticText(config.plugins.internetradio.filter.value)
254                 self["key_yellow"] = StaticText(_("Stations"))
255                 self["key_blue"] = StaticText(_("Favorites"))
256
257                 self.mode = self.FAVORITELIST
258                 self["list"] = InternetRadioList()
259                 self["statustext"] = Label()
260                 self["actions"] = ActionMap(["WizardActions", "ColorActions", "EPGSelectActions"],
261                 {
262                         "ok": self.ok_pressed,
263                         "back": self.close,
264                         "input_date_time": self.menu_pressed,
265                         "red": self.red_pressed,
266                         "green": self.green_pressed,
267                         "yellow": self.yellow_pressed,
268                         "blue": self.blue_pressed,
269                         "info" : self.info_pressed,
270                         
271                 }, -1)
272
273                 self.stationList = []
274                 self.stationListIndex = 0
275
276                 self.filterList = []
277                 self.filterListIndex = 0
278
279                 self.favoriteList = []
280                 self.favoriteListIndex = 0
281
282                 self.stationListFiltered = []
283
284                 
285                 self.favoriteConfig = InternetRadioFavoriteConfig()
286                 
287                 
288
289                 self["title"] = Label()
290                 self["station"] = Label()
291                 self["headertext"] = Label()
292                 self["console"] = Label()
293
294
295                 self.stationHeaderText = ""
296                 self.searchInternetRadioString = ""
297
298
299                 self.currentPlayingStation = None 
300
301                 self.onClose.append(self.__onClose)
302                 self.onLayoutFinish.append(self.startRun)
303                 self.onExecBegin.append(self.onBeginExec)
304
305                 self.musicPlayer = eMusicPlayer(self.BANDS)
306                 #self.musicPlayer.timeout.connect(self.musicPlayerCallBack)
307                 self.musicPlayer_conn = self.musicPlayer.callback.connect(self.musicPlayerCallBack)
308
309                 self.try_url = ""
310                 self.url_tried = 0
311                 
312                 self.stationListURL = "http://www.radio-browser.info/xml.php"
313                 self.filterSwitch = { _("Countries"):_("Genres"), _("Genres"):_("Countries")}
314
315
316                 self.visuCleanerTimer = eTimer()
317                 self.visuCleanerTimer_conn = self.visuCleanerTimer.timeout.connect(self.visuCleanerTimerCallback)
318
319                 self.clearStatusTextTimer = eTimer()
320                 self.clearStatusTextTimer_conn = self.clearStatusTextTimer.timeout.connect(self.clearStatusTextTimerCallback)
321
322                 self.fullScreenAutoActivationTimer = eTimer()
323                 self.fullScreenAutoActivationTimer_conn = self.fullScreenAutoActivationTimer.timeout.connect(self.fullScreenAutoActivationTimerCallback)
324                 
325                 self.visible = True
326                 
327                 self.fullScreen = session.instantiateDialog(InternetRadioFullScreen, zPosition=1000)
328                 self.autoActivationKeyPressedActionSlot = eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.autoActivationKeyPressed)
329
330                 global containerStreamripper
331                 global dataAvail_conn
332                 global appClosed_conn
333                 if containerStreamripper is None:
334                         containerStreamripper = eConsoleAppContainer()
335
336                 dataAvail_conn = containerStreamripper.dataAvail.connect(self.streamripperDataAvail)
337                 appClosed_conn = containerStreamripper.appClosed.connect(self.streamripperClosed)
338
339                 if url is not None and radioStation is not None:
340                         self.playRadioStation(url, radioStation)
341                 elif containerStreamripper.running():
342                         self["key_red"].setText(_("Stop record"))
343                         # just to hear to recording music when starting the plugin...
344                         self.currentPlayingStation = InternetRadioStation(name = _("Recording stream station"))
345                         self.playServiceStream("http://localhost:9191")
346                 self.session.nav.SleepTimer.on_state_change.append(self.sleepTimerEntryOnStateChange)
347         
348         def sleepTimerEntryOnStateChange(self, timer):
349                 if timer.state == TimerEntry.StateEnded:
350                         self.closePlayer()
351
352         def onBeginExec(self):
353                 if config.plugins.internetradio.visualization.value in ("2", "3"):
354                         self.summaries.setLabelVisibility(True)                 
355
356         def visualizationConfigOnChange(self, configElement = None):
357                 if config.plugins.internetradio.visualization.value in ("0", "1"):
358                         self.musicPlayer.setBands(self.BANDS)
359                         self.summaries.setLabelVisibility(False)
360                 elif config.plugins.internetradio.visualization.value == "2":
361                         self.musicPlayer.setBands(self.BANDS)
362                         self.summaries.setLabelVisibility(True)
363                 elif config.plugins.internetradio.visualization.value == "3":
364                         if config.plugins.internetradio.fullscreenlayout.value != "0":
365                                 self.musicPlayer.setBands(0)
366                         self.summaries.setLabelVisibility(True)
367                 if config.plugins.internetradio.visualization.value in ("1", "3"):
368                         self.hideControls()
369
370         def fullscreenlayoutConfigOnChange(self, configElement = None):
371                 if config.plugins.internetradio.visualization.value == "3" and config.plugins.internetradio.fullscreenlayout.value != "0":
372                         self.musicPlayer.setBands(0)
373                 else:
374                         self.musicPlayer.setBands(self.BANDS)
375
376         def fullscreenautoactivationConfigOnChange(self, configElement = None):
377                 if config.plugins.internetradio.fullscreenautoactivation.value == "-1":
378                         self.fullScreenAutoActivationTimer.stop()
379                 else:
380                         self.fullScreenAutoActivationTimer.start(int(config.plugins.internetradio.fullscreenautoactivation.value)*1000)
381
382         def autoActivationKeyPressed(self, key = None, flag = None):
383                 self.fullScreenAutoActivationTimer.stop()
384                 if  self.shown == True and self.visible == True and config.plugins.internetradio.fullscreenautoactivation.value != "-1":
385                         self.fullScreenAutoActivationTimer.start(int(config.plugins.internetradio.fullscreenautoactivation.value)*1000)
386                 return 0
387
388         def fullScreenAutoActivationTimerCallback(self):
389                 self.fullScreenAutoActivationTimer.stop()
390                 self.showFullScreen()
391
392         def startRun(self):
393                 self.setPiPTVPlayerEnabled(False)
394                 config.plugins.internetradio.visualization.addNotifier(self.visualizationConfigOnChange, initial_call = True)
395                 config.plugins.internetradio.fullscreenautoactivation.addNotifier(self.fullscreenautoactivationConfigOnChange, initial_call = True)
396                 config.plugins.internetradio.fullscreenlayout.addNotifier(self.fullscreenlayoutConfigOnChange, initial_call = False)
397                 self.setPBtoNull()
398                 self.setProperties()
399                 self.getFavoriteList()
400                 self.visuCleanerTimer.start(1000)
401                 if self.currentPlayingStation is None and config.plugins.internetradio.startupname.value != "" and config.plugins.internetradio.startuptext.value != "":
402                         self["list"].moveToFavorite(config.plugins.internetradio.startupname.value, config.plugins.internetradio.startuptext.value)
403                         url = config.plugins.internetradio.startuptext.value
404                         self.currentPlayingStation = InternetRadioStation(name = config.plugins.internetradio.startupname.value, url = url)
405                         self.url_tried = 0
406                         self.try_url = url
407                         if url.endswith(".pls") or url.endswith(".m3u") or url.endswith(".asx"):
408                                 self.setStatusText(_("Getting streaming data from %s") % url)
409                                 sendUrlCommand(url, None,10).addCallback(self.callbackPlayList).addErrback(self.callbackStationListError)
410                         else:
411                                 self.playServiceStream(url)
412
413         def info_pressed(self):
414                 meta = self.musicPlayer.getMetaInfos()
415                 self.session.open(InternetRadioInformationScreen, meta)
416
417         def showFullScreen(self):
418                 if self.fullScreen.isVisible() == False:
419                         self.visible = False
420                         self.fullScreen.setVisibility(True)
421                         if config.plugins.internetradio.fullscreenlayout.value in ("0","1"):
422                                 self.fullScreen.setStation(self["station"].getText())
423                                 self.fullScreen.setText(self["title"].getText())
424                                 if config.plugins.internetradio.googlecover.value:
425                                         if self["cover"].getPicloaded():
426                                                 self.fullScreen.updateCover()
427                                         else:
428                                                 self.fullScreen.setVisibilityCover(False)
429                         else:
430                                 self.fullScreen.setStation("")
431                                 self.fullScreen.setText("")
432                                 self.fullScreen.setVisibilityCover(False)
433                         self.fullScreenKeyPressedActionSlot = eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.fullScreenKeyPressed)
434                         
435         def fullScreenKeyPressed(self, key = None, flag = None):
436                 if self.fullScreen.isVisible():
437                         self.visible = True
438                         self.fullScreen.setVisibility(False)
439                         self.fullScreenKeyPressedActionSlot = None
440                         self.autoActivationKeyPressed()
441                         return 1
442                 else:
443                         return 0
444
445         def visuCleanerTimerCallback(self):
446                 self.visuCleanerTimer.stop()
447                 if self.needCleanup() == True:
448                         code = 0
449                         v = (-80,) * self.BANDS
450                         self.musicPlayerCallBack(code,v,True)
451
452         def musicPlayerCallBack(self, code = None, v = None, cleanup = False):
453                 if self.visuCleanerTimer.isActive():
454                         self.visuCleanerTimer.stop()
455                 if code == 0 and len(v) > 0:
456                         if config.plugins.internetradio.visualization.value in ("0","1"):
457                                 self.summaries.setValues(v)
458                         if self.fullScreen.isVisible() and config.plugins.internetradio.fullscreenlayout.value == "0":
459                                 self.fullScreen.setValues(v)
460                         if self.visible and config.plugins.internetradio.visualization.value in ("0","2"):
461                                 self.setValues(v)
462                 elif code == 1:
463                         cleanup = True
464                         if (len(v[0]) !=0):
465                                 if len(v[1]) != 0:
466                                         sTitle = "%s - %s" % (v[0],v[1])
467                                 else:
468                                         sTitle = v[0]
469                                 if config.plugins.internetradio.googlecover.value:
470                                         url = "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=%s" % quote(sTitle)
471                                         sendUrlCommand(url, None,10).addCallback(self.GoogleImageCallback).addErrback(self.Error)
472                         else:
473                                 sTitle = "n/a"
474                                 self.hideCover()
475                         self["title"].setText(sTitle)
476                         self.summaries.setText(sTitle)
477                         if self.fullScreen.isVisible() and config.plugins.internetradio.fullscreenlayout.value in ("0", "1"):
478                                 self.fullScreen.setText(sTitle)
479                 elif code == -2:
480                         cleanup = True
481                         if v[0] in (5, 6): # text/uri-list - this can't be decoded.
482                                 self.url_tried += 1
483                                 if self.url_tried == 1:
484                                         self.setStatusText(_("Getting streaming data from\n%s") % self.try_url)
485                                         sendUrlCommand(self.try_url, None,10).addCallback(self.callbackPlayList).addErrback(self.callbackStationListError)
486                                 else:
487                                         self.setStatusText("Error: %s" % v[1], 15000)
488                                         self.currentPlayingStation = None
489                         else:
490                                 self.setStatusText("Error: %s" % v[1], 15000)
491                                 self.currentPlayingStation = None
492                 elif code == -5:
493                         cleanup = True
494                         if v[0] == 0:
495                                 text = "trying to start %s..." % v[1]
496                         elif v[0] == 1:
497                                 text = "playing %s..." % v[1]
498                         elif v[0] == 2:
499                                 text = "%s stopped playing..." % v[1]
500                         else:
501                                 text = ""
502                         self.setStatusText(text)
503                 else:
504                         if v and len(v) > 2:
505                                 self.setStatusText("Error: %s" % v[1], 15000)
506                         cleanup = True
507
508                 if cleanup == True:
509                         self.visuCleanerTimer.start(100)
510
511         def streamripperClosed(self, retval):
512                 if retval == 0:
513                         self["console"].setText("")
514                 self["key_red"].setText(_("Record"))
515
516         def streamripperDataAvail(self, data):
517                 sData = data.replace('\n','')
518                 self["console"].setText(sData)
519
520         def InputBoxStartRecordingCallback(self, returnValue = None):
521                 if returnValue:
522                         recordingLength =  int(returnValue) * 60
523                         if not os.path.exists(config.plugins.internetradio.dirname.value):
524                                 os.mkdir(config.plugins.internetradio.dirname.value)
525                         args = []
526                         args.append(self.currentPlayingStation.url)
527                         args.append('-d')
528                         args.append(config.plugins.internetradio.dirname.value)
529                         args.append('-r')
530                         args.append('9191')
531                         if recordingLength != 0:
532                                 args.append('-l')
533                                 args.append("%d" % int(recordingLength))
534                         if config.plugins.internetradio.riptosinglefile.value:
535                                 args.append('-a')
536                                 args.append('-A')
537                         if not config.plugins.internetradio.createdirforeachstream.value:
538                                 args.append('-s')
539                         if config.plugins.internetradio.addsequenceoutputfile.value:
540                                 args.append('-q')
541                         cmd = [self.STREAMRIPPER_BIN, self.STREAMRIPPER_BIN] + args
542                         containerStreamripper.execute(*cmd)
543                         self["key_red"].setText(_("Stop record"))
544                         
545         def deleteRecordingConfirmed(self,val):
546                 if val:
547                         containerStreamripper.sendCtrlC()
548
549         def red_pressed(self):
550                 if containerStreamripper.running():
551                         self.session.openWithCallback(self.deleteRecordingConfirmed, MessageBox, _("Do you really want to stop the recording?"))
552                 else:
553                         if self.currentPlayingStation and len(self.currentPlayingStation.url) != 0:
554                                 self.session.openWithCallback(self.InputBoxStartRecordingCallback, InputBox, windowTitle = _("Recording length"),  title=_("Enter in minutes (0 means unlimited)"), text="0", type=Input.NUMBER)
555                         else:
556                                 self.session.open(MessageBox, _("Only running streamings can be recorded!"), type = MessageBox.TYPE_INFO,timeout = 20 )
557
558         def green_pressed(self):
559                 if self.mode != self.FILTERLIST:
560                         self.mode = self.FILTERLIST
561                         if len(self.filterList):
562                                 self["headertext"].setText(_("InternetRadio filter list (%s)") % config.plugins.internetradio.filter.value)
563                                 self["list"].setMode(self.mode)
564                                 self["list"].setList(self.filterList)
565                                 self["list"].moveToIndex(self.filterListIndex)
566                         else:
567                                 self.getFilterList()
568                 else:
569                         config.plugins.internetradio.filter.value = self.filterSwitch[config.plugins.internetradio.filter.value]
570                         config.plugins.internetradio.filter.save()
571                         self["key_green"].setText(config.plugins.internetradio.filter.value)
572                         self.getFilterList()
573
574         def yellow_pressed(self):
575                 if self.mode != self.STATIONLIST:
576                         if len(self.stationList) and len(self.stationListFiltered):
577                                 self.setStationList()
578                         else:
579                                 self.stationListIndex = 0
580                                 if config.plugins.internetradio.filter.value == _("Countries"):
581                                         self.getStationList(_("All Countries"))
582                                 else:
583                                         self.getStationList(_("All Genres"))
584                                 
585         def blue_pressed(self):
586                 if self.mode != self.FAVORITELIST:
587                         self.getFavoriteList(self.favoriteListIndex)
588
589         def getFavoriteList(self, favoriteListIndex = 0):
590                 self.mode = self.FAVORITELIST
591                 self["headertext"].setText(_("Favorite list"))
592                 self["list"].setMode(self.mode)
593                 favoriteList = self.favoriteConfig.getFavoriteList()
594                 self["list"].setList(favoriteList)
595                 if len(favoriteList):
596                         self["list"].moveToIndex(favoriteListIndex)
597
598         def getFilterList(self):
599                 self.setStatusText(_("Getting InternetRadio %s list...") % config.plugins.internetradio.filter.value)
600                 self.stationListIndex = 0
601                 if len(self.stationList) == 0:
602                         sendUrlCommand(self.stationListURL, None,10).addCallback(self.callbackFilterList).addErrback(self.callbackFilterListError)
603                 else:
604                         self.setFilterList()
605
606         def callbackFilterList(self, xmlstring):
607                 self.stationList = self.fillStationList(xmlstring)
608                 self.setFilterList()
609                 
610         def setFilterList(self):
611                 self["headertext"].setText(_("InternetRadio filter list (%s)") % config.plugins.internetradio.filter.value)
612                 self.filterListIndex = 0
613                 self.mode = self.FILTERLIST
614                 self["list"].setMode(self.mode)
615                 if config.plugins.internetradio.filter.value == _("Countries"):
616                         self.filterList  = self.fillCountryList()
617                 else:
618                         self.filterList  = self.fillGenreList()
619                 self["list"].setList(self.filterList)
620                 if len(self.filterList):
621                         self["list"].moveToIndex(self.filterListIndex)
622
623         def callbackFilterListError(self, error = None):
624                 if error is not None:
625                         try:
626                                 self.setStatusText(_("%s...") % str(error.getErrorMessage()), 15000)
627                         except: pass
628                         
629         def fillGenreList(self):
630                 genreList = []
631                 genres = {} # stupid helper... FIXME!
632                 for items in self.stationList:
633                         for genre in items.tags.split(","):
634                                 genre = genre.strip().lower()
635                                 if not genres.has_key(genre):
636                                         genres[genre] = 0 # FIXME 
637                                         genreList.append(((InternetRadioFilter(name = genre)),))
638                 genreList =  sorted(genreList, key=lambda genrelist: genrelist[0].name)
639                 genreList.insert(0,((InternetRadioFilter(name = _("All Genres"))),))
640                 return genreList
641                 
642         def fillCountryList(self):
643                 countryList = []
644                 countries = {} # stupid helper... FIXME!
645                 for items in self.stationList:
646                         country = items.country.lower()
647                         if not countries.has_key(country):
648                                 countries[country] = 0 # FIXME 
649                                 countryList.append(((InternetRadioFilter(name = items.country)),))
650                 countryList = sorted(countryList, key=lambda countrylist: countrylist[0].name)
651                 countryList.insert(0,((InternetRadioFilter(name = _("All Countries"))),))
652                 return countryList
653
654         def ok_pressed(self):
655                 if self.visible:
656                         sel = None
657                         try:
658                                 sel = self["list"].l.getCurrentSelection()[0]
659                         except:return
660                         if sel is None:
661                                 return
662                         else:
663                                 if self.mode == self.FILTERLIST:
664                                         self.stationListIndex = 0
665                                         self.filterListIndex = self["list"].getCurrentIndex()
666                                         self.getStationList(sel.name)
667                                 elif self.mode in (self.STATIONLIST, self.FAVORITELIST):
668                                         goOn = True
669                                         currentPlayingStation = None
670                                         if self.mode == self.STATIONLIST:
671                                                 url = sel.url.rstrip().strip().lower()
672                                                 currentPlayingStation = sel
673                                                 currentPlayingStation.url = ""
674                                                 self.stationListIndex = self["list"].getCurrentIndex()
675                                         else:
676                                                 self.favoriteListIndex = self["list"].getCurrentIndex()
677                                                 if sel.configItem.type.value == 0:
678                                                         url = sel.configItem.text.value
679                                                         currentPlayingStation = InternetRadioStation(name = sel.configItem.name.value, tags = sel.configItem.tags.value, country = sel.configItem.country.value, homepage = sel.configItem.homepage.value)
680                                                 else:
681                                                         goOn = False
682                                                         if sel.configItem.type.value in (1,2):
683                                                                 self.stationListIndex = 0
684                                                                 self.filterList = []
685                                                                 if sel.configItem.type.value == 1:
686                                                                                 f = _("Genres")
687                                                                 else:
688                                                                                 f = _("Countries")
689                                                                 config.plugins.internetradio.filter.value = f
690                                                                 config.plugins.internetradio.filter.save()
691                                                                 self["key_green"].setText(config.plugins.internetradio.filter.value)
692                                                                 self.mode = self.FILTERLIST
693                                                                 self.getStationList(sel.configItem.name.value)
694                                         if goOn == True:
695                                                 self.playRadioStation(url, currentPlayingStation)
696                                 
697                                 elif self.mode == self.SEARCHLIST and self.searchInternetRadioString != "":
698                                         self.searchInternetRadio(self.searchInternetRadioString)
699
700         def playRadioStation(self, url, radioStation):
701                 self.stopPlaying()
702                 self.currentPlayingStation = radioStation
703                 self.url_tried = 0
704                 self.try_url = url
705                 if url.endswith(".pls") or url.endswith(".m3u") or url.endswith(".asx"):
706                         self.setStatusText(_("Getting streaming data from %s") % url)
707                         sendUrlCommand(url, None,10).addCallback(self.callbackPlayList).addErrback(self.callbackStationListError)
708                 else:
709                         self.playServiceStream(url)
710                         
711         def stopPlaying(self):
712                 self.musicPlayer.play("")
713                 self.currentPlayingStation = None 
714                 self["title"].setText("")
715                 self["station"].setText("")
716                 self.summaries.setText("")
717                 self["cover"].hide()
718                 self.visuCleanerTimer.start(100)
719
720         def callbackPlayList(self, result):
721                 found = False
722                 parts = string.split(result.lower(),"\n")
723                 if parts[0].startswith("http://"):
724                                         url = parts[0]
725                                         found = True
726                                         self.playServiceStream(url.rstrip().strip())
727                 elif parts[0].find("[playlist]") != -1:
728                         for lines in parts:
729                                 if lines.find("file1=") != -1:
730                                         line = string.split(lines,"file1=")
731                                         found = True
732                                         self.playServiceStream(line[-1].rstrip().strip())
733                                         break
734                 elif parts[0].find("#extm3u") != -1:
735                         for lines in parts:
736                                 if lines.startswith("http://"):
737                                         found = True
738                                         self.playServiceStream(lines.rstrip().strip())
739                                         break
740
741                 elif parts[0].lower().find("asx version") != -1:
742                         stationList = []
743                         try:
744                                 root = xml.etree.cElementTree.fromstring(result.lower())
745                         except: 
746                                 root = None
747                         if root:
748                                 for childs in root.findall("entry"):
749                                         for childs2 in childs.findall("ref"):
750                                                 url = childs2.get("href")
751                                                 if len(url):
752                                                         found = True
753                                                         self.playServiceStream(url.rstrip().strip())
754                                                         break
755                                         if found:
756                                                 break
757                 if not found:
758                         self.currentPlayingStation = None
759                         self.setStatusText(_("No streaming data found..."), 15000)
760
761         def getStationList(self,filter_string):
762                 self.stationHeaderText = _("InternetRadio station list for filter: %s") % filter_string
763                 self["headertext"].setText(self.stationHeaderText)
764                 self.setStatusText(_("Getting %s") %  self.stationHeaderText)
765
766                 if len(self.stationList) == 0:
767                         self.stationListIndex = 0
768                         sendUrlCommand(self.stationListURL, None,10).addCallback(boundFunction(self.callbackStationList,filter_string)).addErrback(self.callbackStationListError)
769                 else:
770                         self.stationListFiltered = self.getFilteredStationList(filter_string)
771                         self.setStationList()
772
773         def callbackStationList(self, filter_string, xmlstring):
774                 self.stationList = self.fillStationList(xmlstring)
775                 self.stationListFiltered = self.getFilteredStationList(filter_string)
776                 self.setStationList()
777                 
778         def setStationList(self):
779                 self.setStatusText("")
780                 self.mode = self.STATIONLIST
781                 self["headertext"].setText(self.stationHeaderText)
782                 self["list"].setMode(self.mode)
783                 self["list"].setList(self.stationListFiltered)
784                 if len(self.stationList):
785                         self["list"].moveToIndex(self.stationListIndex)
786                 
787         def getFilteredStationList(self, filter_string):
788                 if self.mode == self.SEARCHLIST:
789                         return [ (x,) for x in self.stationList if ( self.searchInternetRadioString in x.tags.lower() or self.searchInternetRadioString in x.name.lower())]
790                 else:
791                         self.searchInternetRadioString = ""
792                         if filter_string != _("All Genres") and filter_string != _("All Countries"):
793                                 if config.plugins.internetradio.filter.value == _("Countries"):
794                                         return [ (x,) for x in self.stationList if ( filter_string == x.country)]
795                                 else:
796                                         return [ (x,) for x in self.stationList if ( filter_string in x.tags)]
797                         else:
798                                 return [ (x,) for x in self.stationList]
799
800         def fillStationList(self,xmlstring):
801                 stationList = []
802                 try:
803                         root = xml.etree.cElementTree.fromstring(xmlstring)
804                 except: return []
805                 for childs in root.findall("station"):
806                         stationList.append(InternetRadioStation(name = childs.get("name").encode('utf-8','ignore'), 
807                                                                 tags = childs.get("tags").encode('utf-8','ignore'), country = childs.get("country").encode('utf-8','ignore'), url = childs.get("url"),
808                                                                 language = childs.get("language").encode('utf-8','ignore'), id = childs.get("id"), homepage = childs.get("homepage").encode('utf-8','ignore')))
809                 return sorted(stationList, key=lambda stations: stations.name)
810                 
811
812         def menu_pressed(self):
813                 self.fullScreenAutoActivationTimer.stop()
814                 options = [(_("Config"), self.config),(_("Search"), self.search),]
815                 if self.mode == self.FAVORITELIST and self.getSelectedItem() is not None:
816                         options.extend(((_("rename current selected favorite"), self.renameFavorite),))
817                         options.extend(((_("remove current selected favorite"), self.removeFavorite),))
818                         if config.plugins.internetradio.startupname.value != "":
819                                 options.extend(((_("do not play a service on startup"), boundFunction(self.startUpStation,False)),))
820                         if self.getSelectedItem().configItem.type.value == 0:
821                                 options.extend(((_("play current selected favorite on startup"), boundFunction(self.startUpStation,True)),))
822                 elif self.mode == self.FILTERLIST and self.getSelectedItem() is not None:
823                         options.extend(((_("Add current selected genre to favorite"), self.addFilterToFavorite),))
824                 elif self.mode == self.STATIONLIST and self.getSelectedItem() is not None:
825                         options.extend(((_("Add current selected station to favorite"), self.addStationToFavorite),))
826                 if self.currentPlayingStation and len(self.currentPlayingStation.url) != 0:
827                         options.extend(((_("Add current playing stream to favorite"), self.addCurrentStreamToFavorite),))
828                 options.extend(((_("Fullscreen"), self.showFullScreen),))
829                 if SystemInfo.get("NumVideoDecoders", 1) > 1:
830                         options.extend(((_("Show TV"), boundFunction(self.setPiPPlayerEnabled,True)),))
831                 self.session.openWithCallback(self.menuCallback, ChoiceBox,list = options)
832
833         def menuCallback(self, ret):
834                 ret and ret[1]()
835
836         def setPiPPlayerEnabled(self, value):
837                 if value:
838                         self["actions"].setEnabled(False)
839                         self.fullScreenAutoActivationTimer.stop()
840                         self.hide()
841                         self.visible = False
842                         self.setPiPTVPlayerEnabled(True)
843                 else:
844                         self.currentService = self.currService
845                         self["actions"].setEnabled(True)
846                         self.show()
847                         self.visible = True
848                         self.autoActivationKeyPressed()                 
849
850
851         def startUpStation(self, add):
852                 if add == True:
853                         sel = self.getSelectedItem()
854                         if sel and sel.configItem.type.value == 0:
855                                 config.plugins.internetradio.startupname.value = sel.configItem.name.value
856                                 config.plugins.internetradio.startuptext.value = sel.configItem.text.value
857                 else:
858                         config.plugins.internetradio.startupname.value = ""
859                         config.plugins.internetradio.startuptext.value = ""
860                 config.plugins.internetradio.save()
861
862         def addFilterToFavorite(self):
863                 sel = self.getSelectedItem()
864                 if sel is not None:
865                         if config.plugins.internetradio.filter.value == _("Countries"):
866                                 favoritetype = 2
867                         else:
868                                 favoritetype = 1
869                         self.favoriteConfig.addFavorite(name = sel.name, text = sel.name, favoritetype = favoritetype, tags = "", country = "", homepage = "")                  
870
871         def addStationToFavorite(self):
872                 sel = self.getSelectedItem()
873                 if sel is not None:
874                         self.favoriteConfig.addFavorite(name = sel.name, text = sel.url, favoritetype = 0, tags = sel.genre, country = sel.country, homepage = sel.homepage)                    
875                 
876         def addCurrentStreamToFavorite(self):
877                 self.favoriteConfig.addFavorite(name = self.currentPlayingStation.name, text = self.currentPlayingStation.url, favoritetype = 0, tags =self.currentPlayingStation.tags, country = self.currentPlayingStation.country, homepage = self.currentPlayingStation.homepage)
878
879         def renameFavorite(self):
880                 sel = self.getSelectedItem()
881                 if sel is not None:
882                         self.session.openWithCallback(boundFunction(self.renameFavoriteFinished, sel.configItem), VirtualKeyBoard, title = _("Enter new name for favorite item"), text = sel.configItem.name.value)
883
884         def renameFavoriteFinished(self, configItem, text = None):
885                 if text:
886                         self.favoriteConfig.renameFavorite(configItem, text)
887                         self.favoriteListIndex = self["list"].getCurrentIndex()
888                         self.getFavoriteList(self.favoriteListIndex)
889
890         def removeFavorite(self):
891                 sel = self.getSelectedItem()
892                 if sel is not None:
893                         self.favoriteConfig.removeFavorite(sel.configItem)
894                         self.favoriteListIndex = self["list"].getCurrentIndex()
895                         if self.favoriteListIndex >= 1:
896                                 self.favoriteListIndex -= 1
897                         self.getFavoriteList(self.favoriteListIndex)
898
899         def search(self):
900                 self.session.openWithCallback(self.searchInternetRadio, VirtualKeyBoard, title = _("Enter text to search for"))
901
902         def searchInternetRadio(self, searchstring = None):
903                 if searchstring:
904                         self.stationHeaderText =  _("InternetRadio station list for search-criteria: %s") % searchstring
905                         self["headertext"].setText(self.stationHeaderText)
906                         self.setStatusText(_("Searching InternetRadio for %s...") % searchstring)
907                         self.mode = self.SEARCHLIST
908                         self.searchInternetRadioString = searchstring.lower()
909                         self.stationListIndex = 0
910                         if len(self.stationList) == 0:
911                                 self.stationListIndex = 0
912                                 sendUrlCommand(self.stationListURL, None,10).addCallback(boundFunction(self.callbackStationList,"")).addErrback(self.callbackStationListError)
913                         else:
914                                 self.stationListFiltered = self.getFilteredStationList("")
915                                 self.setStationList()
916
917         def config(self):
918                 self.session.open(InternetRadioSetup)
919
920         def callbackStationListError(self, error = None):
921                 if error is not None:
922                         try:
923                                 self.setStatusText(_("%s ...") % str(error.getErrorMessage()), 15000)
924                         except: pass
925
926         def Error(self, error = None):
927                 if error is not None:
928                         try:
929                                 self.setStatusText(str(error.getErrorMessage()), 15000)
930                         except: pass
931         
932         def __onClose(self):
933                 global dataAvail_conn
934                 global appClosed_conn
935                 self.session.deleteDialog(self.fullScreen)
936                 self.fullScreen = None
937                 self.autoActivationKeyPressedActionSlot = None
938                 self.session.nav.SleepTimer.on_state_change.remove(self.sleepTimerEntryOnStateChange)
939                 self.session.nav.playService(self.currentService)
940                 dataAvail_conn = None
941                 appClosed_conn = None
942                 # fallback to earlier enigma versions FIXME Delete that when commiting
943                 try:
944                         config.plugins.internetradio.visualization.removeNotifier(self.visualizationConfigOnChange)
945                         config.plugins.internetradio.fullscreenautoactivation.removeNotifier(self.fullscreenautoactivationConfigOnChange)
946                         config.plugins.internetradio.fullscreenlayout.removeNotifier(self.fullscreenlayoutConfigOnChange)
947                 
948                 except:
949                         config.plugins.internetradio.visualization.notifiers.remove(self.visualizationConfigOnChange)
950                         config.plugins.internetradio.fullscreenautoactivation.notifiers.remove(self.fullscreenautoactivationConfigOnChange)
951                         config.plugins.internetradio.fullscreenlayout.notifiers.remove(self.fullscreenlayoutConfigOnChange)
952
953         def GoogleImageCallback(self, result):
954                 self.hideCover()
955                 results = simplejson_loads(result)
956                 try:
957                         url = results['responseData']['results'][0]['unescapedUrl']
958                 except: # fuck that
959                         url = ""
960                 if url != "":
961                         print "[InternetRadio] downloading cover from %s " % url
962                         downloadPage(url,"/tmp/.cover").addCallback(self.coverDownloadFinished).addErrback(self.coverDownloadFailed)
963
964         def coverDownloadFailed(self,result):
965                 print "[InternetRadio] cover download failed: %s " % result
966                 self.hideCover()
967                 
968         def hideCover(self):
969                 self["cover"].hide()
970                 self["cover"].setPicloaded(False)
971                 if self.fullScreen.isVisible() and config.plugins.internetradio.fullscreenlayout.value in ("0","1"):
972                         self.fullScreen.setVisibilityCover(False)
973
974         def coverDownloadFinished(self,result):
975                 print "[InternetRadio] cover download finished"
976                 self["cover"].updateIcon("/tmp/.cover")
977
978         def coverLoaded(self):
979                 self["cover"].show()
980                 if self.fullScreen.isVisible() and config.plugins.internetradio.fullscreenlayout.value in ("0","1"):
981                         self.fullScreen.updateCover()
982                 
983         def playServiceStream(self, url):
984                 self.musicPlayer.play(url)
985                 if self.currentPlayingStation:
986                         self.currentPlayingStation.url = url
987                         self["station"].setText(self.currentPlayingStation.name)
988                 self["title"].setText(_("Title: n/a"))
989
990         def createSummary(self):
991                 return InternetRadioOledDisplay
992
993         def getSelectedItem(self):
994                 sel = None
995                 try:
996                         sel = self["list"].l.getCurrentSelection()[0]
997                 except:return None
998                 return sel
999                 
1000         def closePlayer(self):
1001                 self.fullScreenKeyPressed()
1002                 self.close()
1003
1004         def setStatusText(self, text, cleartimertime = 3000):
1005                 self.clearStatusTextTimer.stop()
1006                 self["statustext"].setText(text)
1007                 self.clearStatusTextTimer.start(cleartimertime)
1008
1009         def clearStatusTextTimerCallback(self):
1010                 self.clearStatusTextTimer.stop()
1011                 self["statustext"].setText("")
1012
1013         # used from webinterface
1014         def updateFullscreenStationName(self, stationname):
1015                 if self.fullScreen.isVisible():
1016                         self.fullScreen.setStation(stationname)
1017
1018         # used from webinterface
1019         def getCurrentPlayingStation(self):
1020                 if self.currentPlayingStation and self.currentPlayingStation.url != "":
1021                         return (True, "%s - %s" % (self["station"].getText(), self["title"].getText()))
1022                 else:
1023                         return (False, _("nothing playing..."))
1024                 
1025         # used from webinterface
1026         def getStreamingInfos(self):
1027                 return self.musicPlayer.getMetaInfos()
1028
1029         # used from webinterface
1030         def updateFavoriteList(self):
1031                 if self.mode == self.FAVORITELIST:
1032                         index = self["list"].getCurrentIndex()
1033                         self.favoriteConfig.loadFavoriteConfig() # reload favorites
1034                         favoriteList = self.favoriteConfig.getFavoriteList()
1035                         self["list"].setList(favoriteList)
1036                         if len(favoriteList):
1037                                 self["list"].moveToIndex(index)
1038                 
1039 class InternetRadioFullScreen(Screen, InternetRadioVisualization):
1040
1041         sz_w = getDesktop(0).size().width()
1042         if sz_w == 1280:
1043
1044                 skin = """
1045                         <screen name="InternetRadioFullScreen" position="0,0" size="1280,720" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
1046                                 <widget name="station" position="50,120" zPosition="1" size="1180,20" font="Regular;18" transparent="1"  halign="center" foregroundColor="#356835" backgroundColor="#00000000"/>
1047                                 <widget name="title" position="50,550" zPosition="1" size="1180,80" font="Regular;22" transparent="1"  halign="center" foregroundColor="#4e9a4e" backgroundColor="#00000000"/>
1048                                 <widget name="progress_0" zPosition="3" position="440,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1049                                 <widget name="progress_1" zPosition="3" position="465,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1050                                 <widget name="progress_2" zPosition="3" position="490,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1051                                 <widget name="progress_3" zPosition="3" position="515,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1052                                 <widget name="progress_4" zPosition="3" position="540,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1053                                 <widget name="progress_5" zPosition="3" position="565,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1054                                 <widget name="progress_6" zPosition="3" position="590,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1055                                 <widget name="progress_7" zPosition="3" position="615,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1056                                 <widget name="progress_8" zPosition="3" position="640,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1057                                 <widget name="progress_9" zPosition="3" position="665,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1058                                 <widget name="progress_10" zPosition="3" position="690,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1059                                 <widget name="progress_11" zPosition="3" position="715,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1060                                 <widget name="progress_12" zPosition="3" position="740,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1061                                 <widget name="progress_13" zPosition="3" position="765,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1062                                 <widget name="progress_14" zPosition="3" position="790,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1063                                 <widget name="progress_15" zPosition="3" position="815,240" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1064                                 <widget name="top_0" position="440,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1065                                 <widget name="top_1" position="465,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1066                                 <widget name="top_2" position="490,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1067                                 <widget name="top_3" position="515,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1068                                 <widget name="top_4" position="540,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1069                                 <widget name="top_5" position="565,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1070                                 <widget name="top_6" position="590,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1071                                 <widget name="top_7" position="615,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1072                                 <widget name="top_8" position="640,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1073                                 <widget name="top_9" position="665,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1074                                 <widget name="top_10" position="690,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1075                                 <widget name="top_11" position="715,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1076                                 <widget name="top_12" position="740,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1077                                 <widget name="top_13" position="765,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1078                                 <widget name="top_14" position="790,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1079                                 <widget name="top_15" position="815,235" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1080                         </screen>"""
1081
1082         elif sz_w == 1024:
1083                 skin = """
1084                         <screen name="InternetRadioFullScreen" position="0,0" size="1024,576" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
1085                                 <widget name="station" position="50,120" zPosition="1" size="924,20" font="Regular;18" transparent="1"  halign="center" foregroundColor="#356835" backgroundColor="#00000000"/>
1086                                 <widget name="title" position="50,400" zPosition="1" size="924,80" font="Regular;22" transparent="1"  halign="center" foregroundColor="#4e9a4e" backgroundColor="#00000000"/>
1087                                 <widget name="progress_0" zPosition="3" position="312,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1088                                 <widget name="progress_1" zPosition="3" position="337,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1089                                 <widget name="progress_2" zPosition="3" position="362,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1090                                 <widget name="progress_3" zPosition="3" position="387,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1091                                 <widget name="progress_4" zPosition="3" position="412,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1092                                 <widget name="progress_5" zPosition="3" position="437,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1093                                 <widget name="progress_6" zPosition="3" position="462,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1094                                 <widget name="progress_7" zPosition="3" position="487,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1095                                 <widget name="progress_8" zPosition="3" position="512,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1096                                 <widget name="progress_9" zPosition="3" position="537,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1097                                 <widget name="progress_10" zPosition="3" position="562,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1098                                 <widget name="progress_11" zPosition="3" position="587,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1099                                 <widget name="progress_12" zPosition="3" position="612,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1100                                 <widget name="progress_13" zPosition="3" position="637,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1101                                 <widget name="progress_14" zPosition="3" position="662,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1102                                 <widget name="progress_15" zPosition="3" position="687,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1103                                 <widget name="top_0" position="312,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1104                                 <widget name="top_1" position="337,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1105                                 <widget name="top_2" position="362,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1106                                 <widget name="top_3" position="387,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1107                                 <widget name="top_4" position="412,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1108                                 <widget name="top_5" position="437,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1109                                 <widget name="top_6" position="462,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1110                                 <widget name="top_7" position="487,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1111                                 <widget name="top_8" position="512,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1112                                 <widget name="top_9" position="537,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1113                                 <widget name="top_10" position="562,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1114                                 <widget name="top_11" position="587,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1115                                 <widget name="top_12" position="612,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1116                                 <widget name="top_13" position="637,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1117                                 <widget name="top_14" position="662,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1118                                 <widget name="top_15" position="687,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1119                         </screen>"""
1120
1121
1122
1123                         
1124         else:
1125                 skin = """
1126                         <screen name="InternetRadioFullScreen" position="0,0" size="720,576" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
1127                                 <widget name="station" position="50,120" zPosition="1" size="620,20" font="Regular;18" transparent="1"  halign="center" foregroundColor="#356835" backgroundColor="#00000000"/>
1128                                 <widget name="title" position="50,400" zPosition="1" size="620,80" font="Regular;22" transparent="1"  halign="center" foregroundColor="#4e9a4e" backgroundColor="#00000000"/>
1129                                 <widget name="progress_0" zPosition="3" position="170,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1130                                 <widget name="progress_1" zPosition="3" position="195,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1131                                 <widget name="progress_2" zPosition="3" position="220,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1132                                 <widget name="progress_3" zPosition="3" position="245,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1133                                 <widget name="progress_4" zPosition="3" position="270,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1134                                 <widget name="progress_5" zPosition="3" position="295,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1135                                 <widget name="progress_6" zPosition="3" position="320,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1136                                 <widget name="progress_7" zPosition="3" position="345,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1137                                 <widget name="progress_8" zPosition="3" position="370,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1138                                 <widget name="progress_9" zPosition="3" position="395,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1139                                 <widget name="progress_10" zPosition="3" position="420,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1140                                 <widget name="progress_11" zPosition="3" position="445,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1141                                 <widget name="progress_12" zPosition="3" position="470,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1142                                 <widget name="progress_13" zPosition="3" position="495,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1143                                 <widget name="progress_14" zPosition="3" position="520,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1144                                 <widget name="progress_15" zPosition="3" position="545,138" size="25,200" transparent="1" orientation="orBottomToTop" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green-fs8.png" />
1145                                 <widget name="top_0" position="170,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1146                                 <widget name="top_1" position="195,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1147                                 <widget name="top_2" position="220,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1148                                 <widget name="top_3" position="245,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1149                                 <widget name="top_4" position="270,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1150                                 <widget name="top_5" position="295,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1151                                 <widget name="top_6" position="320,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1152                                 <widget name="top_7" position="345,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1153                                 <widget name="top_8" position="370,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1154                                 <widget name="top_9" position="395,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1155                                 <widget name="top_10" position="420,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1156                                 <widget name="top_11" position="445,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1157                                 <widget name="top_12" position="470,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1158                                 <widget name="top_13" position="495,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1159                                 <widget name="top_14" position="520,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1160                                 <widget name="top_15" position="545,133" zPosition="6" size="25,5" transparent="1" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/InternetRadio/images/bar_green_top-fs8.png" />
1161                         </screen>"""
1162
1163
1164         def __init__(self, session):
1165                 self.session = session
1166                 Screen.__init__(self, session)
1167                 InternetRadioVisualization.__init__(self)
1168                 self["title"] =  Label("")
1169                 self["station"] = Label("")
1170                 self["cover"] = InternetRadioCover(self.coverLoaded)
1171                 self.onLayoutFinish.append(self.startRun)
1172                 self.visible = False
1173
1174         def startRun(self):
1175                 self.setProperties()
1176                 self.hideControls()
1177
1178         def setText(self, title):
1179                 self["title"].setText(title)
1180
1181         def setStation(self, station):
1182                 self["station"].setText(station)
1183
1184
1185         def setVisibility(self, visible):
1186                 if visible:
1187                         if config.plugins.internetradio.fullscreenlayout.value != "0":
1188                                 self.hideControls()
1189                         self.show()
1190                 else:
1191                         self.hide()
1192                 self.visible = visible
1193
1194         def isVisible(self):
1195                 return self.visible
1196
1197         def setVisibilityCover(self, visible):
1198                 if visible and config.plugins.internetradio.googlecover.value:
1199                         self["cover"].show()
1200                 else:
1201                         self["cover"].hide()
1202                         
1203         def updateCover(self):
1204                 self["cover"].updateIcon("/tmp/.cover")
1205                 
1206         def coverLoaded(self):
1207                 self.setVisibilityCover(True)