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