@@ -81,13 +81,25 @@ generates the three strings that the client (JavaScript) needs to connect to the
81
81
URL. The route handler for this URL is shown below:
82
82
83
83
``` java
84
- get (new Route (" /start" ) {
84
+ post (new Route (" /start" ) {
85
85
@Override
86
86
public Object handle (Request request , Response response ) {
87
87
88
88
Archive archive = null ;
89
+ HttpServletRequest req = request. raw();
90
+ boolean hasAudio = req. getParameterMap(). containsKey(" hasAudio" );
91
+ boolean hasVideo = req. getParameterMap(). containsKey(" hasVideo" );
92
+ OutputMode outputMode = OutputMode . COMPOSED ;
93
+ if (req. getParameter(" outputMode" ). equals(" individual" )) {
94
+ outputMode = OutputMode . INDIVIDUAL ;
95
+ }
89
96
try {
90
- archive = opentok. startArchive(sessionId, " Java Archiving Sample App" );
97
+ ArchiveProperties properties = new ArchiveProperties .Builder ()
98
+ .name(" Java Archiving Sample App" )
99
+ .hasAudio(hasAudio)
100
+ .hasVideo(hasVideo)
101
+ .outputMode(outputMode). build();
102
+ archive = opentok. startArchive(sessionId, properties);
91
103
} catch (OpenTokException e) {
92
104
e. printStackTrace();
93
105
return null ;
@@ -98,8 +110,11 @@ get(new Route("/start") {
98
110
```
99
111
100
112
In this handler, the ` startArchive() ` method of the ` opentok ` instance is called with the ` sessionId `
101
- for the session that needs to be archived. The optional second argument is ` name ` , which is stored with
102
- the archive and can be read later. In this case, as in the HelloWorld sample app, there is
113
+ for the session that needs to be archived. An ArchiveProperties object is instantiated. It defines
114
+ optional properties for the archive. The ` name ` is stored with the archive and can be read later.
115
+ The ` hasAudio ` , ` hasVideo ` , and ` outputMode ` values are read from the request body; these define
116
+ whether the archive will record audio and video, and whether it will record streams individually or
117
+ to a single file composed of all streams. In this case, as in the HelloWorld sample app, there is
103
118
only one session created and it is used here and for the participant view. This will trigger the
104
119
recording to begin. The response sent back to the client's XHR request will be the JSON
105
120
representation of the archive, which is returned from the ` toString() ` method. The client is also
0 commit comments