abdelaziz-mahdy / flutter_meedu_videoplayer

Cross-Platform Video Player for flutter
https://abdelaziz-mahdy.github.io/flutter_meedu_videoplayer/
MIT License
132 stars 69 forks source link

How to display the video from byte? #164

Closed SittiphanSittisak closed 10 months ago

SittiphanSittisak commented 10 months ago

This package supports the web platform but I can't convert the byte to a File with the io package that does not support the web platform. The DataSource supports File from the io package and the source with string type.

abdelaziz-mahdy commented 10 months ago

sadly its not supported by video_player interface, but media_kit can play local videos on web. so i recommend using media_kit for that case

SittiphanSittisak commented 10 months ago

I think byte or Uint8List are the basic types of all files and every platform supports this type. Can you add a solution to Uint8List instead of using the URL, File?

I found a solution to display this video from Uint8List by this but it does not work successfully for all browsers.

    final url = html.Url.createObjectUrlFromBlob(blob); //Uint8List can convert/revert to blob
    controller.setDataSource(
      DataSource(type: DataSourceType.network, source: url),
      autoplay: true,
    );
abdelaziz-mahdy commented 10 months ago

I think byte or Uint8List are the basic types of all files and every platform supports this type. Can you add a solution to Uint8List instead of using the URL, File?

I found a solution to display this video from Uint8List by this but it does not work successfully for all browsers.

    final url = html.Url.createObjectUrlFromBlob(blob); //Uint8List can convert/revert to blob
    controller.setDataSource(
      DataSource(type: DataSourceType.network, source: url),
      autoplay: true,
    );

You mean to integrate it in the package?

Isn't this fix enough?

SittiphanSittisak commented 10 months ago

I think if it is not supported as you said, that is enough.

sadly its not supported by video_player interface, but media_kit can play local videos on web. so i recommend using media_kit for that case

I can custom if/else statements for using this method for the web and using the convert to file solution on Android/iOS.

abdelaziz-mahdy commented 10 months ago

I think if it is not supported as you said, that is enough.

sadly its not supported by video_player interface, but media_kit can play local videos on web. so i recommend using media_kit for that case

I can custom if/else statements for using this method for the web and using the convert to file solution on Android/iOS.

Yeah custom imports for web since you are using html, sorry that I couldn't help also thanks for letting me know that it can be done ❤️

I always thought it was impossible