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

video play all in list #35

Closed
itsdani121 opened this issue Jan 25, 2022 · 5 comments
Closed

video play all in list #35

itsdani121 opened this issue Jan 25, 2022 · 5 comments

Comments

@itsdani121
Copy link

itsdani121 commented Jan 25, 2022

Hi, i am using this package with a better player which I initialize the controller then it plays all video which I set as a preload is playing even it did not visible on-screen even class close but still playing on the background before this package it did not any issue. kindly look into this matter here is my code: in which background some random music playing i even did not add or previous video audio also playing

PreloadPageView.builder(
          preloadPagesCount: 5,
          controller: PreloadPageController(),
          scrollDirection: Axis.vertical,
                itemBuilder: (BuildContext context, int index) {
                  return Container(
                    padding: EdgeInsets.only(bottom: 13.0),
                    child: Container(
                      child: Stack(
                        children: [
                          Container(
                            child: BetterPlayerListVideoPlayer(
                                          BetterPlayerDataSource(
                                              BetterPlayerDataSourceType.network,
                                              '${data[index]['media']}'),
                                          playFraction: 0.8,
                                          betterPlayerListVideoPlayerController:
                                              controller,
                                          configuration:
                                              BetterPlayerConfiguration(
                                            expandToFill: true,
                                            aspectRatio: 1.0,
                                            autoPlay: true,
                                            autoDispose: true,
                                            controlsConfiguration:
                                                BetterPlayerControlsConfiguration(
                                                    enableMute: false,
                                                    enableOverflowMenu: false,
                                                    enablePlayPause: false,
                                                    enableFullscreen: false,
                                                    enableSkips: false,
                                                    enableProgressText: false,
                                                    playIcon: CupertinoIcons
                                                        .play_arrow_solid,
                                                    controlBarColor:
                                                        Colors.transparent,
                                                    enableProgressBar: false),
                                          ),
                                        )
                             
                          ),
                        ],
                      ),
                    ),
                  );
                },
                itemCount: data.length,
              ),
@wrbl606
Copy link
Contributor

wrbl606 commented Jan 25, 2022

Videos are not visible, but are rendered just like the one that is visible. To preload the videos and play only if given page is visible you'll have to modify your video-playing widget to load the video at init and listen to commands from the parent (eg. with a controller), and in the parent widget you'll have to listen to 'onPageChanged(int index)' callback to detect which video page is currently visible and notify proper video widget.

This library doesn't know (or care) about the implementation details of the widgets you put to preload thus doesn't do anything special for not visible preloaded widgets.

@itsdani121
Copy link
Author

itsdani121 commented Jan 25, 2022 via email

@wrbl606
Copy link
Contributor

wrbl606 commented Jan 25, 2022

You didn't provide the whole code, so now I can only hint you:

  1. Disable auto play with autoPlay: false.
  2. You are giving the same controller to every page. I can't see where you do its initialisation, but every page should have it's own controller. If I presume correctly, you can generate a BetterPlayerListVideoPlayerController like that:
final controllers = List<BetterPlayerListVideoPlayerController>.generate(data.length, (_) => BetterPlayerListVideoPlayerController());
  1. Assign each generated controller to proper BetterPlayerListVideoPlayer, so instead betterPlayerListVideoPlayerController: controller, do betterPlayerListVideoPlayerController: controllers[index].
  2. Play selected video and stop other ones to make sure you only play one at time:
PreloadPageView.builder(
          onPageChanged: (index) { 
                 controllers.forEach((controller) => controller.pause());
                 controllers[index].play();
           }
...

@itsdani121
Copy link
Author

itsdani121 commented Jan 25, 2022 via email

@itsdani121
Copy link
Author

@wrbl606 i tried your solution it almost works fine but i want that first index video of initialpage video also auto play bcz on page changed video played but first index video not played or first page video not played

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