Skip to content

Commit 3e80ff4

Browse files
committed
updated tutorial
1 parent c69aaeb commit 3e80ff4

File tree

4 files changed

+46
-42
lines changed

4 files changed

+46
-42
lines changed

livestreaming_tutorial/ios/Podfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,4 @@ SPEC CHECKSUMS:
200200

201201
PODFILE CHECKSUM: 4c438addb11b6da45ed7ae408823d68256222460
202202

203-
COCOAPODS: 1.16.2
203+
COCOAPODS: 1.16.1

livestreaming_tutorial/lib/livestream_screen.dart

+40-37
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class LiveStreamScreen extends StatefulWidget {
1111
}
1212

1313
class _LiveStreamScreenState extends State<LiveStreamScreen> {
14-
final callId = "REPLACE_WITH_CALL_ID";
14+
final callId = "demo12345";
1515
Call? _livestreamCall;
1616

1717
@override
@@ -42,36 +42,39 @@ class _LiveStreamScreenState extends State<LiveStreamScreen> {
4242
);
4343
}
4444

45-
return SafeArea(
46-
child: StreamBuilder(
47-
stream: _livestreamCall!.state.valueStream,
48-
initialData: _livestreamCall!.state.value,
49-
builder: (context, snapshot) {
50-
final callState = snapshot.data!;
51-
final participant = callState.callParticipants.firstOrNull;
52-
return Scaffold(
53-
appBar: AppBar(
54-
actions: [
55-
OutlinedButton(
45+
return StreamBuilder(
46+
stream: _livestreamCall!.state.valueStream,
47+
initialData: _livestreamCall!.state.value,
48+
builder: (context, snapshot) {
49+
final callState = snapshot.data!;
50+
final participant = callState.callParticipants.firstOrNull;
51+
return Scaffold(
52+
appBar: AppBar(
53+
actions: [
54+
Padding(
55+
padding: const EdgeInsets.symmetric(horizontal: 8.0),
56+
child: OutlinedButton(
5657
onPressed: () {
5758
_livestreamCall!.end();
5859
Navigator.pop(context);
5960
},
6061
child: const Text('End Call'),
6162
),
62-
],
63-
title: Text('Viewers: ${callState.callParticipants.length}'),
64-
automaticallyImplyLeading: false,
65-
),
66-
body: Builder(
67-
builder: (context) {
68-
if (!snapshot.hasData) {
69-
return const Center(
70-
child: CircularProgressIndicator(),
71-
);
72-
} else {
73-
if (snapshot.hasData && callState.isBackstage) {
74-
return Column(
63+
),
64+
],
65+
title: Text('Viewers: ${callState.callParticipants.length}'),
66+
automaticallyImplyLeading: false,
67+
),
68+
body: Builder(
69+
builder: (context) {
70+
if (!snapshot.hasData) {
71+
return const Center(
72+
child: CircularProgressIndicator(),
73+
);
74+
} else {
75+
if (snapshot.hasData && callState.isBackstage) {
76+
return Center(
77+
child: Column(
7578
mainAxisAlignment: MainAxisAlignment.center,
7679
children: [
7780
const Text('Stream not live'),
@@ -82,20 +85,20 @@ class _LiveStreamScreenState extends State<LiveStreamScreen> {
8285
child: const Text('Go Live'),
8386
),
8487
],
85-
);
86-
}
87-
88-
return StreamVideoRenderer(
89-
call: _livestreamCall!,
90-
videoTrackType: SfuTrackType.video,
91-
participant: participant!,
88+
),
9289
);
9390
}
94-
},
95-
),
96-
);
97-
},
98-
),
91+
92+
return StreamVideoRenderer(
93+
call: _livestreamCall!,
94+
videoTrackType: SfuTrackType.video,
95+
participant: participant!,
96+
);
97+
}
98+
},
99+
),
100+
);
101+
},
99102
);
100103
}
101104
}

livestreaming_tutorial/lib/main.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ Future<void> main() async {
99

1010
// Initialize Stream video and set the API key for our app.
1111
StreamVideo(
12-
'REPLACE_WITH_API_KEY',
12+
'mmhfdzb5evj2',
1313
user: const User(
1414
info: UserInfo(
1515
name: 'John Doe',
16-
id: 'REPLACE_WITH_USER_ID',
16+
id: 'demo',
17+
role: 'admin'
1718
),
1819
),
19-
userToken: 'REPLACE_WITH_TOKEN',
20+
userToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3Byb250by5nZXRzdHJlYW0uaW8iLCJzdWIiOiJ1c2VyL1RhbG9uX0thcnJkZSIsInVzZXJfaWQiOiJUYWxvbl9LYXJyZGUiLCJ2YWxpZGl0eV9pbl9zZWNvbmRzIjo2MDQ4MDAsImlhdCI6MTczNzcxNDU0MiwiZXhwIjoxNzM4MzE5MzQyfQ.mroo_g3_UNMWokded07DCx34d8VX6pBhyuEpzD1ZBGE',
2021
);
2122

2223
// For connecting anonymous users

livestreaming_tutorial/lib/view_livestream_screen.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ViewLivestreamScreen extends StatefulWidget {
99
}
1010

1111
class _ViewLivestreamScreenState extends State<ViewLivestreamScreen> {
12-
final callId = "REPLACE_WITH_CALL_ID";
12+
final callId = "demo12345";
1313

1414
Call? _livestreamCall;
1515

0 commit comments

Comments
 (0)