Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LateInitializationError: Field '_theoPlayerViewController@654089593' has not been initialized. #75

Open
this-sunil opened this issue Dec 2, 2024 · 1 comment

Comments

@this-sunil
Copy link

late THEOplayer theOplayer;

theOplayer = THEOplayer(
fullscreenBuilder: (BuildContext context, THEOplayer player) {
// default, chromeless behaviour, same as not specifying a fullscreenBuilder.
return theOplayer.isInitialized==false?const Center(child: CircularProgressIndicator(color: Colors.white,strokeAlign: 2,strokeWidth: 2)):PlayerScreen(
isInPicture: isInPicture,
forwardController: _forwardController,
backwardController: _backwardController,
animationController: animationController,
theOplayer: theOplayer,
/embedInfo: embedInfo!/ id: widget.id,
image: widget.imgPath,
title: widget.title);
},
theoPlayerConfig: THEOplayerConfig(
license: "",
fullscreenConfiguration:
FullscreenConfig(fullscreenSystemUiMode: SystemUiMode.immersiveSticky, preferredFullscreenOrientations: [
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
], preferredRestoredOrientations: [
DeviceOrientation.portraitUp
]),
androidConfiguration: AndroidConfig.create(
viewComposition: AndroidViewComposition.TEXTURE_LAYER,
),

      // Extra THEOlive configuration:
      //theolive: TheoLiveConfiguration(externalSessionId: "mySessionID"),
    ),
    onCreate: () {
      print("main - THEOplayer - onCreate");

      theOplayer.source = SourceDescription(sources: [
        TypedSource(src: "https://cdn.theoplayer.com/video/big_buck_bunny/big_buck_bunny.m3u8"),
      ]);

      theOplayer.autoplay = true;
      theOplayer.allowBackgroundPlayback = false;

      animationController.forward();
      theOplayer.videoTracks.map((e) {
        print("Video ${e.activeQuality}");
      }).toList();
      theOplayer.audioTracks.map((e) {
        print("Audio ${e.activeQuality}");
      }).toList();
      theOplayer.allowAutomaticPictureInPicture = false;
      isInPicture = false;
      if (kIsWeb) {
        theOplayer.setPresentationMode(PresentationMode.PIP);
      }

      theOplayer.addEventListener(PlayerEventTypes.ERROR, (errorEvent) {
        var error = errorEvent as ErrorEvent;
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            duration: const Duration(milliseconds: 6000),
            backgroundColor: Colors.red,
            content: Text(error.error),
            action: SnackBarAction(
              label: 'OK',
              onPressed: () {
                // Code to execute.
              },
            ),
          ),
        );
      });
      theOplayer.addEventListener(PlayerEventTypes.WAITING, (event) {
        isLoading = false;
        setState(() {});
        print("Player is buffering ${event.type}");
      });

      theOplayer.addEventListener(PlayerEventTypes.PLAYING, (event) {
        isLoading = true;
        setState(() {});
        print("Player is Paying ${event.type}");
      });
    });

can't initialize

@Danesz
Copy link
Collaborator

Danesz commented Dec 4, 2024

Hi @this-sunil ,

Do you have a stack trace of the problem?

Usually, this issue happens if you try to access the player before the player's onCreate()callback is called.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants