Example #1
0
 def toggleLed(self, isTurnedOn):
     if isTurnedOn:
         log("Turning led ON")
         GPIO.output(self.ledGPIO, GPIO.HIGH)
     else:
         log("Turning led OFF")
         GPIO.output(self.ledGPIO, GPIO.LOW)
Example #2
0
def buttonPressed():
    global isInitiallyMode
    log('Button pressed received from Main')
    if isInitiallyMode:
        isInitiallyMode = False
        player.play(allParts[0])
        button.toggleLed(True)
        return

    isPaused = player.pause()
    button.toggleLed(not isPaused)
Example #3
0
    def pause(self):
        if self.isPaused:
            pygame.mixer.music.unpause()
            self.isPaused = False
            log("UNPause")

            return self.isPaused
        else:
            pygame.mixer.music.pause()
            self.isPaused = True
            log("Pause")

            return self.isPaused
Example #4
0
def rewButtonPressed():
    global currentPartPlaying

    player.pause()

    if player.getPosition() > 60:
        log("Cofam do poczatku modulu")
        player.play(allParts[currentPartPlaying])
        button.toggleLed(True)
    else:
        log("Laduje poprzedni modul")
        currentPartPlaying -= 1
        player.play(allParts[currentPartPlaying])
        button.toggleLed(True)
Example #5
0
 def button_callback(self, channel):
     log('Some button pressed')
     self.callbackButtonPressed()
Example #6
0
 def rewind(self):
     pygame.mixer.music.rewind()
     log('rewind?')
Example #7
0
    def getPosition(self):
        position = round(pygame.mixer.music.get_pos() / 1000)

        log("Get position " + str(position) + "sec")
        return round(position)
Example #8
0
 def play(self, fileToPlay):
     pygame.mixer.music.set_endevent(self.bookPartEndEvent)
     pygame.mixer.music.load(THIS_FOLDER + "/../book/" + fileToPlay)
     pygame.mixer.music.play()
     self.isPaused = False
     log("Playing next part: " + fileToPlay)
Example #9
0
def loadNextPart():
    global currentPartPlaying
    print(currentPartPlaying)
    log('End of part: ' + str(currentPartPlaying))
    currentPartPlaying += 1
    player.play(allParts[currentPartPlaying])
Example #10
0
import pygame
from src.Player import Player
from src.Logger import loggerInit, log, error
from src.FilesManager import getAllFileNames
from src.Button import Button

BOOK_PART_END = pygame.USEREVENT + 1

loggerInit()
player = Player(BOOK_PART_END)
log("--- APP STARTED ---")

allParts = getAllFileNames()
log('Loaded parts' + ', '.join(allParts))
currentPartPlaying = 0
isInitiallyMode = True

if len(allParts) == 0:
    error("There is no book to play!")


def buttonPressed():
    global isInitiallyMode
    log('Button pressed received from Main')
    if isInitiallyMode:
        isInitiallyMode = False
        player.play(allParts[0])
        button.toggleLed(True)
        return

    isPaused = player.pause()