AmityVideoPlayer crashes with null check error when playing livestream

AmityVideoPlayer Crashes When Playing Live Stream

Setup

  • amity_sdk: ^7.6.0
  • amity_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

  • :white_check_mark: Verified stream is live and broadcasting in Amity Portal (using OBS)
  • :white_check_mark: Confirmed streamId is valid and being passed correctly
  • :white_check_mark: Checked network connectivity
  • :warning: 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?

Hello @Pragyan_Deep_Gogoi , For this issue, our team recommends updating to the latest Flutter SDK version as several livestream-related fixes have been included.

Please refer to the changelog below and try again after updating:
:backhand_index_pointing_right: Flutter SDK v7.7.4 – 31 Oct 2025

Let us know if the issue persists after the update.

Hi @SocialPlus_Support , Yes the issue still persist even after upgrading to SDK v7.7.4.

Hello @Pragyan_Deep_Gogoi , This issue has been resolved in amity_video_player version 0.0.4. Please refer to the changelog here: Amity Video Player Changelog.

Kindly update to the latest version and check if the issue persists. If you encounter any further problems, feel free to let me know.

@SocialPlus_Support Thank you for updating amity_video_player to version 0.0.4 — the livestream player is now working correctly in our app.

We need clarification on a few points as we continue our integration:

1. Livestream Video Controls

Player controls are currently hidden for livestreams.
Can basic controls be enabled, or is this behavior intentional?

2. Missing channelId in SDK

getStream(streamId) does not return channelId, while the REST API does.
Is this expected, and will the SDK expose channelId in future updates?

3. Livestream Chat Not Enabled

We automatically join users to the respective channel when they open a livestream to allow viewing and sending chats.
However, sending messages returns:

“Livestream chat is not enabled.”

Does livestream chat need to be enabled for our account?
If yes, could you guide us on how to enable it?

4. Dashboard Missing Broadcast Option

Livestream channels do not show the “Broadcast Message” option, unlike community channels.
Is this a feature flag that needs to be activated on our dashboard?

Hello @Pragyan_Deep_Gogoi, our team has responded to your inquiry via email. For better tracking and visibility, please kindly use email as our primary channel going forward.