Browse Source

fix js & set volume

master
欧醚 3 years ago
parent
commit
89128aba42
4 changed files with 46 additions and 6 deletions
  1. +12
    -0
      app.py
  2. +16
    -0
      static/index.css
  3. +7
    -6
      static/index.js
  4. +11
    -0
      templates/homepage.html

+ 12
- 0
app.py View File

@ -149,6 +149,18 @@ def new_channel():
return redirect('.?cid=' + cid)
@app.route('/call/api/user/<int:uid>')
@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():

+ 16
- 0
static/index.css View File

@ -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;
}

+ 7
- 6
static/index.js View File

@ -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));

+ 11
- 0
templates/homepage.html View File

@ -77,6 +77,17 @@
)
<a href="logout" class="logout-link">退出重新登录</a>
</p>
<div id="local-volume">
<label>发言音量:</label>
0%
<input type="range" id="local-volume-range" min="0" max="30" step="0.1" value="10" list="Z">
<datalist id="Z">
<option>10</option>
<option>0</option>
<option>30</option>
</datalist>
300%
</div>
<progress value="0" max="1"></progress>
</div>
<div id="remote-playerlist">

Loading…
Cancel
Save