jhomlala / betterplayer

Better video player for Flutter, with multiple configuration options. Solving typical use cases!
Apache License 2.0
932 stars 1.04k forks source link

[BUG] android not playing #1228

Open heshesh2010 opened 1 year ago

heshesh2010 commented 1 year ago

move file:

https://bieahbucket.s3.amazonaws.com/images/fulReILfMpLKxaUpy1Dc9yU3mDnyMQiznPCsO3vs.mov

E/MethodChannel#better_player_channel(18805): Failed to handle method call E/MethodChannel#better_player_channel(18805): java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior. E/MethodChannel#better_player_channel(18805): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/MethodChannel#better_player_channel(18805): at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:190) E/MethodChannel#better_player_channel(18805): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:430) E/MethodChannel#better_player_channel(18805): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/MethodChannel#better_player_channel(18805): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/MethodChannel#better_player_channel(18805): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/MethodChannel#better_player_channel(18805): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/MethodChannel#better_player_channel(18805): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/MethodChannel#better_player_channel(18805): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#better_player_channel(18805): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/MethodChannel#better_player_channel(18805): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#better_player_channel(18805): at android.os.Handler.handleCallback(Handler.java:942) E/MethodChannel#better_player_channel(18805): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#better_player_channel(18805): at android.os.Looper.loopOnce(Looper.java:226) E/MethodChannel#better_player_channel(18805): at android.os.Looper.loop(Looper.java:313) E/MethodChannel#better_player_channel(18805): at android.app.ActivityThread.main(ActivityThread.java:8757) E/MethodChannel#better_player_channel(18805): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#better_player_channel(18805): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) E/MethodChannel#better_player_channel(18805): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067) E/flutter (18805): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior., null, java.lang.NullPointerException: MediaSource.Factory#setDrmSessionManagerProvider no longer handles null by instantiating a new DefaultDrmSessionManagerProvider. Explicitly construct and pass an instance in order to retain the old behavior. E/flutter (18805): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/flutter (18805): at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:190)

flutter doctor hesham@HeshamElnemrs-MacBook-Pro ios % flutter doctor Doctor summary (to see all details, run flutter doctor -v): [!] Flutter (Channel stable, 3.10.5, on macOS 13.4.1 22F82 darwin-x64, locale en-EG) ! Warning: dart on your path resolves to /usr/local/Cellar/dart/2.18.4/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/hesham/flutter. Consider adding /Users/hesham/flutter/bin to the front of your path. [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.3.1) [✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. [✓] Android Studio (version 2021.2) [✓] VS Code (version 1.79.2) [✓] Connected device (3 available) [✓] Network resources

my code

@override void initState() { BetterPlayerConfiguration betterPlayerConfiguration = BetterPlayerConfiguration( showPlaceholderUntilPlay: true, placeholder: Center( child: LoadingDialog1(backGroundColor: Colors.white.withOpacity(.5)), ),

  autoPlay: true,
  fullScreenByDefault: true,
  aspectRatio: 16 / 9,
  // deviceOrientationsAfterFullScreen: [
  //   DeviceOrientation.portraitDown,
  //   DeviceOrientation.portraitUp
  // ],

  // controlsConfiguration: const BetterPlayerControlsConfiguration(
  //   enableFullscreen: false,
  //   enableSkips: false,
  //   enableOverflowMenu: false,
  //   enablePip: false,
  //   enableMute: false,
  //   enableProgressBar: false,
  //   enablePlayPause: false,
  //   enableSubtitles: false,
  //   enableQualities: false,
  //   enablePlaybackSpeed: false,
  //   enableAudioTracks: false,
  //   enableProgressText: false,
  //   controlBarHeight: 0,
  // ),

  errorBuilder: (context, errorMessage) {
    return const Center(
      child: Text(
        "حدث خطأ أثناء تشغيل الفيديو",
        style: TextStyle(color: Colors.white),
      ),
    );
  },
  // aspectRatio: 16 / 9,
  fit: BoxFit.fill,
);

// betterPlayerController.addEventsListener(_handleEvent);

var betterPlayerDataSource = BetterPlayerDataSource(
  BetterPlayerDataSourceType.network,
  widget.product.images![0].videoUrl.toString(),
  // videoFormat: BetterPlayerVideoFormat.other,
  placeholder: Center(
    child: LoadingDialog1(backGroundColor: Colors.white.withOpacity(.5)),
  ),
  cacheConfiguration: BetterPlayerCacheConfiguration(
    useCache: true,
    preCacheSize: 10 * 1024 * 1024,
    maxCacheSize: 10 * 1024 * 1024,
    maxCacheFileSize: 10 * 1024 * 1024,

    ///Android only option to use cached video between app sessions
    key: widget.product.images![0].videoUrl.toString(),
  ),
);
betterPlayerController = BetterPlayerController(betterPlayerConfiguration);

betterPlayerController.preCache(betterPlayerDataSource);

betterPlayerController.setupDataSource(betterPlayerDataSource);
super.initState();

}