首页 > 解决方案 > 如果链接不起作用,则颤动媒体 url 重定向到另一个 url

问题描述

目前我正在开发一个直播电视应用程序。每个电视频道将包含多个用于备份的直播网址。如果一个 url 关闭,则自动重定向到另一个实时 url。

在频道详情页面中是否可以将其他电视频道显示为相关频道?

class _ChannelDetailsState extends State<ChannelDetails> {
  late VideoPlayerController _controller;
  

  @override
  void initState() {
    super.initState();
    _controller = VideoPlayerController.network(widget.channels.ChannelUrl_1)
      ..initialize().then((_) {
        setState(() {
          _controller.play();
        });
      });

  
    
  }
Container(
                    child: _controller.value.isInitialized
                        ? AspectRatio(
                            aspectRatio: _controller.value.aspectRatio,
                            child: VideoPlayer(
                              _controller,
                            ))
                        : Container(
                            
                            color: Colors.black,
                            child: Container(
                              height: 200,
                              child: Center(child: CircularProgressIndicator()))),
                  ),

这是 Api json 格式

{
    "success": true,
    "data": [
        {
            "id": 1,
            "Channel_Name": "Channel 1",
            "Channel_Image": "http://liveurl/images/profile.png",
            "Channel_Url_1": "http://livetvchannelurl1.m3u8",
            "Channel_Url_2": "http://livetvchannelurl2.m3u8",
            "Channel_Url_3": "http://livetvchannelurl3.m3u8",
            "Channel_Description": "Channel Description goes here",
            "created_at": "2021-10-19T18:49:08.000000Z",
            "updated_at": "2021-10-20T08:00:53.000000Z"
        },
        {
            "id": 2,
            "Channel_Name": "Channel 2",
            "Channel_Image": "http://liveurl/images/profile.png",
            "Channel_Url_1": "http://livetvchannelurl1.m3u8",
            "Channel_Url_2": "http://livetvchannelurl2.m3u8",
            "Channel_Url_3": "http://livetvchannelurl3.m3u8",
            "Channel_Description": "Description goes here",
            "created_at": "2021-10-19T20:21:56.000000Z",
            "updated_at": "2021-10-20T08:01:08.000000Z"
        }
      
        
    ],
    "message": "Channels retrieved successfully"
}

谁能帮我吗。谢谢

标签: flutterdart

解决方案


推荐阅读