From 89128aba425829c84e17e56469eb36b4e3b2be07 Mon Sep 17 00:00:00 2001
From: Tdxdxoz
Date: Sat, 10 Apr 2021 23:05:10 +0800
Subject: [PATCH] fix js & set volume
---
app.py | 12 ++++++++++++
static/index.css | 16 ++++++++++++++++
static/index.js | 13 +++++++------
templates/homepage.html | 11 +++++++++++
4 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/app.py b/app.py
index 7540208..5257b37 100644
--- a/app.py
+++ b/app.py
@@ -149,6 +149,18 @@ def new_channel():
return redirect('.?cid=' + cid)
+@app.route('/call/api/user/')
+@login_required
+def user_info(uid):
+ user = User.query.get(uid)
+ if not user:
+ abort(404)
+ return {
+ key: getattr(user, key)
+ for key in ('acct', 'disp', 'avat', 'url')
+ }
+
+
@app.route('/call/auth')
@limiter.limit("10 / hour")
def auth():
diff --git a/static/index.css b/static/index.css
index ec3eb56..81c9a01 100644
--- a/static/index.css
+++ b/static/index.css
@@ -22,6 +22,22 @@ progress {
width: 90%;
}
+#local-volume {
+ display: flex;
+ width: 90%;
+ margin-bottom: 10px;
+}
+
+#local-volume input {
+ flex: auto;
+ margin: 0 8px;
+}
+
+#local-volume label {
+ flex: 0 0 auto;
+ margin-right: 15px;
+}
+
img {
vertical-align: sub;
}
diff --git a/static/index.js b/static/index.js
index 294a1ee..72be570 100644
--- a/static/index.js
+++ b/static/index.js
@@ -15,7 +15,12 @@ var options = {
$('.leave-btn').hide();
-$(".join-form").submit(async function (e) {
+$('#local-volume-range').on('input change', function() {
+ if (localTracks.audioTrack)
+ localTracks.audioTrack.setVolume(Math.floor($(this).val()**2));
+});
+
+$('.join-form').submit(async function (e) {
e.preventDefault();
console.log('ookkkk', this, $(this));
console.log($(this).serializeArray());
@@ -28,7 +33,6 @@ $(".join-form").submit(async function (e) {
try {
await join();
$('.u-cnt').hide();
- alert("加入成功!");
} catch (error) {
console.error(error);
alert('出错啦\n' + error);
@@ -59,10 +63,7 @@ async function join() {
AgoraRTC.createMicrophoneAudioTrack(),
]);
- localTracks.audioTrack.intervalId = window.setInterval(set_soundmeter, 25, '#local-player progress', localTracks.audioTrack);
-
- // play local audio track
- localTracks.audioTrack.play();
+ localTracks.audioTrack.intervalId = window.setInterval(set_soundmeter, 250, '#local-player progress', localTracks.audioTrack);
// publish local tracks to channel
await client.publish(Object.values(localTracks));
diff --git a/templates/homepage.html b/templates/homepage.html
index 80b675e..6800859 100644
--- a/templates/homepage.html
+++ b/templates/homepage.html
@@ -77,6 +77,17 @@
)
退出重新登录
+
+
+ 0%
+
+
+ 300%
+