Merge branch 'master' of ssh://scm.schwerkraft.elitedvb.net/scmrepos/git/enigma2...
[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.callback.append(self.musicPlayerCallBack)
306                 self.musicPlayer.callback.get().append(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.callback.append(self.visuCleanerTimerCallback)
317
318                 self.clearStatusTextTimer = eTimer()
319                 self.clearStatusTextTimer.callback.append(self.clearStatusTextTimerCallback)
320
321                 self.fullScreenAutoActivationTimer = eTimer()
322                 self.fullScreenAutoActivationTimer.callback.append(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                 if containerStreamripper is None:
331                         containerStreamripper = eConsoleAppContainer()
332
333                 containerStreamripper.dataAvail.append(self.streamripperDataAvail)
334                 containerStreamripper.appClosed.append(self.streamripperClosed)
335
336                 if url is not None and radioStation is not None:
337                         self.playRadioStation(url, radioStation)
338                 elif containerStreamripper.running():
339                         self["key_red"].setText(_("Stop record"))
340                         # just to hear to recording music when starting the plugin...
341                         self.currentPlayingStation = InternetRadioStation(name = _("Recording stream station"))
342                         self.playServiceStream("http://localhost:9191")
343                 self.session.nav.SleepTimer.on_state_change.append(self.sleepTimerEntryOnStateChange)
344         
345         def sleepTimerEntryOnStateChange(self, timer):
346                 if timer.state == TimerEntry.StateEnded:
347                         self.closePlayer()
348
349         def onBeginExec(self):
350                 if config.plugins.internetradio.visualization.value in ("2", "3"):
351                         self.summaries.setLabelVisibility(True)                 
352
353         def visualizationConfigOnChange(self, configElement = None):
354                 if config.plugins.internetradio.visualization.value in ("0", "1"):
355                         self.musicPlayer.setBands(self.BANDS)
356                         self.summaries.setLabelVisibility(False)
357                 elif config.plugins.internetradio.visualization.value == "2":
358                         self.musicPlayer.setBands(self.BANDS)
359                         self.summaries.setLabelVisibility(True)
360                 elif config.plugins.internetradio.visualization.value == "3":
361                         if config.plugins.internetradio.fullscreenlayout.value != "0":
362                                 self.musicPlayer.setBands(0)
363                         self.summaries.setLabelVisibility(True)
364                 if config.plugins.internetradio.visualization.value in ("1", "3"):
365                         self.hideControls()
366
367         def fullscreenlayoutConfigOnChange(self, configElement = None):
368                 if config.plugins.internetradio.visualization.value == "3" and config.plugins.internetradio.fullscreenlayout.value != "0":
369                         self.musicPlayer.setBands(0)
370                 else:
371                         self.musicPlayer.setBands(self.BANDS)
372
373         def fullscreenautoactivationConfigOnChange(self, configElement = None):
374                 if config.plugins.internetradio.fullscreenautoactivation.value == "-1":
375                         self.fullScreenAutoActivationTimer.stop()
376                 else:
377                         self.fullScreenAutoActivationTimer.start(int(config.plugins.internetradio.fullscreenautoactivation.value)*1000)
378
379         def autoActivationKeyPressed(self, key = None, flag = None):
380                 self.fullScreenAutoActivationTimer.stop()
381                 if  self.shown == True and self.visible == True and config.plugins.internetradio.fullscreenautoactivation.value != "-1":
382                         self.fullScreenAutoActivationTimer.start(int(config.plugins.internetradio.fullscreenautoactivation.value)*1000)
383                 return 0
384
385         def fullScreenAutoActivationTimerCallback(self):
386                 self.fullScreenAutoActivationTimer.stop()
387                 self.showFullScreen()
388
389         def startRun(self):
390                 self.setPiPTVPlayerEnabled(False)
391                 config.plugins.internetradio.visualization.addNotifier(self.visualizationConfigOnChange, initial_call = True)
392                 config.plugins.internetradio.fullscreenautoactivation.addNotifier(self.fullscreenautoactivationConfigOnChange, initial_call = True)
393                 config.plugins.internetradio.fullscreenlayout.addNotifier(self.fullscreenlayoutConfigOnChange, initial_call = False)
394                 self.setPBtoNull()
395                 self.setProperties()
396                 self.getFavoriteList()
397                 self.visuCleanerTimer.start(1000)
398                 if self.currentPlayingStation is None and config.plugins.internetradio.startupname.value != "" and config.plugins.internetradio.startuptext.value != "":
399                         self["list"].moveToFavorite(config.plugins.internetradio.startupname.value, config.plugins.internetradio.startuptext.value)
400                         url = config.plugins.internetradio.startuptext.value
401                         self.currentPlayingStation = InternetRadioStation(name = config.plugins.internetradio.startupname.value, url = url)
402                         self.url_tried = 0
403                         self.try_url = url
404                         if url.endswith(".pls") or url.endswith(".m3u") or url.endswith(".asx"):
405                                 self.setStatusText(_("Getting streaming data from %s") % url)
406                                 sendUrlCommand(url, None,10).addCallback(self.callbackPlayList).addErrback(self.callbackStationListError)
407                         else:
408                                 self.playServiceStream(url)
409
410         def info_pressed(self):
411                 meta = self.musicPlayer.getMetaInfos()
412                 self.session.open(InternetRadioInformationScreen, meta)
413
414         def showFullScreen(self):
415                 if self.fullScreen.isVisible() == False:
416                         self.visible = False
417                         self.fullScreen.setVisibility(True)
418                         if config.plugins.internetradio.fullscreenlayout.value in ("0","1"):
419                                 self.fullScreen.setStation(self["station"].getText())
420                                 self.fullScreen.setText(self["title"].getText())
421                         else:
422                                 self.fullScreen.setStation("")
423                                 self.fullScreen.setText("")
424                         eActionMap.getInstance().bindAction('', -0x7FFFFFFF, self.fullScreenKeyPressed)
425                         
426         def fullScreenKeyPressed(self, key = None, flag = None):
427                 if self.fullScreen.isVisible():
428                         self.visible = True
429                         self.fullScreen.setVisibility(False)
430                         eActionMap.getInstance().unbindAction('', self.fullScreenKeyPressed)
431                         self.autoActivationKeyPressed()
432                         return 1
433                 else:
434                         return 0
435
436         def visuCleanerTimerCallback(self):
437                 self.visuCleanerTimer.stop()
438                 if self.needCleanup() == True:
439                         code = 0
440                         v = (-80,) * self.BANDS
441                         self.musicPlayerCallBack(code,v,True)
442
443         def musicPlayerCallBack(self, code = None, v = None, cleanup = False):
444                 if self.visuCleanerTimer.isActive():
445                         self.visuCleanerTimer.stop()
446                 if code == 0 and len(v) > 0:
447                         if config.plugins.internetradio.visualization.value in ("0","1"):
448                                 self.summaries.setValues(v)
449                         if self.fullScreen.isVisible() and config.plugins.internetradio.fullscreenlayout.value == "0":
450                                 self.fullScreen.setValues(v)
451                         if self.visible and config.plugins.internetradio.visualization.value in ("0","2"):
452                                 self.setValues(v)
453                 elif code == 1:
454                         cleanup = True
455                         if (len(v[0]) !=0):
456                                 if len(v[1]) != 0:
457                                         sTitle = "%s - %s" % (v[0],v[1])
458                                 else:
459                                         sTitle = v[0]
460                                 if config.plugins.internetradio.googlecover.value:
461                                         url = "http://images.google.de/images?q=%s&btnG=Bilder-Suche" % quote(sTitle)
462                                         sendUrlCommand(url, None,10).addCallback(self.GoogleImageCallback).addErrback(self.Error)
463                         else:
464                                 sTitle = "n/a"
465                         self["title"].setText(sTitle)
466                         self.summaries.setText(sTitle)
467                         if self.fullScreen.isVisible() and config.plugins.internetradio.fullscreenlayout.value in ("0", "1"):
468                                 self.fullScreen.setText(sTitle)
469                 elif code == -2:
470                         cleanup = True
471                         if v[0] in (5, 6): # text/uri-list - this can't be decoded.
472                                 self.url_tried += 1
473                                 if self.url_tried == 1:
474                                         self.setStatusText(_("Getting streaming data from\n%s") % self.try_url)
475                                         sendUrlCommand(self.try_url, None,10).addCallback(self.callbackPlayList).addErrback(self.callbackStationListError)
476                                 else:
477                                         self.setStatusText("Error: %s" % v[1], 15000)
478                                         self.currentPlayingStation = None
479                         else:
480                                 self.setStatusText("Error: %s" % v[1], 15000)
481                                 self.currentPlayingStation = None
482                 elif code == -5:
483                         cleanup = True
484                         if v[0] == 0:
485                                 text = "trying to start %s..." % v[1]
486                         elif v[0] == 1:
487                                 text = "playing %s..." % v[1]
488                         elif v[0] == 2:
489                                 text = "%s stopped playing..." % v[1]
490                         else:
491                                 text = ""
492                         self.setStatusText(text)
493                 else:
494                         if v and len(v) > 2:
495                                 self.setStatusText("Error: %s" % v[1], 15000)
496                         cleanup = True
497
498                 if cleanup == True:
499                         self.visuCleanerTimer.start(100)
500
501         def streamripperClosed(self, retval):
502                 if retval == 0:
503                         self["console"].setText("")
504                 self["key_red"].setText(_("Record"))
505
506         def streamripperDataAvail(self, data):
507                 sData = data.replace('\n','')
508                 self["console"].setText(sData)
509
510         def InputBoxStartRecordingCallback(self, returnValue = None):
511                 if returnValue:
512                         recordingLength =  int(returnValue) * 60
513                         if not os.path.exists(config.plugins.internetradio.dirname.value):
514                                 os.mkdir(config.plugins.internetradio.dirname.value)
515                         args = []
516                         args.append(self.currentPlayingStation.url)
517                         args.append('-d')
518                         args.append(config.plugins.internetradio.dirname.value)
519                         args.append('-r')
520                         args.append('9191')
521                         if recordingLength != 0:
522                                 args.append('-l')
523                                 args.append("%d" % int(recordingLength))
524                         if config.plugins.internetradio.riptosinglefile.value:
525                                 args.append('-a')
526                                 args.append('-A')
527                         if not config.plugins.internetradio.createdirforeachstream.value:
528                                 args.append('-s')
529                         if config.plugins.internetradio.addsequenceoutputfile.value:
530                                 args.append('-q')
531                         cmd = [self.STREAMRIPPER_BIN, self.STREAMRIPPER_BIN] + args
532                         containerStreamripper.execute(*cmd)
533                         self["key_red"].setText(_("Stop record"))
534                         
535         def deleteRecordingConfirmed(self,val):
536                 if val:
537                         containerStreamripper.sendCtrlC()
538
539         def red_pressed(self):
540                 if containerStreamripper.running():
541                         self.session.openWithCallback(self.deleteRecordingConfirmed, MessageBox, _("Do you really want to stop the recording?"))
542                 else:
543                         if self.currentPlayingStation and len(self.currentPlayingStation.url) != 0:
544                                 self.session.openWithCallback(self.InputBoxStartRecordingCallback, InputBox, windowTitle = _("Recording length"),  title=_("Enter in minutes (0 means unlimited)"), text="0", type=Input.NUMBER)
545                         else:
546                                 self.session.open(MessageBox, _("Only running streamings can be recorded!"), type = MessageBox.TYPE_INFO,timeout = 20 )
547
548         def green_pressed(self):
549                 if self.mode != self.FILTERLIST:
550                         self.mode = self.FILTERLIST
551                         if len(self.filterList):
552                                 self["headertext"].setText(_("InternetRadio filter list (%s)") % config.plugins.internetradio.filter.value)
553                                 self["list"].setMode(self.mode)
554                                 self["list"].setList(self.filterList)
555                                 self["list"].moveToIndex(self.filterListIndex)
556                         else:
557                                 self.getFilterList()
558                 else:
559                         config.plugins.internetradio.filter.value = self.filterSwitch[config.plugins.internetradio.filter.value]
560                         config.plugins.internetradio.filter.save()
561                         self["key_green"].setText(config.plugins.internetradio.filter.value)
562                         self.getFilterList()
563
564         def yellow_pressed(self):
565                 if self.mode != self.STATIONLIST:
566                         if len(self.stationList) and len(self.stationListFiltered):
567                                 self.setStationList()
568                         else:
569                                 self.stationListIndex = 0
570                                 if config.plugins.internetradio.filter.value == _("Countries"):
571                                         self.getStationList(_("All Countries"))
572                                 else:
573                                         self.getStationList(_("All Genres"))
574                                 
575         def blue_pressed(self):
576                 if self.mode != self.FAVORITELIST:
577                         self.getFavoriteList(self.favoriteListIndex)
578
579         def getFavoriteList(self, favoriteListIndex = 0):
580                 self.mode = self.FAVORITELIST
581                 self["headertext"].setText(_("Favorite list"))
582                 self["list"].setMode(self.mode)
583                 favoriteList = self.favoriteConfig.getFavoriteList()
584                 self["list"].setList(favoriteList)
585                 if len(favoriteList):
586                         self["list"].moveToIndex(favoriteListIndex)
587
588         def getFilterList(self):
589                 self.setStatusText(_("Getting InternetRadio %s list...") % config.plugins.internetradio.filter.value)
590                 self.stationListIndex = 0
591                 if len(self.stationList) == 0:
592                         sendUrlCommand(self.stationListURL, None,10).addCallback(self.callbackFilterList).addErrback(self.callbackFilterListError)
593                 else:
594                         self.setFilterList()
595
596         def callbackFilterList(self, xmlstring):
597                 self.stationList = self.fillStationList(xmlstring)
598                 self.setFilterList()
599                 
600         def setFilterList(self):
601                 self["headertext"].setText(_("InternetRadio filter list (%s)") % config.plugins.internetradio.filter.value)
602                 self.filterListIndex = 0
603                 self.mode = self.FILTERLIST
604                 self["list"].setMode(self.mode)
605                 if config.plugins.internetradio.filter.value == _("Countries"):
606                         self.filterList  = self.fillCountryList()
607                 else:
608                         self.filterList  = self.fillGenreList()
609                 self["list"].setList(self.filterList)
610                 if len(self.filterList):
611                         self["list"].moveToIndex(self.filterListIndex)
612
613         def callbackFilterListError(self, error = None):
614                 if error is not None:
615                         try:
616                                 self.setStatusText(_("%s...") % str(error.getErrorMessage()), 15000)
617                         except: pass
618                         
619         def fillGenreList(self):
620                 genreList = []
621                 genres = {} # stupid helper... FIXME!
622                 for items in self.stationList:
623                         for genre in items.tags.split(","):
624                                 genre = genre.strip().lower()
625                                 if not genres.has_key(genre):
626                                         genres[genre] = 0 # FIXME 
627                                         genreList.append(((InternetRadioFilter(name = genre)),))
628                 genreList =  sorted(genreList, key=lambda genrelist: genrelist[0].name)
629                 genreList.insert(0,((InternetRadioFilter(name = _("All Genres"))),))
630                 return genreList
631                 
632         def fillCountryList(self):
633                 countryList = []
634                 countries = {} # stupid helper... FIXME!
635                 for items in self.stationList:
636                         country = items.country.lower()
637                         if not countries.has_key(country):
638                                 countries[country] = 0 # FIXME 
639                                 countryList.append(((InternetRadioFilter(name = items.country)),))
640                 countryList = sorted(countryList, key=lambda countrylist: countrylist[0].name)
641                 countryList.insert(0,((InternetRadioFilter(name = _("All Countries"))),))
642                 return countryList
643
644         def ok_pressed(self):
645                 if self.visible:
646                         sel = None
647                         try:
648                                 sel = self["list"].l.getCurrentSelection()[0]
649                         except:return
650                         if sel is None:
651                                 return
652                         else:
653                                 if self.mode == self.FILTERLIST:
654                                         self.stationListIndex = 0
655                                         self.filterListIndex = self["list"].getCurrentIndex()
656                                         self.getStationList(sel.name)
657                                 elif self.mode in (self.STATIONLIST, self.FAVORITELIST):
658                                         goOn = True
659                                         currentPlayingStation = None
660                                         if self.mode == self.STATIONLIST:
661                                                 url = sel.url.rstrip().strip().lower()
662                                                 currentPlayingStation = sel
663                                                 currentPlayingStation.url = ""
664                                                 self.stationListIndex = self["list"].getCurrentIndex()
665                                         else:
666                                                 self.favoriteListIndex = self["list"].getCurrentIndex()
667                                                 if sel.configItem.type.value == 0:
668                                                         url = sel.configItem.text.value
669                                                         currentPlayingStation = InternetRadioStation(name = sel.configItem.name.value, tags = sel.configItem.tags.value, country = sel.configItem.country.value, homepage = sel.configItem.homepage.value)
670                                                 else:
671                                                         goOn = False
672                                                         if sel.configItem.type.value in (1,2):
673                                                                 self.stationListIndex = 0
674                                                                 self.filterList = []
675                                                                 if sel.configItem.type.value == 1:
676                                                                                 f = _("Genres")
677                                                                 else:
678                                                                                 f = _("Countries")
679                                                                 config.plugins.internetradio.filter.value = f
680                                                                 config.plugins.internetradio.filter.save()
681                                                                 self["key_green"].setText(config.plugins.internetradio.filter.value)
682                                                                 self.mode = self.FILTERLIST
683                                                                 self.getStationList(sel.configItem.name.value)
684                                         if goOn == True:
685                                                 self.playRadioStation(url, currentPlayingStation)
686                                 
687                                 elif self.mode == self.SEARCHLIST and self.searchInternetRadioString != "":
688                                         self.searchInternetRadio(self.searchInternetRadioString)
689
690         def playRadioStation(self, url, radioStation):
691                 self.stopPlaying()
692                 self.currentPlayingStation = radioStation
693                 self.url_tried = 0
694                 self.try_url = url
695                 if url.endswith(".pls") or url.endswith(".m3u") or url.endswith(".asx"):
696                         self.setStatusText(_("Getting streaming data from %s") % url)
697                         sendUrlCommand(url, None,10).addCallback(self.callbackPlayList).addErrback(self.callbackStationListError)
698                 else:
699                         self.playServiceStream(url)
700                         
701         def stopPlaying(self):
702                 self.musicPlayer.play("")
703                 self.currentPlayingStation = None 
704                 self["title"].setText("")
705                 self["station"].setText("")
706                 self.summaries.setText("")
707                 self["cover"].hide()
708                 self.visuCleanerTimer.start(100)
709
710         def callbackPlayList(self, result):
711                 found = False
712                 parts = string.split(result.lower(),"\n")
713                 if parts[0].startswith("http://"):
714                                         url = parts[0]
715                                         found = True
716                                         self.playServiceStream(url.rstrip().strip())
717                 elif parts[0].find("[playlist]") != -1:
718                         for lines in parts:
719                                 if lines.find("file1=") != -1:
720                                         line = string.split(lines,"file1=")
721                                         found = True
722                                         self.playServiceStream(line[-1].rstrip().strip())
723                                         break
724                 elif parts[0].find("#extm3u") != -1:
725                         for lines in parts:
726                                 if lines.startswith("http://"):
727                                         found = True
728                                         self.playServiceStream(lines.rstrip().strip())
729                                         break
730
731                 elif parts[0].lower().find("asx version") != -1:
732                         stationList = []
733                         try:
734                                 root = xml.etree.cElementTree.fromstring(result.lower())
735                         except: 
736                                 root = None
737                         if root:
738                                 for childs in root.findall("entry"):
739                                         for childs2 in childs.findall("ref"):
740                                                 url = childs2.get("href")
741                                                 if len(url):
742                                                         found = True
743                                                         self.playServiceStream(url.rstrip().strip())
744                                                         break
745                                         if found:
746                                                 break
747                 if not found:
748                         self.currentPlayingStation = None
749                         self.setStatusText(_("No streaming data found..."), 15000)
750
751         def getStationList(self,filter_string):
752                 self.stationHeaderText = _("InternetRadio station list for filter: %s") % filter_string
753                 self["headertext"].setText(self.stationHeaderText)
754                 self.setStatusText(_("Getting %s") %  self.stationHeaderText)
755
756                 if len(self.stationList) == 0:
757                         self.stationListIndex = 0
758                         sendUrlCommand(self.stationListURL, None,10).addCallback(boundFunction(self.callbackStationList,filter_string)).addErrback(self.callbackStationListError)
759                 else:
760                         self.stationListFiltered = self.getFilteredStationList(filter_string)
761                         self.setStationList()
762
763         def callbackStationList(self, filter_string, xmlstring):
764                 self.stationList = self.fillStationList(xmlstring)
765                 self.stationListFiltered = self.getFilteredStationList(filter_string)
766                 self.setStationList()
767                 
768         def setStationList(self):
769                 self.setStatusText("")
770                 self.mode = self.STATIONLIST
771                 self["headertext"].setText(self.stationHeaderText)
772                 self["list"].setMode(self.mode)
773                 self["list"].setList(self.stationListFiltered)
774                 if len(self.stationList):
775                         self["list"].moveToIndex(self.stationListIndex)
776                 
777         def getFilteredStationList(self, filter_string):
778                 if self.mode == self.SEARCHLIST:
779                         return [ (x,) for x in self.stationList if ( self.searchInternetRadioString in x.tags.lower() or self.searchInternetRadioString in x.name.lower())]
780                 else:
781                         self.searchInternetRadioString = ""
782                         if filter_string != _("All Genres") and filter_string != _("All Countries"):
783                                 if config.plugins.internetradio.filter.value == _("Countries"):
784                                         return [ (x,) for x in self.stationList if ( filter_string == x.country)]
785                                 else:
786                                         return [ (x,) for x in self.stationList if ( filter_string in x.tags)]
787                         else:
788                                 return [ (x,) for x in self.stationList]
789
790         def fillStationList(self,xmlstring):
791                 stationList = []
792                 try:
793                         root = xml.etree.cElementTree.fromstring(xmlstring)
794                 except: return []
795                 for childs in root.findall("station"):
796                         stationList.append(InternetRadioStation(name = childs.get("name").encode('utf-8','ignore'), 
797                                                                 tags = childs.get("tags").encode('utf-8','ignore'), country = childs.get("country").encode('utf-8','ignore'), url = childs.get("url"),
798                                                                 language = childs.get("language").encode('utf-8','ignore'), id = childs.get("id"), homepage = childs.get("homepage").encode('utf-8','ignore')))
799                 return sorted(stationList, key=lambda stations: stations.name)
800                 
801
802         def menu_pressed(self):
803                 self.fullScreenAutoActivationTimer.stop()
804                 options = [(_("Config"), self.config),(_("Search"), self.search),]
805                 if self.mode == self.FAVORITELIST and self.getSelectedItem() is not None:
806                         options.extend(((_("rename current selected favorite"), self.renameFavorite),))
807                         options.extend(((_("remove current selected favorite"), self.removeFavorite),))
808                         if config.plugins.internetradio.startupname.value != "":
809                                 options.extend(((_("do not play a service on startup"), boundFunction(self.startUpStation,False)),))
810                         if self.getSelectedItem().configItem.type.value == 0:
811                                 options.extend(((_("play current selected favorite on startup"), boundFunction(self.startUpStation,True)),))
812                 elif self.mode == self.FILTERLIST and self.getSelectedItem() is not None:
813                         options.extend(((_("Add current selected genre to favorite"), self.addFilterToFavorite),))
814                 elif self.mode == self.STATIONLIST and self.getSelectedItem() is not None:
815                         options.extend(((_("Add current selected station to favorite"), self.addStationToFavorite),))
816                 if self.currentPlayingStation and len(self.currentPlayingStation.url) != 0:
817                         options.extend(((_("Add current playing stream to favorite"), self.addCurrentStreamToFavorite),))
818                 options.extend(((_("Fullscreen"), self.showFullScreen),))
819                 if SystemInfo.get("NumVideoDecoders", 1) > 1:
820                         options.extend(((_("Show TV"), boundFunction(self.setPiPPlayerEnabled,True)),))
821                 self.session.openWithCallback(self.menuCallback, ChoiceBox,list = options)
822
823         def menuCallback(self, ret):
824                 ret and ret[1]()
825
826         def setPiPPlayerEnabled(self, value):
827                 if value:
828                         self["actions"].setEnabled(False)
829                         self.fullScreenAutoActivationTimer.stop()
830                         self.hide()
831                         self.visible = False
832                         self.setPiPTVPlayerEnabled(True)
833                 else:
834                         self.currentService = self.currService
835                         self["actions"].setEnabled(True)
836                         self.show()
837                         self.visible = True
838                         self.autoActivationKeyPressed()                 
839
840
841         def startUpStation(self, add):
842                 if add == True:
843                         sel = self.getSelectedItem()
844                         if sel and sel.configItem.type.value == 0:
845                                 config.plugins.internetradio.startupname.value = sel.configItem.name.value
846                                 config.plugins.internetradio.startuptext.value = sel.configItem.text.value
847                 else:
848                         config.plugins.internetradio.startupname.value = ""
849                         config.plugins.internetradio.startuptext.value = ""
850                 config.plugins.internetradio.save()
851
852         def addFilterToFavorite(self):
853                 sel = self.getSelectedItem()
854                 if sel is not None:
855                         if config.plugins.internetradio.filter.value == _("Countries"):
856                                 favoritetype = 2
857                         else:
858                                 favoritetype = 1
859                         self.favoriteConfig.addFavorite(name = sel.name, text = sel.name, favoritetype = favoritetype, tags = "", country = "", homepage = "")                  
860
861         def addStationToFavorite(self):
862                 sel = self.getSelectedItem()
863                 if sel is not None:
864                         self.favoriteConfig.addFavorite(name = sel.name, text = sel.url, favoritetype = 0, tags = sel.genre, country = sel.country, homepage = sel.homepage)                    
865                 
866         def addCurrentStreamToFavorite(self):
867                 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)
868
869         def renameFavorite(self):
870                 sel = self.getSelectedItem()
871                 if sel is not None:
872                         self.session.openWithCallback(boundFunction(self.renameFavoriteFinished, sel.configItem), VirtualKeyBoard, title = _("Enter new name for favorite item"), text = sel.configItem.name.value)
873
874         def renameFavoriteFinished(self, configItem, text = None):
875                 if text:
876                         self.favoriteConfig.renameFavorite(configItem, text)
877                         self.favoriteListIndex = self["list"].getCurrentIndex()
878                         self.getFavoriteList(self.favoriteListIndex)
879
880         def removeFavorite(self):
881                 sel = self.getSelectedItem()
882                 if sel is not None:
883                         self.favoriteConfig.removeFavorite(sel.configItem)
884                         self.favoriteListIndex = self["list"].getCurrentIndex()
885                         if self.favoriteListIndex >= 1:
886                                 self.favoriteListIndex -= 1
887                         self.getFavoriteList(self.favoriteListIndex)
888
889         def search(self):
890                 self.session.openWithCallback(self.searchInternetRadio, VirtualKeyBoard, title = _("Enter text to search for"))
891
892         def searchInternetRadio(self, searchstring = None):
893                 if searchstring:
894                         self.stationHeaderText =  _("InternetRadio station list for search-criteria: %s") % searchstring
895                         self["headertext"].setText(self.stationHeaderText)
896                         self.setStatusText(_("Searching InternetRadio for %s...") % searchstring)
897                         self.mode = self.SEARCHLIST
898                         self.searchInternetRadioString = searchstring.lower()
899                         self.stationListIndex = 0
900                         if len(self.stationList) == 0:
901                                 self.stationListIndex = 0
902                                 sendUrlCommand(self.stationListURL, None,10).addCallback(boundFunction(self.callbackStationList,"")).addErrback(self.callbackStationListError)
903                         else:
904                                 self.stationListFiltered = self.getFilteredStationList("")
905                                 self.setStationList()
906
907         def config(self):
908                 self.session.open(InternetRadioSetup)
909
910         def callbackStationListError(self, error = None):
911                 if error is not None:
912                         try:
913                                 self.setStatusText(_("%s ...") % str(error.getErrorMessage()), 15000)
914                         except: pass
915
916         def Error(self, error = None):
917                 if error is not None:
918                         try:
919                                 self.setStatusText(str(error.getErrorMessage()), 15000)
920                         except: pass
921         
922         def __onClose(self):
923                 self.session.deleteDialog(self.fullScreen)
924                 self.fullScreen = None
925                 eActionMap.getInstance().unbindAction('', self.autoActivationKeyPressed)
926                 self.session.nav.SleepTimer.on_state_change.remove(self.sleepTimerEntryOnStateChange)
927                 self.session.nav.playService(self.currentService)
928                 containerStreamripper.dataAvail.remove(self.streamripperDataAvail)
929                 containerStreamripper.appClosed.remove(self.streamripperClosed)
930                 # fallback to earlier enigma versions FIXME Delete that when commiting
931                 try:
932                         config.plugins.internetradio.visualization.removeNotifier(self.visualizationConfigOnChange)
933                         config.plugins.internetradio.fullscreenautoactivation.removeNotifier(self.fullscreenautoactivationConfigOnChange)
934                         config.plugins.internetradio.fullscreenlayout.removeNotifier(self.fullscreenlayoutConfigOnChange)
935                 
936                 except:
937                         config.plugins.internetradio.visualization.notifiers.remove(self.visualizationConfigOnChange)
938                         config.plugins.internetradio.fullscreenautoactivation.notifiers.remove(self.fullscreenautoactivationConfigOnChange)
939                         config.plugins.internetradio.fullscreenlayout.notifiers.remove(self.fullscreenlayoutConfigOnChange)
940
941         def GoogleImageCallback(self, result):
942                 foundPos = result.find("imgres?imgurl=")
943                 foundPos2 = result.find("&amp;imgrefurl=")
944                 if foundPos != -1 and foundPos2 != -1:
945                         print "[InternetRadio] downloading cover from %s " % result[foundPos+14:foundPos2]
946                         downloadPage(result[foundPos+14:foundPos2] ,"/tmp/.cover").addCallback(self.coverDownloadFinished).addErrback(self.coverDownloadFailed)
947
948         def coverDownloadFailed(self,result):
949                 print "[InternetRadio] cover download failed: %s " % result
950                 self["cover"].hide()
951
952         def coverDownloadFinished(self,result):
953                 print "[InternetRadio] cover download finished"
954                 self["cover"].updateIcon("/tmp/.cover")
955
956         def coverLoaded(self):
957                 self["cover"].show()
958                 
959         def playServiceStream(self, url):
960                 self.musicPlayer.play(url)
961                 if self.currentPlayingStation:
962                         self.currentPlayingStation.url = url
963                         self["station"].setText(self.currentPlayingStation.name)
964                 self["title"].setText(_("Title: n/a"))
965
966         def createSummary(self):
967                 return InternetRadioOledDisplay
968
969         def getSelectedItem(self):
970                 sel = None
971                 try:
972                         sel = self["list"].l.getCurrentSelection()[0]
973                 except:return None
974                 return sel
975                 
976         def closePlayer(self):
977                 self.fullScreenKeyPressed()
978                 self.close()
979
980         def setStatusText(self, text, cleartimertime = 3000):
981                 self.clearStatusTextTimer.stop()
982                 self["statustext"].setText(text)
983                 self.clearStatusTextTimer.start(cleartimertime)
984
985         def clearStatusTextTimerCallback(self):
986                 self.clearStatusTextTimer.stop()
987                 self["statustext"].setText("")
988
989         # used from webinterface
990         def updateFullscreenStationName(self, stationname):
991                 if self.fullScreen.isVisible():
992                         self.fullScreen.setStation(stationname)
993
994         # used from webinterface
995         def getCurrentPlayingStation(self):
996                 if self.currentPlayingStation and self.currentPlayingStation.url != "":
997                         return (True, "%s - %s" % (self["station"].getText(), self["title"].getText()))
998                 else:
999                         return (False, _("nothing playing..."))
1000                 
1001         # used from webinterface
1002         def getStreamingInfos(self):
1003                 return self.musicPlayer.getMetaInfos()
1004
1005         # used from webinterface
1006         def updateFavoriteList(self):
1007                 if self.mode == self.FAVORITELIST:
1008                         index = self["list"].getCurrentIndex()
1009                         self.favoriteConfig.loadFavoriteConfig() # reload favorites
1010                         favoriteList = self.favoriteConfig.getFavoriteList()
1011                         self["list"].setList(favoriteList)
1012                         if len(favoriteList):
1013                                 self["list"].moveToIndex(index)
1014                 
1015 class InternetRadioFullScreen(Screen, InternetRadioVisualization):
1016
1017         sz_w = getDesktop(0).size().width()
1018         if sz_w == 1280:
1019
1020                 skin = """
1021                         <screen name="InternetRadioFullScreen" position="0,0" size="1280,720" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
1022                                 <widget name="station" position="50,120" zPosition="1" size="1180,20" font="Regular;18" transparent="1"  halign="center" foregroundColor="#356835" backgroundColor="#00000000"/>
1023                                 <widget name="title" position="50,550" zPosition="1" size="1180,80" font="Regular;22" transparent="1"  halign="center" foregroundColor="#4e9a4e" backgroundColor="#00000000"/>
1024                                 <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" />
1025                                 <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" />
1026                                 <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" />
1027                                 <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" />
1028                                 <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" />
1029                                 <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" />
1030                                 <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" />
1031                                 <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" />
1032                                 <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" />
1033                                 <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" />
1034                                 <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" />
1035                                 <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" />
1036                                 <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" />
1037                                 <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" />
1038                                 <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" />
1039                                 <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" />
1040                                 <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" />
1041                                 <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" />
1042                                 <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" />
1043                                 <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" />
1044                                 <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" />
1045                                 <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" />
1046                                 <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" />
1047                                 <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" />
1048                                 <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" />
1049                                 <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" />
1050                                 <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" />
1051                                 <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" />
1052                                 <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" />
1053                                 <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" />
1054                                 <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" />
1055                                 <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" />
1056                         </screen>"""
1057
1058         elif sz_w == 1024:
1059                 skin = """
1060                         <screen name="InternetRadioFullScreen" position="0,0" size="1024,576" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
1061                                 <widget name="station" position="50,120" zPosition="1" size="924,20" font="Regular;18" transparent="1"  halign="center" foregroundColor="#356835" backgroundColor="#00000000"/>
1062                                 <widget name="title" position="50,400" zPosition="1" size="924,80" font="Regular;22" transparent="1"  halign="center" foregroundColor="#4e9a4e" backgroundColor="#00000000"/>
1063                                 <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" />
1064                                 <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" />
1065                                 <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" />
1066                                 <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" />
1067                                 <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" />
1068                                 <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" />
1069                                 <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" />
1070                                 <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" />
1071                                 <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" />
1072                                 <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" />
1073                                 <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" />
1074                                 <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" />
1075                                 <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" />
1076                                 <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" />
1077                                 <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" />
1078                                 <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" />
1079                                 <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" />
1080                                 <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" />
1081                                 <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" />
1082                                 <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" />
1083                                 <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" />
1084                                 <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" />
1085                                 <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" />
1086                                 <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" />
1087                                 <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" />
1088                                 <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" />
1089                                 <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" />
1090                                 <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" />
1091                                 <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" />
1092                                 <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" />
1093                                 <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" />
1094                                 <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" />
1095                         </screen>"""
1096
1097
1098
1099                         
1100         else:
1101                 skin = """
1102                         <screen name="InternetRadioFullScreen" position="0,0" size="720,576" flags="wfNoBorder" backgroundColor="#00000000" title="InternetRadio">
1103                                 <widget name="station" position="50,120" zPosition="1" size="620,20" font="Regular;18" transparent="1"  halign="center" foregroundColor="#356835" backgroundColor="#00000000"/>
1104                                 <widget name="title" position="50,400" zPosition="1" size="620,80" font="Regular;22" transparent="1"  halign="center" foregroundColor="#4e9a4e" backgroundColor="#00000000"/>
1105                                 <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" />
1106                                 <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" />
1107                                 <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" />
1108                                 <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" />
1109                                 <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" />
1110                                 <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" />
1111                                 <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" />
1112                                 <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" />
1113                                 <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" />
1114                                 <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" />
1115                                 <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" />
1116                                 <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" />
1117                                 <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" />
1118                                 <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" />
1119                                 <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" />
1120                                 <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" />
1121                                 <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" />
1122                                 <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" />
1123                                 <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" />
1124                                 <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" />
1125                                 <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" />
1126                                 <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" />
1127                                 <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" />
1128                                 <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" />
1129                                 <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" />
1130                                 <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" />
1131                                 <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" />
1132                                 <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" />
1133                                 <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" />
1134                                 <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" />
1135                                 <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" />
1136                                 <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" />
1137                         </screen>"""
1138
1139
1140         def __init__(self, session):
1141                 self.session = session
1142                 Screen.__init__(self, session)
1143                 InternetRadioVisualization.__init__(self)
1144                 self["title"] =  Label("")
1145                 self["station"] = Label("")
1146                 self.onLayoutFinish.append(self.startRun)
1147                 self.visible = False
1148
1149         def startRun(self):
1150                 self.setProperties()
1151                 self.hideControls()
1152
1153         def setText(self, title):
1154                 self["title"].setText(title)
1155
1156         def setStation(self, station):
1157                 self["station"].setText(station)
1158
1159
1160         def setVisibility(self, visible):
1161                 if visible:
1162                         if config.plugins.internetradio.fullscreenlayout.value != "0":
1163                                 self.hideControls()
1164                         self.show()
1165                 else:
1166                         self.hide()
1167                 self.visible = visible
1168
1169         def isVisible(self):
1170                 return self.visible