test + vumetre pixel rudimentaire
This commit is contained in:
10
README.md
10
README.md
@ -12,6 +12,7 @@ Projet / roadmap :
|
|||||||
- Possibilité de basculer entre radio / fichiers mp3 ?
|
- Possibilité de basculer entre radio / fichiers mp3 ?
|
||||||
- [lib phat beat](https://pypi.org/project/phatbeat/)
|
- [lib phat beat](https://pypi.org/project/phatbeat/)
|
||||||
|
|
||||||
|
|
||||||
2. téléchargement d'une playlist deezer
|
2. téléchargement d'une playlist deezer
|
||||||
|
|
||||||
- compte + profil deezer comme source de musique via [deezer-python](https://github.com/browniebroke/deezer-python) et/ou [pydeezer](https://github.com/Chr1st-oo/pydeezer)
|
- compte + profil deezer comme source de musique via [deezer-python](https://github.com/browniebroke/deezer-python) et/ou [pydeezer](https://github.com/Chr1st-oo/pydeezer)
|
||||||
@ -20,7 +21,14 @@ Projet / roadmap :
|
|||||||
3. interface web ?
|
3. interface web ?
|
||||||
- serveur / interface web permettant de piloter le lecteur + les téléchargements
|
- serveur / interface web permettant de piloter le lecteur + les téléchargements
|
||||||
|
|
||||||
|
## roadmap bis ?
|
||||||
|
|
||||||
A regarder ?
|
1. lecture de playlists locales (fichiers .m3u), possibilité de basculer d'une playlist à la suivante avec le bouton on/off ?
|
||||||
|
2. construction de playlist de fichiers locaux par scan d'un dossier
|
||||||
|
3. interface web pour construire des playlists, depuis fichier local et/ou deezer etc ?
|
||||||
|
|
||||||
|
## A regarder ?
|
||||||
|
|
||||||
- https://pad.p2p.legal/s/rec-machine
|
- https://pad.p2p.legal/s/rec-machine
|
||||||
|
- [creation de playlist .m3u avec python](https://github.com/TaylorMonacelli/python-create-m3u-playlist-from-directory/blob/master/main.py)
|
||||||
|
-
|
||||||
|
@ -31,6 +31,12 @@ class FolderPlayer:
|
|||||||
def pause(self):
|
def pause(self):
|
||||||
self.list_player.pause()
|
self.list_player.pause()
|
||||||
|
|
||||||
|
def play_pause(self):
|
||||||
|
if self.list_player.is_playing():
|
||||||
|
self.pause()
|
||||||
|
else:
|
||||||
|
self.play()
|
||||||
|
|
||||||
def next(self):
|
def next(self):
|
||||||
self.list_player.next()
|
self.list_player.next()
|
||||||
self.display_title()
|
self.display_title()
|
||||||
|
111
test.py
111
test.py
@ -1,47 +1,86 @@
|
|||||||
import os, random, vlc, phatbeat, time, signal
|
import phatbeat, signal
|
||||||
|
from folderplayer import FolderPlayer
|
||||||
|
|
||||||
|
player = FolderPlayer("/home/jducastel/music")
|
||||||
|
|
||||||
class VLCdriver():
|
def show_volume(volume):
|
||||||
|
phatbeat.clear()
|
||||||
def __init__(self):
|
level = round(volume*8/100); print(f"level {level}")
|
||||||
self.files = []
|
for i in range(0,8): # resetting
|
||||||
self.vlc_instance = vlc.Instance()
|
if level > i:
|
||||||
self.vlc_player = self.vlc_instance.media_player_new()
|
phatbeat.set_pixel(7-i, 128,128,128,channel=0)
|
||||||
self.is_playing = False
|
phatbeat.set_pixel(7-i, 128,128,128,channel=1)
|
||||||
|
phatbeat.show()
|
||||||
def load_folder(self, folder):
|
|
||||||
# get list of files in music_dir
|
|
||||||
self.files = [ os.path.join(folder, f) for f in os.listdir(folder) if os.path.isfile(os.path.join(folder,f)) and f.endswith('.mp3') ]
|
|
||||||
print(f"loaded {folder}")
|
|
||||||
|
|
||||||
def play_file(self, path):
|
|
||||||
print(f"playing {path}")
|
|
||||||
self.media = self.vlc_instance.media_new(path)
|
|
||||||
self.vlc_player.set_media(self.media)
|
|
||||||
self.vlc_player.play()
|
|
||||||
self.is_playing = True
|
|
||||||
|
|
||||||
def play_random(self):
|
|
||||||
path = random.choice(self.files)
|
|
||||||
self.play_file(path)
|
|
||||||
|
|
||||||
@phatbeat.on(phatbeat.BTN_FASTFWD)
|
@phatbeat.on(phatbeat.BTN_FASTFWD)
|
||||||
def fast_forward(pin):
|
def fast_forward(pin):
|
||||||
self.play_random()
|
global player
|
||||||
time.sleep(1)
|
player.next()
|
||||||
|
|
||||||
|
|
||||||
|
# @phatbeat.hold(phatbeat.BTN_FASTFWD, hold_time=2)
|
||||||
|
# def hold_fast_forward(pin):
|
||||||
|
# print("FF Held")
|
||||||
|
|
||||||
|
|
||||||
@phatbeat.on(phatbeat.BTN_PLAYPAUSE)
|
@phatbeat.on(phatbeat.BTN_PLAYPAUSE)
|
||||||
def play_pause(pin):
|
def play_pause(pin):
|
||||||
if self.is_playing:
|
global player
|
||||||
self.player.stop()
|
player.play_pause()
|
||||||
self.is_playing = False
|
|
||||||
else:
|
|
||||||
self.player.play()
|
|
||||||
self.is_playing = True
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
|
|
||||||
d = VLCdriver()
|
# @phatbeat.hold(phatbeat.BTN_PLAYPAUSE, hold_time=2)
|
||||||
d.load_folder('/home/jducastel/music/')
|
# def hold_play_pause(pin):
|
||||||
d.play_random()
|
# print("PP Held")
|
||||||
|
|
||||||
|
|
||||||
|
@phatbeat.on(phatbeat.BTN_VOLUP)
|
||||||
|
def volume_up(pin):
|
||||||
|
global player
|
||||||
|
player.volume_up(12)
|
||||||
|
show_volume(player.get_volume())
|
||||||
|
|
||||||
|
# @phatbeat.hold(phatbeat.BTN_VOLUP)
|
||||||
|
# def hold_volume_up(pin):
|
||||||
|
# print("VU Held")
|
||||||
|
|
||||||
|
|
||||||
|
@phatbeat.on(phatbeat.BTN_VOLDN)
|
||||||
|
def volume_down(pin):
|
||||||
|
global player
|
||||||
|
player.volume_down(12)
|
||||||
|
show_volume(player.get_volume())
|
||||||
|
|
||||||
|
# @phatbeat.hold(phatbeat.BTN_VOLDN)
|
||||||
|
# def hold_volume_down(pin):
|
||||||
|
# print("VD Held")
|
||||||
|
|
||||||
|
|
||||||
|
@phatbeat.on(phatbeat.BTN_REWIND)
|
||||||
|
def rewind(pin):
|
||||||
|
global player
|
||||||
|
player.previous()
|
||||||
|
|
||||||
|
|
||||||
|
# @phatbeat.hold(phatbeat.BTN_REWIND)
|
||||||
|
# def hold_rewind(btn):
|
||||||
|
# print("RR Held")
|
||||||
|
|
||||||
|
|
||||||
|
# @phatbeat.on(phatbeat.BTN_ONOFF)
|
||||||
|
# def onoff(pin):
|
||||||
|
# print("OO Pressed")
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# @phatbeat.hold(phatbeat.BTN_ONOFF)
|
||||||
|
# def hold_onoff(pin):
|
||||||
|
# print("OO Held")
|
||||||
|
|
||||||
|
try:
|
||||||
|
player.play()
|
||||||
|
player.set_volume(24)
|
||||||
|
show_volume(player.get_volume())
|
||||||
signal.pause()
|
signal.pause()
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("bye !")
|
||||||
|
exit()
|
||||||
|
Reference in New Issue
Block a user