Add web HTTP-FLV playback path
This commit is contained in:
@@ -33,12 +33,22 @@ class _HomePageState extends State<HomePage> {
|
||||
if (isWide)
|
||||
NavigationRail(
|
||||
selectedIndex: _selectedIndex,
|
||||
onDestinationSelected: (int index) => setState(() => _selectedIndex = index),
|
||||
onDestinationSelected: (int index) =>
|
||||
setState(() => _selectedIndex = index),
|
||||
labelType: NavigationRailLabelType.all,
|
||||
destinations: const [
|
||||
NavigationRailDestination(icon: Icon(Icons.explore), label: Text('Explore')),
|
||||
NavigationRailDestination(icon: Icon(Icons.videocam), label: Text('Console')),
|
||||
NavigationRailDestination(icon: Icon(Icons.settings), label: Text('Settings')),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.explore),
|
||||
label: Text('Explore'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.videocam),
|
||||
label: Text('Console'),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.settings),
|
||||
label: Text('Settings'),
|
||||
),
|
||||
],
|
||||
),
|
||||
Expanded(child: _pages[_selectedIndex]),
|
||||
@@ -47,11 +57,21 @@ class _HomePageState extends State<HomePage> {
|
||||
bottomNavigationBar: !isWide
|
||||
? NavigationBar(
|
||||
selectedIndex: _selectedIndex,
|
||||
onDestinationSelected: (int index) => setState(() => _selectedIndex = index),
|
||||
onDestinationSelected: (int index) =>
|
||||
setState(() => _selectedIndex = index),
|
||||
destinations: const [
|
||||
NavigationDestination(icon: Icon(Icons.explore), label: 'Explore'),
|
||||
NavigationDestination(icon: Icon(Icons.videocam), label: 'Console'),
|
||||
NavigationDestination(icon: Icon(Icons.settings), label: 'Settings'),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.explore),
|
||||
label: 'Explore',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.videocam),
|
||||
label: 'Console',
|
||||
),
|
||||
NavigationDestination(
|
||||
icon: Icon(Icons.settings),
|
||||
label: 'Settings',
|
||||
),
|
||||
],
|
||||
)
|
||||
: null,
|
||||
@@ -100,7 +120,10 @@ class _ExploreViewState extends State<_ExploreView> {
|
||||
if (mounted) setState(() => _activeRooms = data['active_rooms'] ?? []);
|
||||
}
|
||||
} catch (e) {
|
||||
if (!isAuto && mounted) ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text("Failed to load rooms")));
|
||||
if (!isAuto && mounted)
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text("Failed to load rooms")));
|
||||
} finally {
|
||||
if (!isAuto && mounted) setState(() => _isLoading = false);
|
||||
}
|
||||
@@ -114,8 +137,14 @@ class _ExploreViewState extends State<_ExploreView> {
|
||||
appBar: AppBar(
|
||||
title: Text("Explore", style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
actions: [
|
||||
IconButton(icon: Icon(Icons.refresh), onPressed: () => _refreshRooms()),
|
||||
IconButton(icon: Icon(Icons.logout), onPressed: () => context.read<AuthProvider>().logout()),
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
onPressed: () => _refreshRooms(),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.logout),
|
||||
onPressed: () => context.read<AuthProvider>().logout(),
|
||||
),
|
||||
],
|
||||
),
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
@@ -128,33 +157,42 @@ class _ExploreViewState extends State<_ExploreView> {
|
||||
child: _isLoading && _activeRooms.isEmpty
|
||||
? Center(child: CircularProgressIndicator())
|
||||
: _activeRooms.isEmpty
|
||||
? ListView(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 100),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.live_tv_outlined, size: 80, color: Colors.grey),
|
||||
SizedBox(height: 16),
|
||||
Text("No active rooms. Be the first!", style: TextStyle(color: Colors.grey, fontSize: 16)),
|
||||
],
|
||||
),
|
||||
)
|
||||
])
|
||||
: GridView.builder(
|
||||
padding: EdgeInsets.all(12),
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 400,
|
||||
childAspectRatio: 1.2,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
? ListView(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 100),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.live_tv_outlined,
|
||||
size: 80,
|
||||
color: Colors.grey,
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
Text(
|
||||
"No active rooms. Be the first!",
|
||||
style: TextStyle(color: Colors.grey, fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
itemCount: _activeRooms.length,
|
||||
itemBuilder: (context, index) {
|
||||
final room = _activeRooms[index];
|
||||
return _buildRoomCard(room, settings);
|
||||
},
|
||||
),
|
||||
],
|
||||
)
|
||||
: GridView.builder(
|
||||
padding: EdgeInsets.all(12),
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: 400,
|
||||
childAspectRatio: 1.2,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
),
|
||||
itemCount: _activeRooms.length,
|
||||
itemBuilder: (context, index) {
|
||||
final room = _activeRooms[index];
|
||||
return _buildRoomCard(room, settings);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -166,13 +204,13 @@ class _ExploreViewState extends State<_ExploreView> {
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
final rtmpUrl = "${settings.rtmpUrl}/${room['room_id']}";
|
||||
final playbackUrl = settings.playbackUrl(room['room_id'].toString());
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PlayerPage(
|
||||
title: room['title'],
|
||||
rtmpUrl: rtmpUrl,
|
||||
playbackUrl: playbackUrl,
|
||||
roomId: room['room_id'].toString(),
|
||||
),
|
||||
),
|
||||
@@ -188,18 +226,37 @@ class _ExploreViewState extends State<_ExploreView> {
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).colorScheme.primaryContainer,
|
||||
child: Center(child: Icon(Icons.live_tv, size: 50, color: Theme.of(context).colorScheme.primary)),
|
||||
child: Center(
|
||||
child: Icon(
|
||||
Icons.live_tv,
|
||||
size: 50,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
top: 8, left: 8,
|
||||
top: 8,
|
||||
left: 8,
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(color: Colors.red, borderRadius: BorderRadius.circular(4)),
|
||||
child: Row(children: [
|
||||
Icon(Icons.circle, size: 8, color: Colors.white),
|
||||
SizedBox(width: 4),
|
||||
Text("LIVE", style: TextStyle(color: Colors.white, fontSize: 10, fontWeight: FontWeight.bold)),
|
||||
]),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(Icons.circle, size: 8, color: Colors.white),
|
||||
SizedBox(width: 4),
|
||||
Text(
|
||||
"LIVE",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -208,18 +265,35 @@ class _ExploreViewState extends State<_ExploreView> {
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 12,
|
||||
vertical: 8,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
CircleAvatar(radius: 16, child: Text(room['user_id'].toString().substring(0, 1))),
|
||||
CircleAvatar(
|
||||
radius: 16,
|
||||
child: Text(room['user_id'].toString().substring(0, 1)),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(room['title'], maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14)),
|
||||
Text("Host ID: ${room['user_id']}", style: TextStyle(fontSize: 12, color: Colors.grey)),
|
||||
Text(
|
||||
room['title'],
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
"Host ID: ${room['user_id']}",
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user