5

When I run the flutter app's video page on the web, I get "Uncaught UnimplementedError: init() has not been implemented." error. On iOS or Android there is no error. Even though I initialized the sound to 0 but the result did not change. Where am i doing wrong?

Versions: video_player: ^2.6.1 chewie: ^1.5.0

import 'package:chewie/chewie.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:kindergarten/Models/School/Gallery/gallery_detail_model.dart';
import 'package:kindergarten/Utils/color_palette.dart';
import 'package:video_player/video_player.dart';

class VideoPlayerView extends StatefulWidget {
  const VideoPlayerView({super.key, required this.model});

  final GalleryDetailModel model;

  @override
  State<VideoPlayerView> createState() => _VideoPlayerViewState();
}

class _VideoPlayerViewState extends State<VideoPlayerView> {
  VideoPlayerController? _videoPlayerController;
  ChewieController? _chewieController;

  @override
  void initState() {
    super.initState();

    _initVideoPlayer();
  }

  void _initVideoPlayer() async {
    _videoPlayerController = VideoPlayerController.network(widget.model.videoUrl.value);

    await _videoPlayerController
      ?..initialize().then((value) => {
            widget.model.aspectRatio.value = _videoPlayerController!.value.aspectRatio,
            setState(() {
              if (kIsWeb) {
                _videoPlayerController?.setVolume(0);
              }
            })
          });

    _chewieController = ChewieController(videoPlayerController: _videoPlayerController!, autoPlay: false, allowMuting: true);
  }

  @override
  void dispose() {
    _videoPlayerController?.dispose();
    _chewieController?.dispose();

    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return _videoPlayerController!.value.isInitialized
        ? Chewie(controller: _chewieController!)
        : Center(child: CircularProgressIndicator(color: ColorPalette.yellow));
  }
}

Even though I initialized the sound to 0 and set auto play to false but the result did not change.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.