| 1 |
import xbmc, xbmcgui |
| 2 |
from libpandora.pandora import Pandora |
| 3 |
|
| 4 |
KEY_BUTTON_BACK = 275 |
| 5 |
KEY_KEYBOARD_ESC = 61467 |
| 6 |
|
| 7 |
ACTION_PREVIOUS_MENU = 10 |
| 8 |
ACTION_NEXT_ITEM = 14 |
| 9 |
|
| 10 |
BTN_THUMB_DN = 330 |
| 11 |
BTN_THUMB_UP = 331 |
| 12 |
BTN_PLAY_PAUSE = 332 |
| 13 |
BTN_SKIP = 333 |
| 14 |
BTN_INFO = 334 |
| 15 |
BTN_HIDE = 335 |
| 16 |
|
| 17 |
class PandaGUI(xbmcgui.WindowXMLDialog): |
| 18 |
def __init__(self,strXMLname, strFallbackPath,strDefaultName,strRes,bforeFallback=0,panda=None): |
| 19 |
xbmcgui.WindowXMLDialog.__init__( self, strXMLname, strFallbackPath, strDefaultName, strRes) |
| 20 |
self.panda = panda |
| 21 |
|
| 22 |
def onInit(self): |
| 23 |
print "PANDORA: Window Initalized!!!" |
| 24 |
self.list = self.getControl(200) |
| 25 |
dlg = xbmcgui.DialogProgress() |
| 26 |
dlg.create( "PANDORA", "Fetching Stations" ) |
| 27 |
dlg.update( 0 ) |
| 28 |
for s in self.panda.getStations(): |
| 29 |
tmp = xbmcgui.ListItem(s["stationName"]) |
| 30 |
tmp.setProperty( "stationId", s["stationId"] ) |
| 31 |
self.list.addItem(tmp) |
| 32 |
dlg.close() |
| 33 |
|
| 34 |
def onAction(self, action): |
| 35 |
buttonCode = action.getButtonCode() |
| 36 |
actionID = action.getId() |
| 37 |
if (actionID == ACTION_PREVIOUS_MENU ): |
| 38 |
if xbmc.getCondVisibility( 'Skin.HasSetting(PandoraVis)' ): |
| 39 |
xbmc.executebuiltin( 'Skin.Reset(PandoraVis)' ) |
| 40 |
#xbmc.executebuiltin( "SetProperty(HidePlayer,False)" ) |
| 41 |
else: |
| 42 |
self.panda.quit() |
| 43 |
|
| 44 |
|
| 45 |
elif (actionID == ACTION_NEXT_ITEM ): |
| 46 |
self.panda.skipSong() |
| 47 |
|
| 48 |
def onClick(self, controlID): |
| 49 |
if (controlID == 200): #List Item |
| 50 |
selItem = self.list.getSelectedItem() |
| 51 |
self.panda.playStation( selItem.getProperty("stationId") ) |
| 52 |
elif self.panda.playing: |
| 53 |
if controlID == BTN_THUMB_DN: |
| 54 |
pass #TODO |
| 55 |
elif controlID == BTN_THUMB_UP: |
| 56 |
pass #TODO |
| 57 |
elif controlID == BTN_PLAY_PAUSE: |
| 58 |
pass #Handled by skin currently, further functionality TBD |
| 59 |
elif controlID == BTN_SKIP: |
| 60 |
self.panda.playNextSong() |
| 61 |
elif controlID == BTN_INFO: |
| 62 |
pass #TODO |
| 63 |
elif controlID == BTN_HIDE: |
| 64 |
pass #Handled by skin |
| 65 |
|
| 66 |
def onFocus(self, controlID): |
| 67 |
pass |