Fixed UI stuck when get thumbnails on screen sharing. (#149)
* fix: get thumbnails stuck. * update.
This commit is contained in:
@@ -3,16 +3,16 @@ PODS:
|
|||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- flutter_webrtc (0.9.2):
|
- flutter_webrtc (0.9.2):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- WebRTC-SDK (= 104.5112.02)
|
- WebRTC-SDK (= 104.5112.03)
|
||||||
- FlutterMacOS (1.0.0)
|
- FlutterMacOS (1.0.0)
|
||||||
- livekit_client (1.1.0):
|
- livekit_client (1.1.0):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- WebRTC-SDK (~> 104.5112.02)
|
- WebRTC-SDK (~> 104.5112.03)
|
||||||
- path_provider_macos (0.0.1):
|
- path_provider_macos (0.0.1):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- shared_preferences_macos (0.0.1):
|
- shared_preferences_macos (0.0.1):
|
||||||
- FlutterMacOS
|
- FlutterMacOS
|
||||||
- WebRTC-SDK (104.5112.02)
|
- WebRTC-SDK (104.5112.03)
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- device_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos`)
|
- device_info_plus_macos (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus_macos/macos`)
|
||||||
@@ -42,12 +42,12 @@ EXTERNAL SOURCES:
|
|||||||
|
|
||||||
SPEC CHECKSUMS:
|
SPEC CHECKSUMS:
|
||||||
device_info_plus_macos: 1ad388a1ef433505c4038e7dd9605aadd1e2e9c7
|
device_info_plus_macos: 1ad388a1ef433505c4038e7dd9605aadd1e2e9c7
|
||||||
flutter_webrtc: e4c5ac172da404d18f31d46ca8144ddd871551ea
|
flutter_webrtc: 335c834280a69d6db648228ab9bd0f855886f776
|
||||||
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
|
FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424
|
||||||
livekit_client: d3f90a194a0102e5987dc80dcc3ccb5890c17a43
|
livekit_client: 1076d27c06480d4abdda77641f6586309bc2dd3f
|
||||||
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
|
path_provider_macos: 3c0c3b4b0d4a76d2bf989a913c2de869c5641a19
|
||||||
shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727
|
shared_preferences_macos: a64dc611287ed6cbe28fd1297898db1336975727
|
||||||
WebRTC-SDK: e0589abeb63db07a4ca1f45c82ba0f1a72e61622
|
WebRTC-SDK: 9f50fb5a410edc38e6fbb865fe940e3010bc8e7e
|
||||||
|
|
||||||
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
|
PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c
|
||||||
|
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ packages:
|
|||||||
name: flutter_webrtc
|
name: flutter_webrtc
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.2"
|
version: "0.9.3"
|
||||||
google_fonts:
|
google_fonts:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -1,9 +1,84 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
|
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
|
||||||
|
|
||||||
import '../logger.dart';
|
class ThumbnailWidget extends StatefulWidget {
|
||||||
|
const ThumbnailWidget(
|
||||||
|
{Key? key,
|
||||||
|
required this.source,
|
||||||
|
required this.selected,
|
||||||
|
required this.onTap})
|
||||||
|
: super(key: key);
|
||||||
|
final rtc.DesktopCapturerSource source;
|
||||||
|
final bool selected;
|
||||||
|
final Function(rtc.DesktopCapturerSource) onTap;
|
||||||
|
|
||||||
|
@override
|
||||||
|
ThumbnailWidgetState createState() => ThumbnailWidgetState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class ThumbnailWidgetState extends State<ThumbnailWidget> {
|
||||||
|
final List<StreamSubscription> _subscriptions = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_subscriptions.add(widget.source.onThumbnailChanged.stream.listen((event) {
|
||||||
|
setState(() {});
|
||||||
|
}));
|
||||||
|
_subscriptions.add(widget.source.onNameChanged.stream.listen((event) {
|
||||||
|
setState(() {});
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void deactivate() {
|
||||||
|
for (var element in _subscriptions) {
|
||||||
|
element.cancel();
|
||||||
|
}
|
||||||
|
super.deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Column(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
decoration: widget.selected
|
||||||
|
? BoxDecoration(
|
||||||
|
border: Border.all(width: 2, color: Colors.blueAccent))
|
||||||
|
: null,
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () {
|
||||||
|
if (kDebugMode) {
|
||||||
|
print('Selected source id => ${widget.source.id}');
|
||||||
|
}
|
||||||
|
widget.onTap(widget.source);
|
||||||
|
},
|
||||||
|
child: widget.source.thumbnail != null
|
||||||
|
? Image.memory(
|
||||||
|
widget.source.thumbnail!,
|
||||||
|
gaplessPlayback: true,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
)
|
||||||
|
: Container(),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Text(
|
||||||
|
widget.source.name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 12,
|
||||||
|
color: Colors.black87,
|
||||||
|
fontWeight:
|
||||||
|
widget.selected ? FontWeight.bold : FontWeight.normal),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class ScreenSelectDialog extends Dialog {
|
class ScreenSelectDialog extends Dialog {
|
||||||
@@ -21,15 +96,8 @@ class ScreenSelectDialog extends Dialog {
|
|||||||
_stateSetter?.call(() {});
|
_stateSetter?.call(() {});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_subscriptions
|
|
||||||
.add(rtc.desktopCapturer.onNameChanged.stream.listen((source) {
|
|
||||||
_sources[source.id] = source;
|
|
||||||
_stateSetter?.call(() {});
|
|
||||||
}));
|
|
||||||
|
|
||||||
_subscriptions
|
_subscriptions
|
||||||
.add(rtc.desktopCapturer.onThumbnailChanged.stream.listen((source) {
|
.add(rtc.desktopCapturer.onThumbnailChanged.stream.listen((source) {
|
||||||
_sources[source.id] = source;
|
|
||||||
_stateSetter?.call(() {});
|
_stateSetter?.call(() {});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -42,16 +110,16 @@ class ScreenSelectDialog extends Dialog {
|
|||||||
|
|
||||||
void _ok(BuildContext context) {
|
void _ok(BuildContext context) {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
for (var item in _subscriptions) {
|
for (var element in _subscriptions) {
|
||||||
item.cancel();
|
element.cancel();
|
||||||
}
|
}
|
||||||
Navigator.pop<rtc.DesktopCapturerSource>(context, _selectedSource);
|
Navigator.pop<rtc.DesktopCapturerSource>(context, _selectedSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _cancel(BuildContext context) {
|
void _cancel(BuildContext context) {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
for (var item in _subscriptions) {
|
for (var element in _subscriptions) {
|
||||||
item.cancel();
|
element.cancel();
|
||||||
}
|
}
|
||||||
Navigator.pop<rtc.DesktopCapturerSource>(context, null);
|
Navigator.pop<rtc.DesktopCapturerSource>(context, null);
|
||||||
}
|
}
|
||||||
@@ -59,21 +127,26 @@ class ScreenSelectDialog extends Dialog {
|
|||||||
Future<void> _getSources() async {
|
Future<void> _getSources() async {
|
||||||
try {
|
try {
|
||||||
var sources = await rtc.desktopCapturer.getSources(types: [_sourceType]);
|
var sources = await rtc.desktopCapturer.getSources(types: [_sourceType]);
|
||||||
for (var item in sources) {
|
for (var element in sources) {
|
||||||
logger.info('name: ${item.name}, id: ${item.id}, type: ${item.type}');
|
if (kDebugMode) {
|
||||||
}
|
print(
|
||||||
_stateSetter?.call(() {
|
'name: ${element.name}, id: ${element.id}, type: ${element.type}');
|
||||||
for (var item in sources) {
|
|
||||||
_sources[item.id] = item;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = Timer.periodic(const Duration(seconds: 2), (timer) {
|
_timer = Timer.periodic(const Duration(seconds: 3), (timer) {
|
||||||
rtc.desktopCapturer.updateSources(types: [_sourceType]);
|
rtc.desktopCapturer.updateSources(types: [_sourceType]);
|
||||||
});
|
});
|
||||||
|
_sources.clear();
|
||||||
|
for (var element in sources) {
|
||||||
|
_sources[element.id] = element;
|
||||||
|
}
|
||||||
|
_stateSetter?.call(() {});
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warning(e.toString());
|
if (kDebugMode) {
|
||||||
|
print(e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,57 +232,15 @@ class ScreenSelectDialog extends Dialog {
|
|||||||
.where((element) =>
|
.where((element) =>
|
||||||
element.value.type ==
|
element.value.type ==
|
||||||
rtc.SourceType.Screen)
|
rtc.SourceType.Screen)
|
||||||
.map((e) => Column(
|
.map((e) => ThumbnailWidget(
|
||||||
children: [
|
onTap: (source) {
|
||||||
Expanded(
|
setState(() {
|
||||||
child: Container(
|
_selectedSource = source;
|
||||||
decoration: (_selectedSource !=
|
});
|
||||||
null &&
|
},
|
||||||
_selectedSource!.id ==
|
source: e.value,
|
||||||
e.value.id)
|
selected: _selectedSource?.id ==
|
||||||
? BoxDecoration(
|
e.value.id,
|
||||||
border: Border.all(
|
|
||||||
width: 2,
|
|
||||||
color: Colors
|
|
||||||
.blueAccent))
|
|
||||||
: null,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
logger.info(
|
|
||||||
'Selected screen id => ${e.value.id}');
|
|
||||||
setState(() {
|
|
||||||
_selectedSource =
|
|
||||||
e.value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: e.value.thumbnail !=
|
|
||||||
null
|
|
||||||
? Image.memory(
|
|
||||||
e.value.thumbnail!,
|
|
||||||
scale: 1.0,
|
|
||||||
repeat: ImageRepeat
|
|
||||||
.noRepeat,
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
Text(
|
|
||||||
e.value.name,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight:
|
|
||||||
(_selectedSource !=
|
|
||||||
null &&
|
|
||||||
_selectedSource!
|
|
||||||
.id ==
|
|
||||||
e.value
|
|
||||||
.id)
|
|
||||||
? FontWeight.bold
|
|
||||||
: FontWeight
|
|
||||||
.normal),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
)),
|
)),
|
||||||
@@ -222,57 +253,15 @@ class ScreenSelectDialog extends Dialog {
|
|||||||
.where((element) =>
|
.where((element) =>
|
||||||
element.value.type ==
|
element.value.type ==
|
||||||
rtc.SourceType.Window)
|
rtc.SourceType.Window)
|
||||||
.map((e) => Column(
|
.map((e) => ThumbnailWidget(
|
||||||
children: [
|
onTap: (source) {
|
||||||
Expanded(
|
setState(() {
|
||||||
child: Container(
|
_selectedSource = source;
|
||||||
decoration: (_selectedSource !=
|
});
|
||||||
null &&
|
},
|
||||||
_selectedSource!.id ==
|
source: e.value,
|
||||||
e.value.id)
|
selected: _selectedSource?.id ==
|
||||||
? BoxDecoration(
|
e.value.id,
|
||||||
border: Border.all(
|
|
||||||
width: 2,
|
|
||||||
color: Colors
|
|
||||||
.blueAccent))
|
|
||||||
: null,
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () {
|
|
||||||
logger.info(
|
|
||||||
'Selected window id => ${e.value.id}');
|
|
||||||
setState(() {
|
|
||||||
_selectedSource =
|
|
||||||
e.value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
child: e.value.thumbnail!
|
|
||||||
.isNotEmpty
|
|
||||||
? Image.memory(
|
|
||||||
e.value.thumbnail!,
|
|
||||||
scale: 1.0,
|
|
||||||
repeat: ImageRepeat
|
|
||||||
.noRepeat,
|
|
||||||
)
|
|
||||||
: Container(),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
Text(
|
|
||||||
e.value.name,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 12,
|
|
||||||
color: Colors.black87,
|
|
||||||
fontWeight:
|
|
||||||
(_selectedSource !=
|
|
||||||
null &&
|
|
||||||
_selectedSource!
|
|
||||||
.id ==
|
|
||||||
e.value
|
|
||||||
.id)
|
|
||||||
? FontWeight.bold
|
|
||||||
: FontWeight
|
|
||||||
.normal),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
)),
|
)),
|
||||||
|
|||||||
@@ -16,5 +16,5 @@ Pod::Spec.new do |s|
|
|||||||
s.static_framework = true
|
s.static_framework = true
|
||||||
|
|
||||||
s.dependency 'FlutterMacOS'
|
s.dependency 'FlutterMacOS'
|
||||||
s.dependency 'WebRTC-SDK', '~> 104.5112.02'
|
s.dependency 'WebRTC-SDK', '~> 104.5112.03'
|
||||||
end
|
end
|
||||||
|
|||||||
+1
-1
@@ -218,7 +218,7 @@ packages:
|
|||||||
name: flutter_webrtc
|
name: flutter_webrtc
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.9.2"
|
version: "0.9.3"
|
||||||
glob:
|
glob:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ dependencies:
|
|||||||
uuid: ^3.0.6
|
uuid: ^3.0.6
|
||||||
synchronized: ^3.0.0
|
synchronized: ^3.0.0
|
||||||
protobuf: ^2.0.1
|
protobuf: ^2.0.1
|
||||||
flutter_webrtc: ^0.9.2
|
flutter_webrtc: ^0.9.3
|
||||||
dart_webrtc: ^1.0.7
|
dart_webrtc: ^1.0.7
|
||||||
device_info_plus: ^3.2.3
|
device_info_plus: ^3.2.3
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user