Esempio n. 1
0
 def setVolume(self, action):
     try:
         operator = None
         if action == "down":
             self.loud = True
             operator = "-"
         elif action == "up":
             self.loud = False
             operator = "+"
         if operator:
             volume = xbmc.getInfoLabel("Player.Volume").replace(",", ".")
             downvolume = int(
                 float(Addon.getSetting("downvolume")) * 60.0 / 100.0)
             formula = "int((60+%s%s%s)*(100/60.0))" % (
                 volume.split(" ")[0], operator, str(downvolume))
             vol = eval(formula)
             if vol > 100: vol = 100
             elif vol < 0: vol = 0
             xbmc.executebuiltin('XBMC.SetVolume(%d)' % vol)
             xbmc.sleep(100)
             LOGGER.debug.LOG(
                 "SetVolume: %s to %s, Formula: %s" %
                 (volume, xbmc.getInfoLabel("Player.Volume"), formula))
     except:
         LOGGER.error.print_exc()
Esempio n. 2
0
 def showLogo(self):
     try:
         # skinner test
         try:
             WINDOW_VIDEO_NAV.removeControl(self.logo)
         except:
             pass
         if IsTrue(Addon.getSetting("showlogo")) or IsTrue(
                 Addon.getSetting("showlogo2")):
             size = int(float(Addon.getSetting("logosize")))
             posx = int(float(Addon.getSetting("logoposx")))
             posy = int(float(Addon.getSetting("logoposy")))
             if size + posx > 1280: posx = 1280 - size
             if size + posy > 720: posy = 720 - size
             self.logo = xbmcgui.ControlImage(posx,
                                              posy,
                                              size,
                                              size,
                                              Addon.getAddonInfo("icon"),
                                              aspectRatio=2)
             prop = ("Running",
                     "Alive")[IsTrue(Addon.getSetting("showlogo2"))]
             WINDOW_VIDEO_NAV.addControl(self.logo)
             self.logo.setVisibleCondition(
                 '!IsEmpty(Window(10025).Property(TvTunesIs%s))' % prop)
             self.logo.setAnimations([('Visible', 'effect=fade time=300'),
                                      ('Hidden', 'effect=fade time=300')])
     except:
         LOGGER.error.print_exc()
Esempio n. 3
0
 def setVolume( self, action ):
     try:
         operator = None
         if action == "down":
             self.loud = True
             operator  = "-"
         elif action == "up":
             self.loud = False
             operator  = "+"
         if operator:
             volume = xbmc.getInfoLabel( "Player.Volume" ).replace( ",", "." )
             downvolume = int( float( Addon.getSetting( "downvolume" ) ) * 60.0 / 100.0 )
             formula = "int((60+%s%s%s)*(100/60.0))" % ( volume.split( " " )[ 0 ], operator, str( downvolume ) )
             vol = eval( formula )
             if vol > 100 : vol = 100
             elif vol < 0 : vol = 0
             xbmc.executebuiltin( 'XBMC.SetVolume(%d)' % vol )
             xbmc.sleep( 100 )
             LOGGER.debug.LOG( "SetVolume: %s to %s, Formula: %s" % ( volume, xbmc.getInfoLabel( "Player.Volume" ), formula ) )
     except:
         LOGGER.error.print_exc()
Esempio n. 4
0
 def showLogo( self ):
     try:
         # skinner test
         try: WINDOW_VIDEO_NAV.removeControl( self.logo )
         except: pass
         if IsTrue( Addon.getSetting( "showlogo" ) ) or IsTrue( Addon.getSetting( "showlogo2" ) ):
             size = int( float( Addon.getSetting( "logosize" ) ) )
             posx = int( float( Addon.getSetting( "logoposx" ) ) )
             posy = int( float( Addon.getSetting( "logoposy" ) ) )
             if size + posx > 1280: posx = 1280 - size
             if size + posy > 720:  posy = 720 - size
             self.logo = xbmcgui.ControlImage( posx, posy, size, size, Addon.getAddonInfo( "icon" ), aspectRatio=2 )
             prop = ( "Running", "Alive" )[ IsTrue( Addon.getSetting( "showlogo2" ) ) ]
             WINDOW_VIDEO_NAV.addControl( self.logo )
             self.logo.setVisibleCondition( '!IsEmpty(Window(10025).Property(TvTunesIs%s))' % prop )
             self.logo.setAnimations( [ ( 'Visible', 'effect=fade time=300' ), ( 'Hidden', 'effect=fade time=300' ) ] )
     except:
         LOGGER.error.print_exc()
Esempio n. 5
0
    def run(self):
        try:
            LOGGER.notice.LOG("initialized Player took %s",
                              time_took(START_TIME))
            self.refresh_container = False
            while (not self._stop):
                self._stop = xbmc.abortRequested
                if xbmc.getCondVisibility(CONDITION_STOP_TUNES_PLAYER):
                    self.stopTunesPlayer()

                #if xbmc.getCondVisibility( "!IsEmpty(ListItem.Path) + !StringCompare(ListItem.Path,%s/)" % os.path.dirname( self.playpath ) ):
                #    print repr( xbmc.getInfoLabel( "ListItem.Path" ) + THEME_FILE )

                if xbmc.getCondVisibility(CONDITION_PLAY_TUNE):
                    TVShowTitle = _unicode(
                        xbmc.getInfoLabel("ListItem.TVShowTitle")
                        or xbmc.getInfoLabel("Container.FolderName"))
                    if TVShowTitle and CONTAINER.has_key(TVShowTitle):
                        listitem = CONTAINER[TVShowTitle]
                        #default tune
                        tune = listitem.getProperty("tune")
                        if tune and tune != self.playpath:
                            if not self.isPlaying():
                                self._play(tune, listitem)
                                xbmc.sleep(100)
                            else:
                                LOGGER.debug.LOG("player already playing")

                #if xbmc.getCondVisibility( CONDITION_TUNE_ENDED ):
                if self.isAlive and not self.isPlaying() or IsTrue(
                        WINDOW_VIDEO_NAV.getProperty(
                            'TvTunesIsAlive')) and not self.isPlaying():
                    LOGGER.debug.LOG("playing ends")
                    if self.loud:
                        self.setVolume("up")
                    WINDOW_VIDEO_NAV.clearProperty('TvTunesIsAlive')
                    self.isAlive = False

                if self.playpath and xbmc.getCondVisibility(
                        CONDITION_REINIT_TUNES_PLAYER):
                    LOGGER.debug.LOG("stop playing")
                    self.stop()
                    if self.loud:
                        self.setVolume("up")
                    LOGGER.debug.LOG("reinit condition")
                    self.initialize()

                time.sleep(.5)

                if xbmc.getCondVisibility(CONDITION_REFRESH_CONTAINER):
                    self.refresh_container = True
                elif self.refresh_container:
                    #refresh container
                    globals().update({"CONTAINER": getTVShows("dict", True)})
                    # reload Addon objet
                    from common import Addon
                    globals().update({"Addon": Addon})
                    # reset refresh status
                    self.refresh_container = False
                    if Addon.getSetting("useplayerv2").lower() == "false":
                        #change player
                        self.stopTunesPlayer(True)
                    else:
                        # set again logo for change
                        self.showLogo()
        except SystemExit:
            LOGGER.warning.LOG("SystemExit! xbmc.abortRequested(%r)" %
                               xbmc.abortRequested)
            self.stopTunesPlayer()
        except:
            LOGGER.error.print_exc()
            self.stopTunesPlayer()
Esempio n. 6
0
    def run( self ):
        try:
            LOGGER.notice.LOG( "initialized Player took %s", time_took( START_TIME ) )
            self.refresh_container = False
            while ( not self._stop ):
                self._stop = xbmc.abortRequested
                if xbmc.getCondVisibility( CONDITION_STOP_TUNES_PLAYER ):
                    self.stopTunesPlayer()

                #if xbmc.getCondVisibility( "!IsEmpty(ListItem.Path) + !StringCompare(ListItem.Path,%s/)" % os.path.dirname( self.playpath ) ):
                #    print repr( xbmc.getInfoLabel( "ListItem.Path" ) + THEME_FILE )

                if xbmc.getCondVisibility( CONDITION_PLAY_TUNE ):
                    TVShowTitle = _unicode( xbmc.getInfoLabel( "ListItem.TVShowTitle" ) or xbmc.getInfoLabel( "Container.FolderName" ) )
                    if TVShowTitle and CONTAINER.has_key( TVShowTitle ):
                        listitem = CONTAINER[ TVShowTitle ]
                        #default tune
                        tune = listitem.getProperty( "tune" )
                        if tune and tune != self.playpath:
                            if not self.isPlaying():
                                self._play( tune, listitem )
                                xbmc.sleep( 100 )
                            else:
                                LOGGER.debug.LOG( "player already playing" )

                #if xbmc.getCondVisibility( CONDITION_TUNE_ENDED ):
                if self.isAlive and not self.isPlaying() or IsTrue( WINDOW_VIDEO_NAV.getProperty( 'TvTunesIsAlive' ) ) and not self.isPlaying():
                    LOGGER.debug.LOG( "playing ends" )
                    if self.loud:
                        self.setVolume( "up" )
                    WINDOW_VIDEO_NAV.clearProperty( 'TvTunesIsAlive' )
                    self.isAlive = False

                if self.playpath and xbmc.getCondVisibility( CONDITION_REINIT_TUNES_PLAYER ):
                    LOGGER.debug.LOG( "stop playing" )
                    self.stop()
                    if self.loud:
                        self.setVolume( "up" )
                    LOGGER.debug.LOG( "reinit condition" )
                    self.initialize()

                time.sleep( .5 )

                if xbmc.getCondVisibility( CONDITION_REFRESH_CONTAINER ):
                    self.refresh_container = True
                elif self.refresh_container:
                    #refresh container
                    globals().update( { "CONTAINER": getTVShows( "dict", True ) } )
                    # reload Addon objet
                    from common import Addon
                    globals().update( { "Addon": Addon } )
                    # reset refresh status
                    self.refresh_container = False
                    if Addon.getSetting( "useplayerv2" ).lower() == "false":
                        #change player
                        self.stopTunesPlayer( True )
                    else:
                        # set again logo for change
                        self.showLogo()
        except SystemExit:
            LOGGER.warning.LOG( "SystemExit! xbmc.abortRequested(%r)" % xbmc.abortRequested )
            self.stopTunesPlayer()
        except:
            LOGGER.error.print_exc()
            self.stopTunesPlayer()