fluttervideo-playersubtitlesrtflutter-video-player

How do i open srt file on flutter?


I am trying to load subtitle to a video using the flutter video player package it works good for short files but it stopped as the file get bigger I trayed subtitle_wrapper package but it has many bugs

Future<ClosedCaptionFile> getSubtitle(String url) async {
  final data = NetworkAssetBundle(Uri(path: url));
  final newdata = await data.load(url);
  String fileContents = getStringFromBytes(newdata);
  return captionFile = SubRipCaptionFile(fileContents);
}

this is getStringFromBytes function

getStringFromBytes(ByteData data) { final buffer = data.buffer; 
var list = buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
return utf8.decode(list); } 

Solution

  • it wasn't the size after all I tested on some srt files that have a blank space for some duration and the flutter converter do a check on every element if the length is<3 it break on get out of the loop