live_flutter_plugin 12.6.0
live_flutter_plugin: ^12.6.0 copied to clipboard
The solution allows anchors to compete with each other and co-anchor with viewers in real time, with a global end-to-end latency of below 300 ms on average.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:live_flutter_plugin/v2_tx_live_premier.dart';
import 'package:live_flutter_plugin/liteav_live_config.dart';
import 'v2_player_list_page.dart';
import 'v2_player_entrance_page.dart';
import 'debug/generate_test_user_sig.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter 视频云工具包',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomeListPage(),
);
}
}
class HomeItem {
String title;
Widget Function() function;
HomeItem(this.title, this.function);
}
class HomeListPage extends StatefulWidget {
const HomeListPage({Key? key}) : super(key: key);
@override
_HomeListState createState() => _HomeListState();
}
class _HomeListState extends State<HomeListPage> {
String? _version;
final List<HomeItem> homeItems = [
HomeItem('直播播放-V2', () => const V2TXLivePlayerEntrancePage()),
HomeItem('直播播放列表-V2', () => const V2TXLivePlayerListPage()),
];
@override
void initState() {
super.initState();
_initPlatformState();
}
@override
void deactivate() {
super.deactivate();
}
Future<void> _initPlatformState() async {
V2TXLivePremier.getSDKVersionStr().then((version) {
_version = "${LiteavLiveConfig.flutterSDKVersion}($version)";
print("VERSION: " + _version!);
setState(() {});
});
await V2TXLivePremier.setUserId("flutter_demo");
await V2TXLivePremier.setEnvironment("default");
await V2TXLivePremier.setLicence(GenerateTestUserSig.LICENSEURL, GenerateTestUserSig.LICENSEURLKEY);
await V2TXLivePremier.setObserver(_onPremierObserver);
}
void _onPremierObserver(type, param) {
if (type != V2TXLivePremierObserverType.onLog) {
print("_onPremierObserver, " + type.toString() + ":" + param.toString());
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter 视频云工具包'),
),
body: Column(
children: [
Expanded(
child: ListView.builder(
itemCount: homeItems.length,
itemBuilder: (context, index) {
final item = homeItems[index];
return ListTile(
title: Text(item.title),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => item.function()),
);
},
leading: const CircleAvatar(
backgroundColor: Colors.blue,
child: Icon(Icons.list, color: Colors.white),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
);
},
),
),
],
),
bottomNavigationBar: Container(
height: 56,
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center, // 仅水平居中
children: [
Text(
_version == null ? '加载中...' : '版本: v$_version',
),
],
),
),
),
);
}
}