srt_parser 1.1.0+3 copy "srt_parser: ^1.1.0+3" to clipboard
srt_parser: ^1.1.0+3 copied to clipboard

outdated

A cross-platform, .srt parser that allows you to read a String containing Html and Coordinates and results to subtitle objects.

.srt parser #

description #

A .srt file parser that allows you to read a String containing HTML, coordination and timestamps information and convert it to a list of subtitle objects.
Each Subtitle object contains a list of subtitle subsets with their corresponding metadata.

Example #

import 'package:srt_parser/srt_parser.dart';

const String data = '''1
00:02:26,407 --> 00:02:31,356  X1:100 X2:100 Y1:100 Y2:100
+ time to move on, <u><b><font color="#00ff00">Arman</font></b></u>.
- OK

2
00:02:31,567 --> 00:02:37,164 
+ Lukas is publishing his library.
- I like the man.
''';

void main() {
  List<Subtitle> subtitles = parseSrt(data);
  for (Subtitle item in subtitles) {
    print('ID is: ${item.id}');
    print('Begin is: ${item.range.begin} and End is: ${item.range.end}');
    for (String line in item.lines) {
      print(line);
    }
    print('----');
  }
}

Using in Flutter #

A wrapper class like below should convert csslib's Color to dart:ui's.


import 'dart:ui' as color_ref;

import 'package:csslib/parser.dart';
import 'package:srt_parser/srt_parser.dart';

class WrappedHtmlCode {
  WrappedHtmlCode(HtmlCode html){
    htmlCode.i = html.i!=null? html.i:null;
    htmlCode.b = html.b!=null? html.b:null;
    color = html.fontColor== Color.black ?  const color_ref.Color(0xFF000000) :color_ref.Color(html.fontColor.argbValue);

  }
  HtmlCode htmlCode = HtmlCode();
  color_ref.Color color;

}

8
likes
0
pub points
0%
popularity

Publisher

unverified uploader

A cross-platform, .srt parser that allows you to read a String containing Html and Coordinates and results to subtitle objects.

Homepage
Repository
View/report issues

License

unknown (LICENSE)

Dependencies

csslib, meta

More

Packages that depend on srt_parser