示例#1
0
def handle_request(reader, writer):
    request = yield from reader.read()
    method, url, *_ = request.decode('utf-8').split(' ')

    path, parameters = parse_url(url)
    if path.startswith("/folder"):
        folder = parameters.get("folder", 1)
        mp3.play_folder(int(folder))
    elif path.startswith("/play"):
        track = parameters.get("track", 1)
        mp3.play_track(int(track))
    elif path.startswith("/next"):
        mp3.next()
    elif path.startswith("/prev"):
        mp3.previous()
    elif path.startswith("/resume"):
        mp3.resume()
    elif path.startswith("/pause"):
        mp3.pause()

    yield from writer.awrite(
        'HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n'
    )
    with open('index.html') as f:
        for line in f:
            yield from writer.awrite(line)

    yield from writer.aclose()
示例#2
0
def pause_play():
  mp3.pause()
  return "Paused"
示例#3
0
 def pause(self):
     mp3.pause()
     _debug("pause")
     self.status = self.PAUSED
     self.led.off()
示例#4
0
import machine
import socket
import ure
import mp3
import time
from machine import Pin

lvlDark = 3  # At which level of light the music should not play
playVol = 12  #12 Define how loud should the music play
bsy = Pin(0, Pin.IN)
brght = machine.ADC(0)
snsMove = Pin(5, Pin.IN)
brnow, br1, br2, br3, br4, br5, br6, br7, br8, br9, br10 = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

mp3.set_volume(playVol)
mp3.pause()

while True:
    br1 = br2
    br2 = br3
    br3 = br4
    br4 = br5
    br5 = br6
    br6 = br7
    br7 = br8
    br8 = br9
    br9 = br10
    try:
        br10 = brght.read()
        brnow = int(
            (br1 + br2 + br3 + br4 + br5 + br6 + br7 + br8 + br9 + br10) / 10)