Skip to content

Commit

Permalink
Merge branch 'main' into improve-reconnect-logic-for-websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwebrtc committed Dec 8, 2023
2 parents c78308c + d684856 commit 79a9b32
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
12 changes: 8 additions & 4 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_window_close/flutter_window_close.dart';
import 'package:livekit_client/livekit_client.dart';
import 'package:livekit_example/theme.dart';
import 'package:logging/logging.dart';
import 'package:intl/intl.dart';
Expand All @@ -16,10 +17,13 @@ void main() async {

WidgetsFlutterBinding.ensureInitialized();

FlutterWindowClose.setWindowShouldCloseHandler(() async {
await onWindowShouldClose?.call();
return true;
});
if (lkPlatformIsDesktop()) {
FlutterWindowClose.setWindowShouldCloseHandler(() async {
await onWindowShouldClose?.call();
return true;
});
}

runApp(const LiveKitExampleApp());
}

Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/room.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class _RoomPageState extends State<RoomPage> with WidgetsBindingObserver {
Hardware.instance.setSpeakerphoneOn(true);
}

if (!lkPlatformIs(PlatformType.web) && !lkPlatformIsTest()) {
if (lkPlatformIsDesktop()) {
onWindowShouldClose = () async {
unawaited(widget.room.disconnect());
await _listener.waitFor<RoomDisconnectedEvent>(
Expand Down
25 changes: 18 additions & 7 deletions lib/src/widgets/screen_select_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@ class ThumbnailWidget extends StatefulWidget {

class ThumbnailWidgetState extends State<ThumbnailWidget> {
final List<StreamSubscription> _subscriptions = [];
Uint8List? _thumbnail;
String _name = '';

@override
void initState() {
super.initState();
_subscriptions.add(widget.source.onThumbnailChanged.stream.listen((event) {
setState(() {});
_name = widget.source.name;
_thumbnail = widget.source.thumbnail?.isNotEmpty == true
? widget.source.thumbnail
: null;
_subscriptions
.add(widget.source.onThumbnailChanged.stream.listen((thumbnail) {
setState(() {
_thumbnail = thumbnail;
});
}));
_subscriptions.add(widget.source.onNameChanged.stream.listen((event) {
setState(() {});
_subscriptions.add(widget.source.onNameChanged.stream.listen((name) {
setState(() {
_name = name;
});
}));
}

Expand Down Expand Up @@ -73,17 +84,17 @@ class ThumbnailWidgetState extends State<ThumbnailWidget> {
}
widget.onTap(widget.source);
},
child: widget.source.thumbnail != null
child: _thumbnail != null
? Image.memory(
widget.source.thumbnail!,
_thumbnail!,
gaplessPlayback: true,
alignment: Alignment.center,
)
: Container(),
),
)),
Text(
widget.source.name,
_name,
style: TextStyle(
fontSize: 12,
color: Colors.black87,
Expand Down

0 comments on commit 79a9b32

Please sign in to comment.