如何将此响应转换为播放列表

How to convert this response to playlist

如何在 flutter 中将此响应转换为播放列表

我正在使用 flutter_vlc_player

#EXTM3U

#EXTINF:0 tvg-logo="http://example.com/logo/" tvg-id="" ,麦德龙电视 http://127.0.0.1:8000/live/test/test/3

#EXTINF:0 tvg-logo="http://example.com/logo/" tvg-id="" ,TVONE http://127.0.0.1:8000/live/test/test/5

#EXTINF:0 tvg-logo="http://example.com/logo/" tvg-id="" ,TVRI http://127.0.0.1:8000/live/test/test/33

如果您尝试使用 split 方法就可以解决您的问题!!

代码:

void main() {
  String text = '''#EXTM3U

#EXTINF:0 tvg-logo="http://example.com/logo/" tvg-id="" ,METRO TV http://127.0.0.1:8000/live/test/test/3

#EXTINF:0 tvg-logo="http://example.com/logo/" tvg-id="" ,TVONE http://127.0.0.1:8000/live/test/test/5

#EXTINF:0 tvg-logo="http://example.com/logo/" tvg-id="" ,TVRI http://127.0.0.1:8000/live/test/test/33''';

  text.split("\n").forEach((line) {
    var splits = line.split('http://');
    splits.length >= 3 ? print('http://' + splits[2]) : null;
  });
}

输出:

http://127.0.0.1:8000/live/test/test/3
http://127.0.0.1:8000/live/test/test/5
http://127.0.0.1:8000/live/test/test/33