YoutubeMetaData.fromRawData constructor

YoutubeMetaData.fromRawData(
  1. dynamic rawData
)

Creates YoutubeMetaData from raw json video data.

Implementation

factory YoutubeMetaData.fromRawData(dynamic rawData) {
  final data = rawData as Map<String, dynamic>;
  final durationInMs = ((data['duration'] ?? 0).toDouble() * 1000).floor();
  return YoutubeMetaData(
    videoId: data['videoId'],
    title: data['title'],
    author: data['author'],
    duration: Duration(milliseconds: durationInMs),
  );
}