根据示例,当我使用video_player插件时,我无法播放视频并出现错误。(在iOS模拟器中)
我将以下条目添加到/ios/Runner/Info.plist中的Info.plist文件中:
>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
VideoPlayerController _controller;
@override
void initState() {
// TODO: implement 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.
print('initialize${_controller.value.toString()}');
setState(() {});
});
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
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,
),
),
);
}
我希望我可以播放视频,但出现错误。
[C2.1 FBF3D053-02DA-4FC7-A153-96BA9F8DAF09 192.168.0.96:56397<->45.249.110.23:443]
Connected Path: satisfied (Path is satisfied), interface: en0
Duration: 1.601s, DNS @0.000s took 0.002s, TCP @0.005s took 0.249s, TLS took 0.546s
bytes in/out: 27647/1397, packets in/out: 22/4, rtt: 0.256s, retransmitted packets: 0, out-of-order packets: 8
"LocalDataTask <698CEEC9-45A4-41BC-9449-C8E33C4EB550>.<2>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <698CEEC9-45A4-41BC-9449-C8E33C4EB550>.<2>, NSLocalizedDescription=cancelled} [-999]
[C1.1 441C4C64-313B-4F7D-9B25-8454C615F6BC 192.168.0.96:56396<->45.249.110.23:80]
Connected Path: satisfied (Path is satisfied), interface: en0
Duration: 2.161s, DNS @0.003s took 0.006s, TCP @0.012s took 0.001s
bytes in/out: 579/346, packets in/out: 1/1, rtt: 0.256s, retransmitted packets: 0, out-of-order packets: 0
我已经打印了“ _controller.value”:
VideoPlayerValue(duration: 0:01:57.312000, size: Size(1280.0, 720.0), position: 0:00:00.000000, buffered: [DurationRange(start: 0:00:00.000000, end: 0:00:00.021000)], isPlaying: false, isLooping: false, isBuffering: truevolume: 1.0, errorDescription: null)