Flutter AWS : how to authenticate IAM role user of bucket and get AWS S3 object of hls video file and play in video player?
Asked Answered
H

1

8

how to authenticate IAM role user by region, bucket id,access key and sceret key and get video file object and play in video player. Actually we have uploaded video files in AWS S3 and given access grant to one IAM role user.

Now from the flutter app, I need to authenticate the IAM user by accesskey, secretkey, and get the video object & play in a video player without saving or downloading in local.

i tried with plugin,

flutter_aws_s3_client: ^0.5.0

const region = "<region>";
const bucketId = "<bucket id>";
final AwsS3Client s3client = AwsS3Client(
    region: region,
    host: "s3.$region.amazonaws.com",
    bucketId: bucketId,
    accessKey: "<accesskey>",
    secretKey: "<secretkey>");

//object video name 
final response = await s3client.getObject("example_test.m3u8");

here I got the object response as 200, but how can I pass and play this video file in the video player ? is there any way? I have tried with adding HEADER in expo player android video_player_plugin.dart. but no luck.

video player Plugin

video_player: ^0.10.11+1

class _VideoAppState extends State<VideoApp> {
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network('//need to pass the videoUrl of AWS S3')
      ..initialize().then((_) {
        setState(() {});
      });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        body: Center(
          child: _controller.value.initialized
              ? AspectRatio(
                  aspectRatio: _controller.value.aspectRatio,
                  child: VideoPlayer(_controller),
                )
              : Container(),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              _controller.value.isPlaying
                  ? _controller.pause()
                  : _controller.play();
            });
          },
          child: Icon(
            _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }

so help me out how to solve this?

Thanks in advance

Hotchkiss answered 8/6, 2020 at 10:55 Comment(2)
Did you manage to find the solutionTillfourd
Same, did you ever work this out via Dart?Collaborative
B
0

for that you need follow some steps 1:get access response 2: then redirect or call that video widget so you load that video

Beeck answered 23/9, 2022 at 7:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.