alexmercerind / flutter_media_metadata

A Flutter plugin to read 🔖 metadata of 🎵 media files. Supports Windows, Linux, macOS, Android, iOS & Web.
MIT License
69 stars 36 forks source link

retriever timeout is too big #10

Closed nt4f04uNd closed 3 years ago

nt4f04uNd commented 3 years ago

in repro below, commented lines are invalid urls - any of them makes retriever to sleep like forever, and because of https://github.com/alexmercerind/flutter_media_metadata/issues/9, it blocks the entire app

repro (make sure to have an internet permsission in manifest for that) ```dart import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_media_metadata/flutter_media_metadata.dart'; void main() { runApp(App()); } const List songs = [ Song(id: 0, title: "Rockstore", artist: "Yxngxr1", albumArtUrl: "https://avatars.yandex.net/get-music-content/176019/30f10951.a.7937298-1/m1000x1000"), Song(id: 1, title: "721", artist: "Yxngxr1", albumArtUrl: "https://avatars.yandex.net/get-music-content/176019/30f10951.a.7937298-1/m1000x1000"), // Song(id: 2, title: "Psycho", artist: "Yxngxr1", albumArtUrl: "https://scontent-arn2-1.cdninstagram.com/v/t51.2885-15/e35/s1080x1080/88996756_151384646331095_1419169024996412508_n.jpg?_nc_ht=scontent-arn2-1.cdninstagram.com&_nc_cat=111&_nc_ohc=8ciKQSWYalIAX_se42z&oh=7b993844fb394fd9f0677132b84d5798&oe=5EBEFDB4"), Song(id: 3, title: "I Don't Suit Hats", artist: "Yxngxr1", albumArtUrl: "https://scontent-arn2-1.cdninstagram.com/v/t51.2885-15/e35/s1080x1080/88996756_151384646331095_1419169024996412508_n.jpg?_nc_ht=scontent-arn2-1.cdninstagram.com&_nc_cat=111&_nc_ohc=8ciKQSWYalIAX_se42z&oh=7b993844fb394fd9f0677132b84d5798&oe=5EBEFDB4"), Song(id: 4, title: "Sucker for your love", artist: "Yxngxr1", albumArtUrl: "https://images.genius.com/96cfd1f79e6655e623249d8b8801da9c.1000x1000x1.jpg"), Song(id: 5, title: "Let's Shake", artist: "Yxngxr1", albumArtUrl: "https://images.genius.com/2a4f8cc4ba4fc23c25cde406be846388.1000x1000x1.jpg"), Song(id: 6, title: "All That", artist: "Oliver Tree", albumArtUrl: "https://pic.lyricshub.ru/img/t/w/j/x/pGINOaxjwt.jpg"), Song(id: 7, title: "Alien Boy", artist: "Oliver Tree", albumArtUrl: "https://pic.lyricshub.ru/img/t/w/j/x/pGINOaxjwt.jpg"), Song(id: 8, title: "Hurt", artist: "Oliver Tree", albumArtUrl: "https://znaj.ua/crops/3421a9/620x0/1/0/2018/12/14/DBnxWUdZ6Mec5ohW1iBkqzhWYdKYU1qbOPIIfA9u.jpeg"), Song(id: 9, title: "Let Me Down", artist: "Oliver Tree", albumArtUrl: "https://cdn62.zvooq.com/pic?type=release&id=10763576&size=500x500&ext=jpg"), // Song(id: 10, title: "bad thoughts", artist: "bbno\$", albumArtUrl: "https://fastfoodmusic.com/wp-content/uploads/2019/11/1200x1200-3.jpg"), // Song(id: 11, title: "on god", artist: "bbno\$", albumArtUrl: "https://fastfoodmusic.com/wp-content/uploads/2019/11/1200x1200-3.jpg"), // Song(id: 12, title: "gone", artist: "bbno\$", albumArtUrl: "https://fastfoodmusic.com/wp-content/uploads/2019/11/1200x1200-3.jpg"), ]; class App extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'App', home: SafeArea( child: Scaffold( body: ListView.builder( itemCount: songs.length * 100, itemBuilder: (context, index) => Item(song: songs[index % songs.length]), ), ), ), ); } } class Item extends StatefulWidget { Item({Key key, this.song}) : super(key: key); final Song song; @override _ItemState createState() => _ItemState(); } class _ItemState extends State { MetadataRetriever retriever; Uint8List bytes; @override void initState() { super.initState(); retriever = MetadataRetriever(); _init(); } Future _init() async { final uri = Uri.parse(widget.song.albumArtUrl); await retriever.setUri(uri); if (mounted) { setState(() { bytes = retriever.albumArt; }); } } @override Widget build(BuildContext context) { return ListTile( leading: Container( height: 50.0, width: 50.0, color: Colors.green, child: bytes == null ? null : Image.memory(bytes), ), title: Text(widget.song.title), subtitle: Text(widget.song.artist), ); } } class Song { const Song({ @required this.id, @required this.title, @required this.artist, @required this.albumArtUrl, }); final int id; final String title; final String artist; final String albumArtUrl; } ```
alexmercerind commented 3 years ago

This is now out of scope for the project, I have removed option to retrieve metadata from URL, since its going to be a pain to implement in Windows/Linux.