flutter - 视频不可见,但音频在 iOS 中工作正常,颤动视频播放器
问题描述
这在 android 设备中运行良好,音频和视频都在相应地播放。但在 iOS 的情况下,只有音频工作,没有视觉效果。我正在 iOS 模拟器中运行该应用程序。我还在 GitHub 上搜索了这个问题,人们建议它可以在真实设备上正常工作,但事实并非如此。
这是我播放视频的整个代码
class UiPathVideoPage extends StatefulWidget {
final String text;
UiPathVideoPage({Key key, @required this.text}) : super(key: key);
@override
_UiPathVideoPageState createState() => _UiPathVideoPageState();
}
class _UiPathVideoPageState extends State<UiPathVideoPage> {
VideoPlayerController _controller;
ProgressDialog pr;
@override void initState() {
// TODO: implement initState
super.initState();
if(widget.text == 'Telecom') {
_controller = VideoPlayerController.network(
'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/04ea5f9ca1')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
}
if(widget.text == 'Finance'){
_controller = VideoPlayerController.network(
'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/o/VideoLibrary%273320d38f')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
}
if(widget.text == 'Sales'){
_controller = VideoPlayerController.network(
'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/o/VideoLibraryc498e')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
}
if(widget.text == 'Others'){
_controller = VideoPlayerController.network(
'https://firebasestorage.googleapis.com/v0/b/recycler-view-8483d.appspot.com/o/VideoLibrary%2Fcea5f9ca1')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
}
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
pr = new ProgressDialog(context);
pr.style(
message: 'Please Waiting...',
borderRadius: 10.0,
backgroundColor: Colors.white,
progressWidget: CircularProgressIndicator(),
elevation: 10.0,
insetAnimCurve: Curves.easeInOut,
progress: 0.0,
maxProgress: 100.0,
progressTextStyle: TextStyle(
color: Colors.black, fontSize: 13.0, fontWeight: FontWeight.w400),
messageTextStyle: TextStyle(
color: Colors.black, fontSize: 19.0, fontWeight: FontWeight.w600)
);
return Container(
child: Scaffold(
backgroundColor: Colors.grey[200],
appBar: AppBar(
backgroundColor: Colors.grey[900],
title: Text(""),
),
body: Center(
child:
_controller.value.initialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(
child: Image.asset('assets/loading.gif'),
)
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
),
);
}
}
我正在寻求帮助,在此先感谢
解决方案
推荐阅读
- sql - 在一个表单内的 Access 中的三个子表单中显示基于相同 id 的记录
- php - 将 PHP 从版本 5.6 升级到 7.2 后 MySQL 服务无法在 Ubuntu 14.04 上启动
- javascript - 如何在javascript的url中传递参数?
- javascript - 使用 array.map() 映射到另一个类
- php - 为什么我不能对这个数组进行排序?
- azure - 数据工厂 v1 将某些标头屏蔽为 http 标头中的凭据
- react-native - 使用本机反应如何获取当前位置的城市名称?
- r - html格式的shiny_output比较结果
- python - python 3.6 pynput NameError:未定义名称“键盘”
- python - 带有日期时间轴的散景悬停多线