flutter - Flutter : 视频播放器
问题描述
我正在尝试添加 video_player 插件以在我的项目中显示视频,但项目正在崩溃并在控制台上显示
[错误:flutter/shell/platform/android/platform_view_android_jni_impl.cc(43)] java.lang.RuntimeException:attachToGLContext 期间出错(详见 logcat) E/flutter (15242):在 android.graphics.SurfaceTexture.attachToGLContext(SurfaceTexture .java:286) E/flutter (15242): F/flutter (15242): [致命:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1062)] 检查失败:CheckException(env)。F/libc (15242):致命信号 6 (SIGABRT),tid 15334 (1.raster) 中的代码 -6
这是我使用的方法
VideoPlayerController _controller;
@override
void initState() {
super.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(() {});
});
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
Container(
height: 200,
child: 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,
),
),
),),
所以谁能告诉我怎么了!
解决方案
推荐阅读
- xterm - URxvt 使用深色而不是浅色作为提示(xterm 使用)
- apache-spark - Spark Streaming 创建许多小文件
- javascript - 为什么在开发工具中检查时未定义 JS 中分配的变量?
- javascript - Convert javascript array into json array
- ios - 如何向 iOS UIWebView 添加导航?
- dump - 如何将特定进程转储到 RAM 文件
- php - Symfony,内存限制
- javascript - Mongoose/Mongodb:索引已经存在不同的选项
- javascript - 对 Firebase 身份验证做出反应
- security - 演示 XXE(XML 外部实体)攻击 - Spring Boot