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 configure http headers for media_kit? #92

Closed Carseason closed 1 year ago

Carseason commented 1 year ago

main:

void main() async {
  MediaKit.ensureInitialized();
  initMeeduPlayer(
    androidUseMediaKit: config.isAndroid(),
    iosUseMediaKit: config.isIos(),
  );
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

player:

 final pl = MeeduPlayerController(
    controlsStyle: ControlsStyle.secondary,
  );
 pl.setDataSource(
      DataSource(
        type: DataSourceType.network,
        httpHeaders: headers,
        source: widget.url,
      ),
      autoplay: true,
    );
 MeeduVideoPlayer(
                controller: pl,
              );
abdelaziz-mahdy commented 1 year ago

Media_kit headers are handled by the package when sent to setdatasource

Carseason commented 1 year ago

Media_kit headers are handled by the package when sent to setdatasource

do i need to do something? Now I can't receive the http header....

abdelaziz-mahdy commented 1 year ago

You will just pass the http headers in set data source and the video should play correctly, if you have a problem can you elaborate more

Carseason commented 1 year ago

pubspec.yaml

  flutter_meedu_videoplayer: ^4.2.10
  media_kit_libs_ios_video: ^1.0.4
  media_kit_libs_android_video: ^1.0.3

server will intercept http header authentication。 Cannot receive http header cookie after using media_kit. otherwise everything works fine

abdelaziz-mahdy commented 1 year ago

Can you provide an error, or a better definition to your problem , or everything works correctly?

Carseason commented 1 year ago

my server will verify cookies, if used

  initMeeduPlayer(
    androidUseMediaKit: true,
  );

I can't get any cookies on the server, When

androidUseMediaKit: false 

my server can receive cookies normally, There is no error in flutter_meedu_videoplayer, only the log that my server cannot receive cookies

abdelaziz-mahdy commented 1 year ago

Maybe it's an issue with media_kit or by my handling for http headers

But I am waiting for the new release of media_kit since it adds official http headers support

Carseason commented 1 year ago

https://github.com/alexmercerind/media_kit/pull/147 Looking forward to your work, I will close the issue once it is done thanks for your project

Carseason commented 1 year ago

my server request header

map['cookie:[sysauth_http=xxxxxxx'] Accept:[*/*] Connection:[close] Icy-Metadata:[1] Range:[bytes=0-] User-Agent:[libmpv]]

Cookies have redundant symbols。

abdelaziz-mahdy commented 1 year ago

I think it may be due to me not handling : I remember that people had problems with symbols in general (don't remember which ones)

In the pr Alex fixed that problem this is why I am waiting for the new release

abdelaziz-mahdy commented 1 year ago

flutter pub upgrade

should fix your issue, let me know if it does

Carseason commented 1 year ago

The header is read correctly, I'm working on something else, thanks for your work