Click here to Skip to main content
15,887,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to make a reels app. I am getting this error, I checked other answers for this question all of them said there is a problem with the video but I am using cloud-firestore URL, the same URL is working for the listview Widget but not for pageview. The screen becomes completely blank when I navigate to this screen.

PageViewScreen :

class _PageViewBuilderState extends State<PageViewBuilder> {
  var network = '';
  VideoPlayerController? videoPlayerController;
  @override
  void initState() {
    super.initState();
    videoPlayerController = VideoPlayerController.network(network)
      ..addListener(() {})
      ..setLooping(true)
      ..initialize().then((value) => videoPlayerController!.play());
  }

  int _currentPage = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: StreamBuilder<QuerySnapshot<Map<String, dynamic>>>(
          stream:
              FirebaseFirestore.instance.collection('Imageurls').snapshots(),
          builder: (ctx, snapshot) {
            return !snapshot.hasData
                ? const Center(
                    child: CircularProgressIndicator(),
                  )
                : PageView.builder(
                    scrollDirection: Axis.vertical,
                    itemCount: snapshot.data!.docs.length,
                    onPageChanged: (int page) {
                      setState(() {
                        _currentPage = page;
                      });
                    },
                    itemBuilder: (BuildContext context, int index) {
                      return AspectRatio(
                        aspectRatio: VideoPlayerController.network(
                          snapshot.data!.docs[index].get('url'),
                        ).value.aspectRatio,
                        child: VideoPlayer(VideoPlayerController.network(
                          snapshot.data!.docs[index].get('url'),
                        )
                          ..addListener(() {})
                          ..setLooping(true)
                          ..initialize()
                              .then((value) => VideoPlayerController.network(
                                    snapshot.data!.docs[index].get('url'),
                                  ).play())),
                      );
                     
                    },
                  );
          }),
    );
  }
}


What I have tried:

I did try to use this same page builder for getting image from cloud at that time it was working
Posted

1 solution

Put this in your AndroidManifest.xml

<application ...
android:usescleartexttraffic="true" <="" pre="">
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900