Skip to content

Commit 3b3b279

Browse files
committed
updates sample app to add hasAudio, hasVideo and outputMode
1 parent 575fdb1 commit 3b3b279

File tree

3 files changed

+45
-5
lines changed

3 files changed

+45
-5
lines changed

sample/Archiving/archiving.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from flask import Flask, render_template, request, redirect, url_for
2-
from opentok import OpenTok, MediaModes
2+
from opentok import OpenTok, MediaModes, OutputModes
33
from email.utils import formatdate
44
import os, time
55

@@ -52,9 +52,13 @@ def download(archive_id):
5252
archive = opentok.get_archive(archive_id)
5353
return redirect(archive.url)
5454

55-
@app.route("/start")
55+
@app.route("/start", methods=['POST'])
5656
def start():
57-
archive = opentok.start_archive(session.session_id, name="Python Archiving Sample App")
57+
has_audio = 'hasAudio' in request.form.keys()
58+
has_video = 'hasVideo' in request.form.keys()
59+
output_mode = OutputModes[request.form.get('outputMode')]
60+
archive = opentok.start_archive(session.session_id, name="Python Archiving Sample App",
61+
has_audio=has_audio, has_video=has_video, output_mode=output_mode)
5862
return archive.json()
5963

6064
@app.route("/stop/<archive_id>")

sample/Archiving/static/js/host.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,33 @@ session.on('archiveStarted', function(event) {
1818
console.log("ARCHIVE STARTED");
1919
$(".start").hide();
2020
$(".stop").show();
21+
disableForm();
2122
});
2223

2324
session.on('archiveStopped', function(event) {
2425
archiveID = null;
2526
console.log("ARCHIVE STOPPED");
2627
$(".start").show();
2728
$(".stop").hide();
29+
enableForm();
2830
});
2931

3032
$(document).ready(function() {
31-
$(".start").click(function(event){
32-
$.get("start");
33+
$(".start").click(function (event) {
34+
var options = $(".archive-options").serialize();
35+
disableForm();
36+
$.post("/start", options).fail(enableForm);
3337
}).show();
3438
$(".stop").click(function(event){
3539
$.get("stop/" + archiveID);
3640
}).hide();
3741
});
42+
43+
44+
function disableForm() {
45+
$(".archive-options-fields").attr('disabled', 'disabled');
46+
}
47+
48+
function enableForm() {
49+
$(".archive-options-fields").removeAttr('disabled');
50+
}

sample/Archiving/templates/host.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ <h3 class="panel-title">Host</h3>
1515
<div id="subscribers"><div id="publisher"></div></div>
1616
</div>
1717
<div class="panel-footer">
18+
<form class="archive-options">
19+
<fieldset class="archive-options-fields">
20+
<div class="form-group">
21+
<p class="help-block">Archive Options:</p>
22+
<label class="checkbox-inline">
23+
<input type="checkbox" name="hasAudio" checked> Audio
24+
</label>
25+
<label class="checkbox-inline">
26+
<input type="checkbox" name="hasVideo" checked> Video
27+
</label>
28+
</div>
29+
30+
<div class="form-group">
31+
<p class="help-block">Output Mode:</p>
32+
<label class="radio-inline">
33+
<input type="radio" name="outputMode" value="composed" checked> Composed
34+
</label>
35+
<label class="radio-inline">
36+
<input type="radio" name="outputMode" value="individual"> Individual
37+
</label>
38+
</div>
39+
</fieldset>
40+
</form>
1841
<button class="btn btn-danger start">Start archiving</button>
1942
<button class="btn btn-success stop">Stop archiving</button>
2043
</div>

0 commit comments

Comments
 (0)