def doPlay(media): if "-sync" in network.get_hostname(): if "-master" in network.get_hostname(): player.getInterface('zyre').node.broadcast('/play', list(media), 200) print('doPLay: master.. broadcast') else: print('doPLay: slave.. do nothing') else: player.mute(True) time.sleep(0.1) player.play(media) time.sleep(0.05) player.mute(False)
from core.engine import hplayer from core.engine import network import os, platform # NAME playerName = network.get_hostname() # PLAYER player = hplayer.addplayer('mpv', playerName) # INTERFACES player.addInterface('http2', 8080) player.addInterface('osc', 1222, 3737) player.addInterface('keypad') player.addInterface('irremote') # ## HPOD (Régie Max) # is_RPi = platform.machine().startswith('armv') regie_ip = None # Overlay if is_RPi: player.addOverlay('rpifade') # OSC events def syncTest(): loop = "loop" if player.settings()['loop'] else "unloop"
def refresh(self): if self.activePage == PAGE_WELCOME: self.line(0, ' ') self.line(1, ' KXKM') self.line(2, '^1 RPi-Player') self.line(3, ' ') self.line(4, ' ') elif self.activePage == PAGE_EXIT: self.line(0, ' ') self.line(1, ' ') self.line(2, '^0 ^2Ngoodbye !') self.line(3, ' ') self.line(4, ' ') elif self.activePage == PAGE_STATUS: net = network.get_essid('wlan0') if net: net += ' '+str(network.get_rssi('wlan0'))+'%' else: net = 'NO-WIFI !' net = ' ^2P '+net z = self.hplayer.interface('zyre') if z: people = ' ^7C '+str(z.activeCount()) else: people = ' ' self.line(0, '^1 STATUS') self.line(1, net) self.line(2, people) self.line(3, 'name: '+network.get_hostname()) self.line(4, 'ip: '+network.get_ip('wlan0')) elif self.activePage == PAGE_PLAYBACK: player = self.hplayer.activePlayer() status = player.status() # Time & Media playstate = ' ' if player.isPlaying(): if status['media']: playstate = ' '+status['media'].split('/')[-1] # leading space : prevent digit display error # MUTE & Time mutestate = ' ^9JMUTE-VID ' if self.isFaded else ' ' if player.isPlaying(): mutestate += ( str( round(status['time']) )+'/'+str( round(status['duration']) )+'"').rjust(8) # PLAY cmdline = '^5K' if player.isPlaying(): cmdline = '^5D' if player.isPaused() else '^5E' cmdline += " " # LOOP if self.hplayer.settings('loop') == 1: cmdline += '^2O' elif self.hplayer.settings('loop') == 2: cmdline += '^6X' else: cmdline += '^3@' # VOLUME -/+ cmdline += " ^5P"+str(self.hplayer.settings('volume')).rjust(3)+" ^5O" # HEAD ind = min(self.hplayer.playlist.index()+1, self.hplayer.playlist.size()) headline = '^5M^1 ' + ( str(ind)+'/'+str(self.hplayer.playlist.size()) ) headline += ' '+self.dirPlayback headline = headline[:18].ljust(18) # headline += '^0 ^5O'+str(self.hplayer.settings('volume')).rjust(3) self.line(0, headline) self.line(1, mutestate) self.line(2, playstate) self.line(3, ' ') self.line(4, cmdline) elif self.activePage == PAGE_MEDIA: self.line(0, '^8C^1 '+self.hplayer.files.currentDir()) for k in range(4): l = '^6N' if k == self.microIndex else ' ' m = os.path.splitext(self.microList[k])[0] if k < len(self.microList) else '' self.line(k+1, l+m)
from core.engine import hplayer, network # EXTRA TMP UPLOAD import tempfile tempfile.tempdir = '/data/var/tmp' # PLAYER player = hplayer.addplayer('mpv', network.get_hostname()) player.doLog['events'] = True player.doLog['cmds'] = True # Interfaces player.addInterface('http', 8080) player.addInterface('http2', 80) player.addInterface('serial', "^CP2102") # SERIAL USB player.on(['RELOOP'], lambda: player.play("loop*.*")) # PATH hplayer.setBasePath(["/mnt/usb"]) hplayer.persistentSettings("/data/hplayer2-flipper.cfg") # DISABLE automations def disableAuto(settings): player.loop(False) player.autoplay(False) player.clear()
from core.engine.hplayer import HPlayer2 from core.engine import network import os, sys, types, platform import json # DIRECTORY / FILE profilename = os.path.basename(__file__).split('.')[0] projectfolder = os.path.join('/data/sync', profilename) devicename = network.get_hostname() devicefolder = os.path.join('/data/sync/solo', devicename) base_path = ['/data/usb', projectfolder, devicefolder] # INIT HPLAYER hplayer = HPlayer2(base_path) # PLAYERS video = hplayer.addPlayer('mpv', 'video') # audio = hplayer.addPlayer('mpv', 'audio') # ATTACHED ESP myESP = 0 try: with open(os.path.join(projectfolder, 'esp.json')) as json_file: data = json.load(json_file) if devicename in data:
from core.engine import hplayer, network import time # EXTRA TMP UPLOAD import tempfile tempfile.tempdir = '/data/var/tmp' # PLAYER player = hplayer.addplayer('mpv', network.get_hostname()) player.doLog['events'] = True player.doLog['cmds'] = True # Interfaces player.addInterface('http', 8080) player.addInterface('http2', 80) if hplayer.isRPi(): player.addInterface('gpio', [20, 21, 16, 14, 15, 26], 310) if "-sync" in network.get_hostname(): player.addInterface('zyre', 'wlan0') # Remove default stop at "end-playlist" (or it prevent the next play !) player.unbind('end-playlist', player.stop) # PLAY action def doPlay(media): if "-sync" in network.get_hostname(): if "-master" in network.get_hostname(): player.getInterface('zyre').node.broadcast('/play', list(media), 200) print('doPLay: master.. broadcast')