简体   繁体   English

何以捕捉flutter video_player插件错误?

[英]Ho to catch flutter video_player plugin error?

How to catch error on flutter video_player plugin? 如何捕捉flutter video_player插件的错误? the error is Source error . 错误是Source error when this error occurred I want to display error message. 发生此错误时,我想显示错误消息。

I/ExoPlayerImpl(31473): Init 98a4284 [ExoPlayerLib/2.9.6] [kenzo, Redmi Note 3, Xiaomi, 23]
E/ExoPlayerImplInternal(31473): Source error.
E/ExoPlayerImplInternal(31473): com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors (MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, FlvExtractor, OggExtractor, PsExtractor, WavExtractor, AmrExtractor) could read the stream.
E/ExoPlayerImplInternal(31473):     at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractorHolder.selectExtractor(ExtractorMediaPeriod.java:973)
E/ExoPlayerImplInternal(31473):     at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:891)
E/ExoPlayerImplInternal(31473):     at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
E/ExoPlayerImplInternal(31473):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
E/ExoPlayerImplInternal(31473):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
E/ExoPlayerImplInternal(31473):     at java.lang.Thread.run(Thread.java:818)
I/flutter (31473): Another exception was thrown: A ChewieController was used after being disposed.
I/ExoPlayerImpl(31473): Release 98a4284 [ExoPlayerLib/2.9.6] [kenzo, Redmi Note 3, Xiaomi, 23] [goog.exo.core]

my code 我的代码

animeVidBloc.vidCtrl = VideoPlayerController.network(streamurl.src)
          ..initialize().then((_) {
            animeVidBloc.vidCtrl.pause();
            animeVidBloc.cheCtrl = ChewieController(
              videoPlayerController: animeVidBloc.vidCtrl,
              aspectRatio: animeVidBloc.vidCtrl.value.aspectRatio,
              autoPlay: false,
              looping: false,
              allowedScreenSleep: false,
            );
            animeVidBloc.isLoadingData = false;
            animeVidBloc.isLoadingVideo = false;
            animeVidBloc.cheCtrl.pause();
            animeVidBloc.rebuildWidgets(ids: ['body', 'download']);
          });

using .catch after initialize().then doesn't catch the error, example video https://str09.vidoza.net/x4lfoiywwbzpvjumxbaeidisvq6cmoufczvmicnesasm4zqpyunkofpekfla/v.mp4 initialize().then之后使用.catch initialize().then没有捕获错误,例如视频https://str09.vidoza.net/x4lfoiywwbzpvjumxbaeidisvq6cmoufczvmicnesasm4zqpyunkofpekfla/v.mp4

You can attach listener to the VidePlayerController object to catch states of the controller. 您可以将侦听器附加到VidePlayerController对象以捕获控制器的状态。

VideoPlayerController _controller = VideoPlayerController.network(
    "https://str09.vidoza.net/x4lfoiywwbzpvjumxbaeidisvq6cmoufczvmicnesasm4zqpyunkofpekfla/v.mp4")
  ..initialize();

_controller.addListener(() {
  if (_controller.value.hasError) {
    print(_controller.value.errorDescription);
  }
  if (_controller.value.initialized) {}
  if (_controller.value.isBuffering) {}
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM