| 1 |
import xbmc, xbmcgui |
| 2 |
from libpandora.pandora import Pandora |
| 3 |
|
| 4 |
KEY_BUTTON_BACK = 275 |
| 5 |
KEY_KEYBOARD_ESC = 61467 |
| 6 |
|
| 7 |
ACTION_PARENT_DIR = 9 |
| 8 |
ACTION_PREVIOUS_MENU = 10 |
| 9 |
ACTION_NEXT_ITEM = 14 |
| 10 |
ACTION_NAV_BACK = 92 |
| 11 |
|
| 12 |
BTN_THUMB_DN = 330 |
| 13 |
BTN_THUMB_UP = 331 |
| 14 |
BTN_PLAY_PAUSE = 332 |
| 15 |
BTN_SKIP = 333 |
| 16 |
BTN_INFO = 334 |
| 17 |
BTN_HIDE = 335 |
| 18 |
|
| 19 |
BTN_TIRED = 336 |
| 20 |
BTN_THUMBED_DN = 337 |
| 21 |
BTN_THUMBED_UP = 338 |
| 22 |
|
| 23 |
class PandaGUI(xbmcgui.WindowXMLDialog): |
| 24 |
|
| 25 |
def setPanda( self, panda ): |
| 26 |
self.panda = panda |
| 27 |
|
| 28 |
def onInit(self): |
| 29 |
print "PANDORA: Window Initalized!!!" |
| 30 |
self.list = self.getControl(200) |
| 31 |
dlg = xbmcgui.DialogProgress() |
| 32 |
dlg.create( "PANDORA", "Fetching Stations" ) |
| 33 |
dlg.update( 0 ) |
| 34 |
for s in self.panda.getStations(): |
| 35 |
tmp = xbmcgui.ListItem(s["stationName"]) |
| 36 |
tmp.setProperty( "stationId", s["stationId"] ) |
| 37 |
self.list.addItem(tmp) |
| 38 |
dlg.close() |
| 39 |
self.getControl(BTN_THUMBED_DN).setVisible(False) |
| 40 |
self.getControl(BTN_THUMBED_UP).setVisible(False) |
| 41 |
|
| 42 |
logo = self.getControl(100) |
| 43 |
if self.panda.settings.getSetting( "logoSize" ) == "false": |
| 44 |
logo.setPosition(-100, -100) |
| 45 |
|
| 46 |
def onAction(self, action): |
| 47 |
buttonCode = action.getButtonCode() |
| 48 |
actionID = action.getId() |
| 49 |
if ( actionID in ( ACTION_PREVIOUS_MENU, ACTION_NAV_BACK, \ |
| 50 |
ACTION_PARENT_DIR ) ): |
| 51 |
if xbmc.getCondVisibility( 'Skin.HasSetting(PandoraVis)' ): |
| 52 |
xbmc.executebuiltin( 'Skin.Reset(PandoraVis)' ) |
| 53 |
#xbmc.executebuiltin( "SetProperty(HidePlayer,False)" ) |
| 54 |
else: |
| 55 |
self.panda.quit() |
| 56 |
|
| 57 |
|
| 58 |
elif (actionID == ACTION_NEXT_ITEM ): |
| 59 |
self.panda.skipSong() |
| 60 |
|
| 61 |
def onClick(self, controlID): |
| 62 |
if (controlID == 200): #List Item |
| 63 |
selItem = self.list.getSelectedItem() |
| 64 |
self.panda.playStation( selItem.getProperty("stationId") ) |
| 65 |
elif self.panda.playing: |
| 66 |
if controlID == BTN_THUMB_DN: |
| 67 |
self.getControl(BTN_THUMB_DN).setVisible(False) |
| 68 |
self.getControl(BTN_THUMBED_DN).setVisible(True) |
| 69 |
self.getControl(BTN_THUMB_UP).setVisible(True) |
| 70 |
self.getControl(BTN_THUMBED_UP).setVisible(False) |
| 71 |
self.panda.addFeedback( False ) |
| 72 |
self.panda.playNextSong() |
| 73 |
elif controlID == BTN_THUMB_UP: |
| 74 |
self.getControl(BTN_THUMB_DN).setVisible(True) |
| 75 |
self.getControl(BTN_THUMBED_DN).setVisible(False) |
| 76 |
self.getControl(BTN_THUMB_UP).setVisible(False) |
| 77 |
self.getControl(BTN_THUMBED_UP).setVisible(True) |
| 78 |
self.panda.addFeedback( True ) |
| 79 |
elif controlID == BTN_PLAY_PAUSE: |
| 80 |
pass #Handled by skin currently, further functionality TBD |
| 81 |
elif controlID == BTN_SKIP: |
| 82 |
self.panda.playNextSong() |
| 83 |
elif controlID == BTN_INFO: |
| 84 |
pass #TODO |
| 85 |
elif controlID == BTN_TIRED: |
| 86 |
#obj = self.getControl(BTN_TIRED) |
| 87 |
#for attr in dir(obj): |
| 88 |
# print ">>> obj.%s = %s" % (attr, getattr(obj, attr)) |
| 89 |
self.panda.addTiredSong() |
| 90 |
self.panda.playNextSong() |
| 91 |
elif controlID == BTN_HIDE: |
| 92 |
pass #Handled by skin |
| 93 |
|
| 94 |
def onFocus(self, controlID): |
| 95 |
pass |