getMediaItem method

MediaItem getMediaItem(
  1. Video video
)

Creates a media item from a YouTube Video entity.

Implementation

MediaItem getMediaItem(Video video) {
  return MediaItem(
    title: video.title,
    mediaIdentifier: video.url,
    mediaSourceIdentifier: uniqueKey,
    mediaTypeIdentifier: mediaType.uniqueKey,
    position: 0,
    duration: video.duration?.inSeconds ?? 0,
    canDelete: true,
    canEdit: false,
    imageUrl: video.thumbnails.maxResUrl,
    extraUrl: video.thumbnails.mediumResUrl,
    author: video.author,
    authorIdentifier: video.channelId.value,
  );
}