0

I am using video_player package from flutter for displaying a video from url. The url is "https://storage.googleapis.com/gtv-videos-bucket/sample/ForBiggerEscapes.mp4".

There is button for taking screenshot of the different positions of the video and for that I am using video_thumbnail package from.

The code that i am using is attached below:

          FloatingActionButton(
            onPressed: () async {
              final SharedPreferences prefs =
                  await SharedPreferences.getInstance();
              VideoThumbnail.thumbnailFile(
                video:
                    'https://storage.googleapis.com/gtv-videos- 
                    bucket/sample/ForBiggerEscapes.mp4',
                imageFormat: ImageFormat.PNG,
                thumbnailPath: (await getTemporaryDirectory()).path,
                quality: 100,
                timeMs: _controller.value.position.inMilliseconds,
              ).then((value) {
                List<String> videoPathArray =
                    prefs.getStringList('imagePath') ?? [];
                videoPathArray.add(value ?? '');
                prefs.setStringList('imagePath', videoPathArray);
              });
            },
            child: const Icon(
              Icons.screenshot_rounded,
            ),
          ),

In the above code, (await getTemporaryDirectory()).path is used as path for storing the thumbnail from the video. I am also saving the thumbnail path to Shared preference.

Everything is working fine from the above code. But the problem is that every time the thumbnail is stored, the previous image is removed and new image is saved. Is there any way can we save different thumbnails to that directory.

My purpose was to display a list of screenshots of the video at different time intervals when the screenshot button is clicked during playing of the video.

viki
  • 404
  • 3
  • 14

0 Answers0