Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Bron authored and Bastien Bron committed Sep 22, 2023
1 parent da6663c commit 51a62b6
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 43 deletions.
4 changes: 2 additions & 2 deletions borne/json_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<h2 class="section_title">MY NAME IS FUZZY</h2>
<img src="imgs/lamachine.png" />
<p>Cr&eacute;ation en cours !<br />
Ta chanson porte le num&eacute;ro</p>
Le Tube porte le num&eacute;ro</p>
<p class="big_number">#'.$song_id.'</p>
<p>Vous pouvez à présent vous diriger vers la machine.</p>';
<p>Poser le casque et se diriger vers la machine</p>';

echo '<script>
setTimeout(isFinished, 10000);
Expand Down
12 changes: 5 additions & 7 deletions machineatubes/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ def __load_tube(self, payload):
self.log("\t%s: %s" % (k, v))
for k, v in t.parts.items():
self.log("\t(%s) %s channel %s" % (k, v["name"], v["channel"]))

self.log("Signature : %s/%s" % (t.beat_time, t.beat_type))
self.log("%s BPM" % t.bpm)
self.log("%s measures" % t.measures)
self.log("duration %s s" % t.duration())

self.log("Received the song %s !" % t.name)

self.log("num %s, ambiance %s, style %s, prenom %s" % ( t.infos["numero"], t.infos["ambiance"],
t.infos["style"], t.infos["prenom"]))
self.log("de-id: %s" % t.infos["intro_video_url"].split("/")[-1])

self.play()

def load_score_file(self):
Expand Down Expand Up @@ -275,7 +273,7 @@ def main():
Tube.window = window
VideoNote.window = window
LyricsNote.window = window
webview.start(webview_cb, debug=True, private_mode=False, gui="qt")
webview.start(webview_cb, debug=True, private_mode=False)
exit(0)

if __name__ == "__main__":
Expand Down
12 changes: 7 additions & 5 deletions machineatubes/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ def parseJSON2Score(payload, verbose=False):

for note in notes:

b = int(note["beat"]) - 4
if len(note["text"]) > 0:
b = int(note["beat"]) - 4

if b > max_length:
max_length = b

if b > max_length:
max_length = b

score.lyricsnote(b, LyricsNote(note["text"].replace('"', ''),
position=note.get("position", False)))
score.lyricsnote(b, LyricsNote(note["text"].replace('"', ''),
position=note.get("position", False)))


score.measures = int(max_length / score.beat_type) + 1
Expand Down
6 changes: 3 additions & 3 deletions machineatubes/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
server = Flask(__name__, static_folder=base_dir / "ui" / "assets", template_folder=base_dir / "ui")
server.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 # disable caching

'''

@server.after_request
def add_header(response):
response.headers['Cache-Control'] = 'public, max-age=604800, no-transform, immutable'
response.headers['Cache-Control'] = 'public, no-cache, no-store, max-age=0'
response.headers['Expires'] = '0'
return response
'''

@server.route('/')
def machine():
Expand Down
24 changes: 14 additions & 10 deletions machineatubes/tube.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def __init__(self, name="noname") -> None:
self.divisions = 16
self.infos = {}
self.intro_video_url = None
self.videos = []

def duration(self):
'''
Expand Down Expand Up @@ -133,6 +134,8 @@ def videonote(self, beat, note):
note.beat = beat
notes = self.notes.get(beat, [])
self.notes.update( { beat: notes + [ note ] } )
if note.file not in self.videos:
self.videos.append(note.file)

def lyricsnote(self, beat, note):
note.beat = beat
Expand Down Expand Up @@ -170,17 +173,20 @@ def playintro(self):
pass

def play(self, window=False, verbose=False):
Tube.window.load_url('/')
videoend.clear()
Tube.playing = True
for v in self.videos:
Tube.window.evaluate_js("preloadvid('%s')" % (v))
if Tube.window:
Tube.window.evaluate_js('displayinfos("%s","%s","%s","%s","%s","%s")' %
(self.name, self.infos["numero"], self.infos["ambiance"], self.infos["style"], self.bpm, self.infos["prenom"]))
if self.infos.get("intro_video_url"):
Tube.window.evaluate_js('gointro("%s", "%s")' % (get_intro_video(), self.infos["intro_video_url"]))
Tube.window.evaluate_js('gointro("%s")' % (self.infos["intro_video_url"]))

self.gomachine()
print("wait playsong")
videoend.wait(60)
videoend.wait(30)
print("playsong !")
# send bpm control
self.stop()
Expand All @@ -201,10 +207,10 @@ def play(self, window=False, verbose=False):
videoend.clear()
self.stop()
self.applause()
time.sleep(3)

Tube.window.evaluate_js('gooutro("%s")' % get_outro_video())
print("END")
videoend.wait(60)
videoend.wait(30)
#attente
time.sleep(5)
self.stop()
Expand Down Expand Up @@ -266,10 +272,10 @@ def get_intro_video(self, id):
"Authorization": "Basic c2FsdXRAbXluYW1laXNmdXp6eS5jaA:N51ON3CPUu3QXeujqjDKr"}

try:
retry = 10
while retry > 0:
retry = 1
while retry <= 10:
print("trying d-id %s" % url)
time.sleep(10)
time.sleep(retry+1)
response = requests.get(url, headers=headers)

response = response.json()
Expand All @@ -287,7 +293,7 @@ def get_intro_video(self, id):
break

print("retrying... %s" % retry)
retry -= 1
retry += 1

except Exception as e:
print("INTRO VIDEO ERROR")
Expand Down Expand Up @@ -334,8 +340,6 @@ def __init__(self, file, position=None) -> None:
self.file = file
self.beat = 0
self.position = position or "video"
if VideoNote.window:
VideoNote.window.evaluate_js("preloadvid('%s')" % (self.file))

def play(self, i, verbose=False):
if i == self.beat:
Expand Down
Binary file modified ui/assets/img/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified ui/assets/videos/machine/intro/intro.mp4
Binary file not shown.
53 changes: 37 additions & 16 deletions ui/machine.html
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@

<div class="sleep"><img src="assets/img/logoinfos_90.png"></div>
<div class="loading"><img src="assets/img/loading_90.gif"></div>
<video id="introvideo" class="full" style="display:none;" ></video>
<video id="introvideo" src="assets/videos/machine/intro/intro.mp4" class="full" style="display:none;"></video>
<video id="dedicacevideo" class="rotated" style="display:none;"></video>
<video id="outrovideo" style="display:none;" ></video>
</div>
Expand All @@ -288,6 +288,7 @@

let video = document.querySelector("#video");
let intro_video = document.querySelector("#introvideo");
intro_video.load()
let outro_video = document.querySelector("#outrovideo");
let dedi_video = document.querySelector("#dedicacevideo");

Expand Down Expand Up @@ -319,11 +320,9 @@
});
}

var gointro = function(intro_url, dedi_url){
var gointro = function(dedi_url){
loaded()
wakeup()
intro_video.src = intro_url;
intro_video.currentTime = 0;
intro_video.play();
intro_video.style.display = "block";
const elems = document.querySelectorAll('.jingle');
Expand Down Expand Up @@ -356,14 +355,28 @@
vids.forEach(function(v){
v.style.display = "none";
});
clearclipvids();
intro_video.play();
intro_video.style.display = "block";
outro_video.src = outro_url;
outro_video.currentTime = 0;
outro_video.play();
outro_video.style.display = "block";
outro_video.addEventListener("ended", function(v){
outro_video.style.display = "none";
window.pywebview.api.videoend();
sleep();
outro_video.load();
const elems = document.querySelectorAll('.jingle');
elems.forEach(function(e){
e.style.display = "flex";
});
intro_video.addEventListener("ended", function(v){
const elems = document.querySelectorAll('.jingle');
elems.forEach(function(e){
e.style.display = "none";
});
intro_video.style.display = "none";
outro_video.play();
outro_video.style.display = "block";
outro_video.addEventListener("ended", function(v){
outro_video.style.display = "none";
window.pywebview.api.videoend();
sleep();
});
});
}

Expand Down Expand Up @@ -393,6 +406,7 @@
vid.src = source;
vid.muted = true;
vid.loop = true;
vid.classList.add("clipvid");
vid.style.position = "absolute";
vid.addEventListener("ended", function(e){
vid.style.display = "none";
Expand All @@ -404,10 +418,19 @@
vid.load();
vid.play();
vid.style.display="none";
console.log("loaded " + source);
}
};

var clearclipvids = function(){
const vids = document.querySelectorAll('video.clipvid');

vids.forEach(function(v){
v.pause();
v.src = "";
v.remove();
});
}

var playvid = function(source){
if(source == "") return;
const vids = document.querySelectorAll('video');
Expand All @@ -416,11 +439,9 @@
vids.forEach(function(v){
if(v!==vid) v.style.display = "none";
});
vid.style.display = "block";


vid.style.display = "block";
//vid.play();
//vid.currentTime = 0;
//vid.currentTime = 1;
//setTimeOut( function(){}, 200);
};

Expand Down

0 comments on commit 51a62b6

Please sign in to comment.