adaptiveStream and dynacast option in example

This commit is contained in:
Hiroshi Horie
2022-04-03 00:18:28 +09:00
parent 2f6042ef94
commit 91b604a191
2 changed files with 65 additions and 16 deletions
+51 -7
View File
@@ -23,10 +23,14 @@ class _ConnectPageState extends State<ConnectPage> {
static const _storeKeyUri = 'uri'; static const _storeKeyUri = 'uri';
static const _storeKeyToken = 'token'; static const _storeKeyToken = 'token';
static const _storeKeySimulcast = 'simulcast'; static const _storeKeySimulcast = 'simulcast';
static const _storeKeyAdaptiveStream = 'adaptive-stream';
static const _storeKeyDynacast = 'dynacast';
final _uriCtrl = TextEditingController(); final _uriCtrl = TextEditingController();
final _tokenCtrl = TextEditingController(); final _tokenCtrl = TextEditingController();
bool _simulcast = true; bool _simulcast = true;
bool _adaptiveStream = true;
bool _dynacast = true;
bool _busy = false; bool _busy = false;
@override @override
@@ -49,6 +53,8 @@ class _ConnectPageState extends State<ConnectPage> {
_tokenCtrl.text = prefs.getString(_storeKeyToken) ?? ''; _tokenCtrl.text = prefs.getString(_storeKeyToken) ?? '';
setState(() { setState(() {
_simulcast = prefs.getBool(_storeKeySimulcast) ?? true; _simulcast = prefs.getBool(_storeKeySimulcast) ?? true;
_adaptiveStream = prefs.getBool(_storeKeyAdaptiveStream) ?? true;
_dynacast = prefs.getBool(_storeKeyDynacast) ?? true;
}); });
} }
@@ -58,6 +64,8 @@ class _ConnectPageState extends State<ConnectPage> {
await prefs.setString(_storeKeyUri, _uriCtrl.text); await prefs.setString(_storeKeyUri, _uriCtrl.text);
await prefs.setString(_storeKeyToken, _tokenCtrl.text); await prefs.setString(_storeKeyToken, _tokenCtrl.text);
await prefs.setBool(_storeKeySimulcast, _simulcast); await prefs.setBool(_storeKeySimulcast, _simulcast);
await prefs.setBool(_storeKeyAdaptiveStream, _adaptiveStream);
await prefs.setBool(_storeKeyDynacast, _dynacast);
} }
Future<void> _connect(BuildContext ctx) async { Future<void> _connect(BuildContext ctx) async {
@@ -79,8 +87,8 @@ class _ConnectPageState extends State<ConnectPage> {
_uriCtrl.text, _uriCtrl.text,
_tokenCtrl.text, _tokenCtrl.text,
roomOptions: RoomOptions( roomOptions: RoomOptions(
adaptiveStream: true, adaptiveStream: _adaptiveStream,
dynacast: true, dynacast: _dynacast,
defaultVideoPublishOptions: VideoPublishOptions( defaultVideoPublishOptions: VideoPublishOptions(
simulcast: _simulcast, simulcast: _simulcast,
), ),
@@ -108,6 +116,20 @@ class _ConnectPageState extends State<ConnectPage> {
}); });
} }
void _setAdaptiveStream(bool? value) async {
if (value == null || _adaptiveStream == value) return;
setState(() {
_adaptiveStream = value;
});
}
void _setDynacast(bool? value) async {
if (value == null || _dynacast == value) return;
setState(() {
_dynacast = value;
});
}
@override @override
Widget build(BuildContext context) => Scaffold( Widget build(BuildContext context) => Scaffold(
body: Container( body: Container(
@@ -144,7 +166,7 @@ class _ConnectPageState extends State<ConnectPage> {
), ),
), ),
Padding( Padding(
padding: const EdgeInsets.only(bottom: 50), padding: const EdgeInsets.only(bottom: 5),
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@@ -152,10 +174,32 @@ class _ConnectPageState extends State<ConnectPage> {
Switch( Switch(
value: _simulcast, value: _simulcast,
onChanged: (value) => _setSimulcast(value), onChanged: (value) => _setSimulcast(value),
inactiveTrackColor: Colors.white.withOpacity(.2), ),
activeTrackColor: LKColors.lkBlue, ],
inactiveThumbColor: Colors.white.withOpacity(.5), ),
activeColor: Colors.white, ),
Padding(
padding: const EdgeInsets.only(bottom: 5),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Adaptive Stream'),
Switch(
value: _adaptiveStream,
onChanged: (value) => _setAdaptiveStream(value),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 25),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('Dynacast'),
Switch(
value: _dynacast,
onChanged: (value) => _setDynacast(value),
), ),
], ],
), ),
+14 -9
View File
@@ -57,15 +57,20 @@ class LiveKitTheme {
checkColor: MaterialStateProperty.all(Colors.white), checkColor: MaterialStateProperty.all(Colors.white),
fillColor: MaterialStateProperty.all(accentColor), fillColor: MaterialStateProperty.all(accentColor),
), ),
// switchTheme: SwitchThemeData( switchTheme: SwitchThemeData(
// trackColor: MaterialStateProperty.resolveWith((states) { trackColor: MaterialStateProperty.resolveWith((states) {
// print('states: $states'); if (states.contains(MaterialState.selected)) {
// if (states.contains(MaterialState.disabled)) { return accentColor;
// return Colors.red; }
// } return accentColor.withOpacity(0.3);
// return accentColor; }),
// }), thumbColor: MaterialStateProperty.resolveWith((states) {
// ), if (states.contains(MaterialState.selected)) {
return Colors.white;
}
return Colors.white.withOpacity(0.3);
}),
),
dialogTheme: DialogTheme( dialogTheme: DialogTheme(
backgroundColor: cardColor, backgroundColor: cardColor,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(