我有一个json数据。 json数据包含一个视频链接。例如:
[{"id": 12, "name": "bryn", "link":"https://www.xxxxx.com/videos/asdasfrlşr.mp4"},{"id": 13, "name": "brynas", "link":"https://www.xxxxx.com/videos/fgfasfrlşr.mp4"},{"id": 14, "name": "e3bryn", "link":"https://www.xxxxx.com/videos/asdasfthvbvbr.mp4"}]
我使用Chewie视频播放器。我可以列出这些视频,也可以观看。但我关闭了该页面。视频未关闭。视频播放背景。我的代码在下面。
VideoPlayerController _videoPlayerController1;
ChewieController _chewieController;
@override
void initState() {
super.initState();
_videoPlayerController1 = VideoPlayerController.network(
products[index]["link"]);
_chewieController = ChewieController(
videoPlayerController: _videoPlayerController1,
aspectRatio: 16 / 9,
autoPlay: true,
looping: true,
// Try playing around with some of these other options:
// showControls: false,
// materialProgressColors: ChewieProgressColors(
// playedColor: Colors.red,
// handleColor: Colors.blue,
// backgroundColor: Colors.grey,
// bufferedColor: Colors.lightGreen,
// ),
// placeholder: Container(
// color: Colors.grey,
// ),
// autoInitialize: true,
);
}
@override
void dispose() {
_videoPlayerController.dispose();
_chewieController.dispose();
super.dispose();
}
ListView.builder(
itemCount: products == null ? 0 : products.length,
itemBuilder: (BuildContext asd, int index) => Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: products[index]["yazi"],
style: TextStyle(
fontSize: 16,
color: localStorage.mainColor,
fontWeight: FontWeight.bold)),
],
),
),
),
products[index]["link"] == "" ? Text("Video did not found !",
style: TextStyle(
color: localStorage.mainColor,
fontSize: 18,
fontWeight: FontWeight.bold),
) : Chewie(controller: _chewieController),
SizedBox(height: 10),])))
如何解决此问题。谢谢。