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