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] Video doesnt play (android) #1259

Open NerdyBoy-V opened 1 year ago

NerdyBoy-V commented 1 year ago

History check Please confirm that you've checked issues history and you didn't find anything which may solve your issue.

Describe the bug The video doesnt play. I try to play a video from url, but it doesn't work. The videoplayer keeps loading but never plyas (or finds) the video.

*Example code import 'dart:io';

import 'package:flutter/material.dart'; import 'package:better_player/better_player.dart'; import 'package:flutter/services.dart';

class BetterPlayerScreen extends StatefulWidget { // final String videoPath;

BetterPlayerScreen();

@override _BetterPlayerScreenState createState() => _BetterPlayerScreenState(); }

class _BetterPlayerScreenState extends State { late BetterPlayerController _betterPlayerController; late BetterPlayerDataSource _betterPlayerDataSource;

@override void initState() { super.initState(); _initializePlayer(); }

void _initializePlayer() { _betterPlayerDataSource = BetterPlayerDataSource( BetterPlayerDataSourceType.network, 'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4', );

_betterPlayerController =
    BetterPlayerController(BetterPlayerConfiguration());
_betterPlayerController.setupDataSource(_betterPlayerDataSource);
super.initState();

}

@override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('BetterPlayer'), ), body: Center( child: AspectRatio( aspectRatio: 16 / 9, child: BetterPlayer(controller: _betterPlayerController), ), ), ); }

@override void dispose() { _betterPlayerController.dispose(); super.dispose(); } }

Expected behavior A clear and concise description of what you expected to happen.

Screenshots Schermafbeelding 2023-10-04 om 15 45 47

Flutter doctor Please add flutter doctor output here.

Better Player version

Smartphone (please complete the following information):

Additional context I tried different url's but none works.

NerdyBoy-V commented 1 year ago

Nevermind. i had to add better_player: git: 'https://github.com/AnonymHK/betterplayer.git'

and everything works now
lucasdonordeste commented 1 year ago

I received this error too. I installed pakcage in a new project and it worked very well, but in my project that already had better_player it didn't work and this error appears:

E/MethodChannel#better_player_channel(29943): Failed to handle method call E/MethodChannel#better_player_channel(29943): 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(29943): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/MethodChannel#better_player_channel(29943): at com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory.setDrmSessionManagerProvider(HlsMediaSource.java:306) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:424) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/MethodChannel#better_player_channel(29943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/MethodChannel#better_player_channel(29943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#better_player_channel(29943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:322) E/MethodChannel#better_player_channel(29943): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#better_player_channel(29943): at android.os.Handler.handleCallback(Handler.java:938) E/MethodChannel#better_player_channel(29943): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#better_player_channel(29943): at android.os.Looper.loop(Looper.java:246) E/MethodChannel#better_player_channel(29943): at android.app.ActivityThread.main(ActivityThread.java:8653) E/MethodChannel#better_player_channel(29943): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#better_player_channel(29943): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) E/MethodChannel#better_player_channel(29943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) E/flutter (29943): [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 (29943): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/flutter (29943): at com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory.setDrmSessionManagerProvider(HlsMediaSource.java:306) E/flutter (29943): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:424) E/flutter (29943): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/flutter (29943): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/flutter (29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/flutter (29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/flutter (29943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/flutter (29943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter (29943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:322) E/flutter (29943): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter (29943): at android.os.Handler.handleCallback(Handler.java:938) E/flutter (29943): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter (29943): at android.os.Looper.loop(Looper.java:246) E/flutter (29943): at android.app.ActivityThread.main(ActivityThread.java:8653) E/flutter (29943): at java.lang.reflect.Method.invoke(Native Method) E/flutter (29943): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) E/flutter (29943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) E/flutter (29943): ) E/flutter (29943): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7) E/flutter (29943): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #2 MethodChannelVideoPlayer.setDataSource (package:better_player/src/video_player/method_channel_video_player.dart:118:5) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #3 VideoPlayerController._setDataSource (package:better_player/src/video_player/video_player.dart:408:5) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #4 BetterPlayerController._setupDataSource (package:better_player/src/core/better_player_controller.dart:444:9) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #5 BetterPlayerController.setupDataSource (package:better_player/src/core/better_player_controller.dart:274:5) E/flutter (29943): <asynchronous suspension> E/flutter (29943):

pawan-joshee commented 1 year ago

Same Issue occurred here. Video is always in loading state. I'm using it from last one year but this issue is causing from last 5-7 days. As we can see that 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. but I'm not using any DRM.

D/EGL_emulation( 7380): app_time_stats: avg=10036.79ms min=10.89ms max=220449.91ms count=22 I/flutter ( 7380): 1695836328752contentID I/ExoPlayerImpl( 7380): Init cb1a548 [ExoPlayerLib/2.18.7] [emu64a, sdk_gphone64_arm64, Google, 33] E/MethodChannel#better_player_channel( 7380): Failed to handle method call E/MethodChannel#better_player_channel( 7380): 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( 7380): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/MethodChannel#better_player_channel( 7380): at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:190) E/MethodChannel#better_player_channel( 7380): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:430) E/MethodChannel#better_player_channel( 7380): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/MethodChannel#better_player_channel( 7380): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/MethodChannel#better_player_channel( 7380): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/MethodChannel#better_player_channel( 7380): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/MethodChannel#better_player_channel( 7380): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/MethodChannel#better_player_channel( 7380): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#better_player_channel( 7380): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/MethodChannel#better_player_channel( 7380): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#better_player_channel( 7380): at android.os.Handler.handleCallback(Handler.java:942) E/MethodChannel#better_player_channel( 7380): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#better_player_channel( 7380): at android.os.Looper.loopOnce(Looper.java:201) E/MethodChannel#better_player_channel( 7380): at android.os.Looper.loop(Looper.java:288) E/MethodChannel#better_player_channel( 7380): at android.app.ActivityThread.main(ActivityThread.java:7898) E/MethodChannel#better_player_channel( 7380): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#better_player_channel( 7380): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/MethodChannel#better_player_channel( 7380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) E/flutter ( 7380): [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 ( 7380): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/flutter ( 7380): at com.google.android.exoplayer2.source.ProgressiveMediaSource$Factory.setDrmSessionManagerProvider(ProgressiveMediaSource.java:190) E/flutter ( 7380): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/flutter ( 7380): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/flutter ( 7380): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/flutter ( 7380): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/flutter ( 7380): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/flutter ( 7380): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter ( 7380): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322) E/flutter ( 7380): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter ( 7380): at android.os.Handler.handleCallback(Handler.java:942) E/flutter ( 7380): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter ( 7380): at android.os.Looper.loopOnce(Looper.java:201) E/flutter ( 7380): at android.os.Looper.loop(Looper.java:288) E/flutter ( 7380): at android.app.ActivityThread.main(ActivityThread.java:7898) E/flutter ( 7380): at java.lang.reflect.Method.invoke(Native Method) E/flutter ( 7380): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/flutter ( 7380): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) E/flutter ( 7380): ) E/flutter ( 7380): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7) E/flutter ( 7380): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18) E/flutter ( 7380): <asynchronous suspension> E/flutter ( 7380): #2 MethodChannelVideoPlayer.setDataSource (package:better_player/src/video_player/method_channel_video_player.dart:118:5) E/flutter ( 7380): <asynchronous suspension> E/flutter ( 7380): #3 VideoPlayerController._setDataSource (package:better_player/src/video_player/video_player.dart:408:5) E/flutter ( 7380): <asynchronous suspension> E/flutter ( 7380): #4 BetterPlayerController._setupDataSource (package:better_player/src/core/better_player_controller.dart:444:9) E/flutter ( 7380): <asynchronous suspension> E/flutter ( 7380): #5 BetterPlayerController.setupDataSource (package:better_player/src/core/better_player_controller.dart:274:5) E/flutter ( 7380): <asynchronous suspension> E/flutter ( 7380):

i9suaradio commented 1 year ago

Nevermind. i had to add better_player: git: 'https://github.com/AnonymHK/betterplayer.git'

and everything works now

Thanks a lot! This action fixed my problem!! You rock!

1771893348 commented 1 year ago

I received this error too. I installed pakcage in a new project and it worked very well, but in my project that already had better_player it didn't work and this error appears:

E/MethodChannel#better_player_channel(29943): Failed to handle method call E/MethodChannel#better_player_channel(29943): 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(29943): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/MethodChannel#better_player_channel(29943): at com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory.setDrmSessionManagerProvider(HlsMediaSource.java:306) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:424) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/MethodChannel#better_player_channel(29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/MethodChannel#better_player_channel(29943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/MethodChannel#better_player_channel(29943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#better_player_channel(29943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:322) E/MethodChannel#better_player_channel(29943): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/MethodChannel#better_player_channel(29943): at android.os.Handler.handleCallback(Handler.java:938) E/MethodChannel#better_player_channel(29943): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#better_player_channel(29943): at android.os.Looper.loop(Looper.java:246) E/MethodChannel#better_player_channel(29943): at android.app.ActivityThread.main(ActivityThread.java:8653) E/MethodChannel#better_player_channel(29943): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#better_player_channel(29943): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) E/MethodChannel#better_player_channel(29943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) E/flutter (29943): [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 (29943): at com.google.android.exoplayer2.util.Assertions.checkNotNull(Assertions.java:174) E/flutter (29943): at com.google.android.exoplayer2.source.hls.HlsMediaSource$Factory.setDrmSessionManagerProvider(HlsMediaSource.java:306) E/flutter (29943): at com.jhomlala.better_player.BetterPlayer.buildMediaSource(BetterPlayer.kt:424) E/flutter (29943): at com.jhomlala.better_player.BetterPlayer.setDataSource(BetterPlayer.kt:196) E/flutter (29943): at com.jhomlala.better_player.BetterPlayerPlugin.setDataSource(BetterPlayerPlugin.kt:277) E/flutter (29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:151) E/flutter (29943): at com.jhomlala.better_player.BetterPlayerPlugin.onMethodCall(BetterPlayerPlugin.kt:138) E/flutter (29943): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/flutter (29943): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/flutter (29943): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:322) E/flutter (29943): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) E/flutter (29943): at android.os.Handler.handleCallback(Handler.java:938) E/flutter (29943): at android.os.Handler.dispatchMessage(Handler.java:99) E/flutter (29943): at android.os.Looper.loop(Looper.java:246) E/flutter (29943): at android.app.ActivityThread.main(ActivityThread.java:8653) E/flutter (29943): at java.lang.reflect.Method.invoke(Native Method) E/flutter (29943): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) E/flutter (29943): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) E/flutter (29943): ) E/flutter (29943): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7) E/flutter (29943): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #2 MethodChannelVideoPlayer.setDataSource (package:better_player/src/video_player/method_channel_video_player.dart:118:5) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #3 VideoPlayerController._setDataSource (package:better_player/src/video_player/video_player.dart:408:5) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #4 BetterPlayerController._setupDataSource (package:better_player/src/core/better_player_controller.dart:444:9) E/flutter (29943): <asynchronous suspension> E/flutter (29943): #5 BetterPlayerController.setupDataSource (package:better_player/src/core/better_player_controller.dart:274:5) E/flutter (29943): <asynchronous suspension> E/flutter (29943):

请问您是怎么解决的