在我的 Android phone 上播放任何视频之前,Flutter 应用程序都会崩溃

Flutter app crashes for ANY VIDEO before it even starts playing on my Android phone

我正在尝试使用 flutter 中的这个 video_player 插件,但我无法播放任何视频。即使是他们自己的例子中的那些,也会导致应用程序在我尝试播放时崩溃。我尝试使用不同的小部件,如 futureBuilder,但也没有成功。我搜索了很多,发现了一些关于 运行 视频的三星问题,但那是荒谬的。任何帮助不胜感激

这是堆栈跟踪:

I/ACodec  (18054): [] onAllocateComponent
I/OMXClient(18054): Using client-side OMX mux.
I/ACodec  (18054): [OMX.SEC.aac.dec] Now Loaded
I/ACodec  (18054): codec does not support config operating rate (err -1010)
I/ACodec  (18054): [OMX.SEC.aac.dec] Now Loaded->Idle
I/ACodec  (18054): [OMX.SEC.aac.dec] Now Idle->Executing
I/ACodec  (18054): [OMX.SEC.aac.dec] Now Executing
I/System.out(18054): (HTTPLog)-Static: isSBSettingEnabled false
I/System.out(18054): (HTTPLog)-Static: isSBSettingEnabled false
I/ACodec  (18054): [OMX.qcom.video.decoder.avc] Now handling output port settings change
D/SurfaceUtils(18054): set up nativeWindow 0xb8f94d78 for 1280x720, color 0x7fa30c04, rotation 0, usage 0x42002900
I/ACodec  (18054): [OMX.qcom.video.decoder.avc] configureOutputBuffersFromNativeWindow setBufferCount : 11, minUndequeuedBuffers : 5
I/ACodec  (18054): [OMX.qcom.video.decoder.avc] Now Executing
E/GLConsumer(18054): [SurfaceTexture-0-18054-0] attachToContext: invalid current EGLDisplay
E/flutter (18054): [ERROR:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.RuntimeException: Error during attachToGLContext (see logcat for details)
E/flutter (18054):  at android.graphics.SurfaceTexture.attachToGLContext(SurfaceTexture.java:286)
E/flutter (18054):
F/flutter (18054): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1062)] Check failed: CheckException(env).
F/libc    (18054): Fatal signal 6 (SIGABRT), code -6 in tid 18097 (1.raster)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/a5lteub/a5lte:6.0.1/MMB29M/A500MUBS1CRI6:user/release-keys'
Revision: '10'
ABI: 'arm'
pid: 18054, tid: 18097, name: 1.raster  >>> com.example.QrCode <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1062)] Check failed: CheckException(env).
'
    r0 00000000  r1 000046b1  r2 00000006  r3 9e25c978
    r4 9e25c980  r5 9e25c930  r6 00000000  r7 0000010c
    r8 9e25b280  r9 b8ced2a0  sl 9e25c4e0  fp b8bbe958
    ip 00000006  sp 9e25ae40  lr b6cd8f15  pc b6cdb310  cpsr 400f0010
backtrace:
    #00 pc 00044310  /system/lib/libc.so (tgkill+12)
    #01 pc 00041f11  /system/lib/libc.so (pthread_kill+32)
    #02 pc 0001ba13  /system/lib/libc.so (raise+10)
    #03 pc 00018c81  /system/lib/libc.so (__libc_android_abort+34)
    #04 pc 00016840  /system/lib/libc.so (abort+4)
    #05 pc 00012583  /data/app/com.example.QrCode-2/lib/arm/libflutter.so (offset 0x1002000)

这是代码:

import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class VideoPlayerView extends StatefulWidget {
  VideoPlayerView({
    Key key,
    @required this.videoFile,
  }) : super(key: key);

  final File videoFile;

  // VideoPlayerView({
  //   @required this.videoFile,
  // });

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

class _VideoPlayerViewState extends State<VideoPlayerView> {
  VideoPlayerController _controller;

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
        'http://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4')
      ..initialize().then((_) {
        // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
        setState(() {
          _controller.play();
        });
      });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Video Demo',
      home: Scaffold(
        body: Center(
          child: _controller.value.initialized
              ? AspectRatio(
                  aspectRatio: _controller.value.aspectRatio,
                  child: VideoPlayer(_controller),
                )
              : Container(),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            setState(() {
              _controller.value.isPlaying
                  ? _controller.pause()
                  : _controller.play();
            });
          },
          child: Icon(
            _controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
          ),
        ),
      ),
    );
  }

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

好的,我发现当我不在“我的 phone 上的调试模式”时它可以工作。也就是说,如果我从计算机上拔下 phone,然后 运行 单独 phone 上的应用程序,则视频可以正常播放。它对我来说并不完美,但我不会浪费时间。