Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb047da6

Browse files
authored
feat: Add Video API snippets (#121)
1 parent6b8dc4e commitb047da6

26 files changed

+823
-4
lines changed

‎.env-example‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,19 @@ VERIFY_TEMPLATE_NAME="verify"
144144
VERIFY_TEMPLATE_ID="bcdef09-8765-4321-8cde-0123456789ab"
145145
VERIFY_TEMPLATE_FRAGMENT_ID="aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab"
146146

147+
# Video
148+
VIDEO_SESSION_ID="flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN"
149+
VIDEO_TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhcHBsaWNhdGlvbl9pZCI6ImFhYWFhYWFhLWJiYmItNGNjYy04ZGRkLTAxMjM0NTY3ODlhYiJ9.o3U506EejsS8D5Tob90FG1NC1cR69fh3pFOpxnyTHVFfgqI6NWuuN8lEwrS3Zb8bGxE_A9LyyUZ2y4uqLpyXRw"
150+
VIDEO_CONNECTION_ID="bcdef09-8765-4321-8cde-0123456789ab"
151+
VIDEO_STREAM_ID="bcdef09-8765-4321-8cde-0123456789ab"
152+
VIDEO_ARCHIVE_ID="aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab"
153+
VIDEO_BROADCAST_ID="aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab"
154+
147155
# Voice
148156
VOICE_CALL_ID="aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab"
149157
VOICE_TO_NUMBER="447700900000"
150158
VOICE_TEXT="Hello from Vonage! Would you like to learn more?"
151-
VOICE_LANGUAGE="en-US"
159+
VOICE_LANGUAGE="AMERICAN_ENGLISH"
152160
VOICE_DTMF_DIGITS="2468#"
153161
VOICE_CONFERENCE_NAME="My conference call room"
154162
VOICE_NCCO_URL="https://nexmo-community.github.io/ncco-examples/talk.json"

‎src/main/java/com/vonage/quickstart/EnvironmentVariables.java‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,12 @@ public static String envVar(String key) {
150150
VERIFY_FROM_EMAIL =envVar("VERIFY_FROM_EMAIL"),
151151
VERIFY_WHATSAPP_NUMBER =envVar("VERIFY_WHATSAPP_NUMBER"),
152152
VERIFY_TEMPLATE_NAME =envVar("VERIFY_TEMPLATE_NAME"),
153+
VIDEO_STREAM_ID =envVar("VIDEO_STREAM_ID"),
154+
VIDEO_ARCHIVE_ID =envVar("VIDEO_ARCHIVE_ID"),
155+
VIDEO_BROADCAST_ID =envVar("VIDEO_BROADCAST_ID"),
156+
VIDEO_CONNECTION_ID =envVar("VIDEO_CONNECTION_ID"),
157+
VIDEO_SESSION_ID =envVar("VIDEO_SESSION_ID"),
158+
VIDEO_TOKEN =envVar("VIDEO_TOKEN"),
153159
VOICE_CALL_ID =envVar("VOICE_CALL_ID"),
154160
VOICE_TO_NUMBER =envVar("VOICE_TO_NUMBER"),
155161
VOICE_TEXT =envVar("VOICE_TEXT"),
@@ -189,10 +195,10 @@ public static String envVar(String key) {
189195
publicstaticfinalType
190196
NUMBER_TYPE =Type.fromString(envVar("NUMBER_TYPE"));
191197

192-
publicstaticfinalFeature[]
198+
publicstaticfinalcom.vonage.client.numbers.Feature[]
193199
NUMBER_FEATURES =Arrays.stream(envVar("NUMBER_FEATURES").split(","))
194-
.map(Feature::fromString)
195-
.toArray(Feature[]::new);
200+
.map(com.vonage.client.numbers.Feature::fromString)
201+
.toArray(com.vonage.client.numbers.Feature[]::new);
196202

197203
publicstaticfinalSearchPattern
198204
NUMBER_SEARCH_PATTERN =SearchPattern.values()[Integer.parseInt(envVar("NUMBER_SEARCH_PATTERN"))];
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
packagecom.vonage.quickstart.video;
17+
18+
importcom.vonage.client.VonageClient;
19+
importcom.vonage.client.video.*;
20+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
21+
22+
publicclassAddArchiveStream {
23+
publicstaticvoidmain(String[]args)throwsException {
24+
25+
VideoClientvideoClient =VonageClient.builder()
26+
.applicationId(VONAGE_APPLICATION_ID)
27+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
28+
.build().getVideoClient();
29+
30+
videoClient.addArchiveStream(VIDEO_ARCHIVE_ID,VIDEO_STREAM_ID);
31+
32+
System.out.println("Added archive stream");
33+
}
34+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
packagecom.vonage.quickstart.video;
17+
18+
importcom.vonage.client.VonageClient;
19+
importcom.vonage.client.video.*;
20+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
21+
22+
publicclassAddBroadcastStream {
23+
publicstaticvoidmain(String[]args)throwsException {
24+
25+
VideoClientvideoClient =VonageClient.builder()
26+
.applicationId(VONAGE_APPLICATION_ID)
27+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
28+
.build().getVideoClient();
29+
30+
videoClient.addBroadcastStream(VIDEO_BROADCAST_ID,VIDEO_STREAM_ID);
31+
32+
System.out.println("Added broadcast stream");
33+
}
34+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
packagecom.vonage.quickstart.video;
17+
18+
importcom.vonage.client.VonageClient;
19+
importcom.vonage.client.video.*;
20+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
21+
22+
publicclassCreateArchive {
23+
publicstaticvoidmain(String[]args)throwsException {
24+
25+
VideoClientvideoClient =VonageClient.builder()
26+
.applicationId(VONAGE_APPLICATION_ID)
27+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
28+
.build().getVideoClient();
29+
30+
Archivearchive =videoClient.createArchive(
31+
Archive.builder(VIDEO_SESSION_ID)
32+
.streamMode(StreamMode.AUTO)
33+
.hasVideo(true)
34+
.hasAudio(true)
35+
.resolution(Resolution.HD_LANDSCAPE)
36+
.outputMode(OutputMode.COMPOSED).name("My recording")
37+
.build()
38+
);
39+
40+
System.out.println("Started archive: " +archive.toJson());
41+
}
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
packagecom.vonage.quickstart.video;
17+
18+
importcom.vonage.client.VonageClient;
19+
importcom.vonage.client.video.*;
20+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
21+
importjava.time.Duration;
22+
23+
publicclassCreateBroadcast {
24+
publicstaticvoidmain(String[]args)throwsException {
25+
26+
VideoClientvideoClient =VonageClient.builder()
27+
.applicationId(VONAGE_APPLICATION_ID)
28+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
29+
.build().getVideoClient();
30+
31+
Broadcastbroadcast =videoClient.createBroadcast(
32+
Broadcast.builder(VIDEO_SESSION_ID)
33+
.hls(Hls.builder().lowLatency(true).build())
34+
.resolution(Resolution.HD_LANDSCAPE)
35+
.streamMode(StreamMode.AUTO)
36+
.maxDuration(Duration.ofMinutes(45))
37+
.build()
38+
);
39+
40+
System.out.println("Started broadcast: " +broadcast.toJson());
41+
}
42+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2025 Vonage
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
packagecom.vonage.quickstart.video;
17+
18+
importcom.vonage.client.VonageClient;
19+
importcom.vonage.client.video.*;
20+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
21+
22+
publicclassCreateSession {
23+
publicstaticvoidmain(String[]args)throwsException {
24+
25+
VideoClientvideoClient =VonageClient.builder()
26+
.applicationId(VONAGE_APPLICATION_ID)
27+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
28+
.build().getVideoClient();
29+
30+
CreateSessionResponsesession =videoClient.createSession(
31+
CreateSessionRequest.builder()
32+
.mediaMode(MediaMode.ROUTED)
33+
.archiveMode(ArchiveMode.MANUAL)
34+
.build()
35+
);
36+
37+
System.out.println("Created session: " +session.toJson());
38+
}
39+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
packagecom.vonage.quickstart.video;
2+
3+
importcom.vonage.client.VonageClient;
4+
importcom.vonage.client.video.*;
5+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
6+
7+
publicclassDeleteArchive {
8+
publicstaticvoidmain(String[]args)throwsException {
9+
10+
VideoClientvideoClient =VonageClient.builder()
11+
.applicationId(VONAGE_APPLICATION_ID)
12+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
13+
.build().getVideoClient();
14+
15+
videoClient.deleteArchive(VIDEO_ARCHIVE_ID);
16+
17+
System.out.println("Deleted archive");
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
packagecom.vonage.quickstart.video;
2+
3+
importcom.vonage.client.VonageClient;
4+
importcom.vonage.client.video.*;
5+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
6+
7+
publicclassForceDisconnect {
8+
publicstaticvoidmain(String[]args)throwsException {
9+
10+
VideoClientvideoClient =VonageClient.builder()
11+
.applicationId(VONAGE_APPLICATION_ID)
12+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
13+
.build().getVideoClient();
14+
15+
videoClient.forceDisconnect(VIDEO_SESSION_ID,VIDEO_CONNECTION_ID);
16+
17+
System.out.println("Force disconnected");
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
packagecom.vonage.quickstart.video;
2+
3+
importcom.vonage.client.VonageClient;
4+
importcom.vonage.client.video.*;
5+
importstaticcom.vonage.quickstart.EnvironmentVariables.*;
6+
7+
publicclassForceMute {
8+
publicstaticvoidmain(String[]args)throwsException {
9+
10+
VideoClientvideoClient =VonageClient.builder()
11+
.applicationId(VONAGE_APPLICATION_ID)
12+
.privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
13+
.build().getVideoClient();
14+
15+
videoClient.muteStream(VIDEO_SESSION_ID,VIDEO_STREAM_ID);
16+
17+
System.out.println("Force muted");
18+
}
19+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp