AmityVideoPlayer Crashes When Playing Live Stream
Setup
amity_sdk: ^7.6.0amity_video_player: ^0.0.3- Flutter on iOS/Android
- Stream ID:
985afaf858b1aed32986f2d52f7e4376
What We’re Doing
We’re streaming via OBS using the stream URL and key from Amity Portal. The stream shows as LIVE in the portal and we can see it broadcasting there.
In our Flutter app, we’re trying to display this livestream in the feed using AmityVideoPlayer:
class _PostContentLivestreamState extends State<PostContentLivestream> {
AmityVideoContoller? _controller;
@override
void initState() {
super.initState();
_controller = AmityVideoContoller(streamId: widget.post.streamId!);
}
@override
void dispose() {
_controller?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AmityVideoPlayer(controller: _controller!);
}
}
The Errors
When the widget loads, we get these crashes:
Error 1: Null Check Exception
Unhandled Exception: Null check operator used on a null value
#0 StreamFunction.getStreamData (package:amity_sdk/src/functions/stream_function.dart:15:33)
#1 _AmityVideoPlayerState.initState (package:amity_video_player/core/presentation/amity_video_player.dart:53:39)
Console shows:
flutter: LIVE ----> false
flutter: STREAM DATA ----> Instance of 'PartialStreamData'
flutter: Error: Bad state: No element
Error 2: Disposal Crash
LateInitializationError: Field '_videoPlayerController' has not been initialized.
#0 _AmityVideoPlayerState._videoPlayerController
#1 _AmityVideoPlayerState.dispose (package:amity_video_player/core/presentation/amity_video_player.dart:223:5)
Error 3: VLC Player Fails
LateInitializationError: Field '_viewId' has not been initialized.
#0 VlcPlayerController._viewId
#1 VlcPlayerController.dispose (package:flutter_vlc_player/src/vlc_player_controller.dart:355:37)
PlatformException(channel-error, Unable to establish connection on channel., null, null)
These errors repeat in a loop, making the app unstable.
What We’ve Tried
Verified stream is live and broadcasting in Amity Portal (using OBS)
Confirmed streamId is valid and being passed correctly
Checked network connectivity
Still crashes every time
How Do We Fix This?
The stream is definitely live and working in the portal. What’s the correct way to implement AmityVideoPlayer for livestreams? Are there any specific configurations or initializations we’re missing?