1

I tried two packages to manage this (video player & native_video_view) problem. When i use network videos my code working well. First im downloading media file from app. Than im uploading same file and creating a thumbnail for that video. When i tried to watch , video is not showing. Path is correct.

This is my function.


  void _loadStory({required Story story, bool animateToPage = true}) {
    _animController.stop();
    _animController.reset();
    switch (story.media) {
      case MediaType.image:
        _animController.duration = story.duration;
        _animController.forward();
        break;
      case MediaType.video:
        _videoController = null;
        _videoController?.dispose();
        _videoController = VideoPlayerController.file(
          File(story.url),
          videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
        )..initialize().then((_) {
            setState(() {});
            if (_videoController!.value.isInitialized) {
              _animController.duration = _videoController!.value.duration;
              _videoController!.play();
              _animController.forward();
            }
          });
        // _videoController = VideoPlayerController.network(
        //   story.url,
        //   videoPlayerOptions: VideoPlayerOptions(mixWithOthers: true),
        // )..initialize().then((_) {
        //     setState(() {});
        //     if (_videoController!.value.isInitialized) {
        //       _animController.duration = _videoController!.value.duration;
        //       _videoController!.play();
        //       _animController.forward();
        //     }
        //   });
        break;
    }
    if (animateToPage) {
      _pageController.animateToPage(
        _currentIndex,
        duration: const Duration(milliseconds: 1),
        curve: Curves.easeInOut,
      );
    }
  }
}

This is error


Unhandled Exception: PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: Source error, null, null
demonjoseph
  • 211
  • 1
  • 3
  • 10

0 Answers0