fluttercommunity / fluttercommunity/chewie
I can't play a live hls video in my app
- Dominant language
- Dart
- Stars
- 2.1k
- Forks
- 1.1k
- Avg merge
- 6d 8h
- Merged PRs (30d)
- 6
Description
I am facing a issue while running a Live HLS Video in my app here is a code for this:
It easily run recorded HLS video but no Live... Any solution for this...
```
`import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';`
`class Stream1 extends StatefulWidget {
final String videoUrl;
final String name;
const Stream1({Key? key, required this.videoUrl, required this.name})
: super(key: key);`
@override
State createState() {
return _Stream1State();
}
}
```
```
class _Stream1State extends State {
TargetPlatform? _platform;
late VideoPlayerController _videoPlayerController1;
ChewieController? _chewieController1;
@override
void initState() {
super.initState();
initializePlayer();
}
@override
void dispose() {
_videoPlayerController1.dispose();
_chewieController1?.dispose();
super.dispose();
}
Future initializePlayer() async {
_videoPlayerController1 = VideoPlayerController.networkUrl(
Uri.parse(widget.videoUrl),
videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true));
await _videoPlayerController1.initialize();
_createChewieController();
setState(() {});
}
void _createChewieController() {
_chewieController1 = ChewieController(
videoPlayerController: _videoPlayerController1,
autoPlay: true,
looping: true,
customControls: Column(
children: [
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.fromLTRB(8.0, 24.0, 8.0, 8.0),
child: Container(
padding: EdgeInsets.fromLTRB(8.0, 4.0, 8.0, 4.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8.0), // Set border radius
color: Colors.black.withOpacity(
0.5),
),
child: Text(
'${widget.name}',
style: TextStyle(
color: Colors.white,
fontSize: 12,
// fontWeight: FontWeight.bold,
),
),
),
),
),
LinearProgressIndicator(
value: 0.0, // Hide the progress bar
valueColor: AlwaysStoppedAnimation(
Colors.transparent),
backgroundColor:
Colors.transparent,
),
],
),
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: AppTheme.light.copyWith(
platform: _platform ?? Theme.of(context).platform,
),
home: Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(4.0),
child: _chewieController1 != null &&
_chewieController1!.videoPlayerController.value.isInitialized
? Chewie(
controller: _chewieController1!,
)
: CircularProgressIndicator(),
)),
),
);
}
}
`
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.