tsacdop-podcast-app-android/lib/class/episodebrief.dart

54 lines
1.3 KiB
Dart
Raw Normal View History

import 'package:intl/intl.dart';
import 'package:audio_service/audio_service.dart';
2020-02-09 13:29:09 +01:00
class EpisodeBrief {
final String title;
String description;
final int pubDate;
2020-02-09 13:29:09 +01:00
final int enclosureLength;
final String enclosureUrl;
final String feedTitle;
final String primaryColor;
final int liked;
final String downloaded;
final int duration;
final int explicit;
final String imagePath;
final String mediaId;
2020-02-09 13:29:09 +01:00
EpisodeBrief(
this.title,
this.enclosureUrl,
this.enclosureLength,
this.pubDate,
this.feedTitle,
this.primaryColor,
this.liked,
this.downloaded,
2020-02-09 13:29:09 +01:00
this.duration,
this.explicit,
this.imagePath,
this.mediaId);
String dateToString() {
DateTime date = DateTime.fromMillisecondsSinceEpoch(pubDate, isUtc: true);
var diffrence = DateTime.now().difference(date);
if (diffrence.inHours < 24) {
return '${diffrence.inHours} hours ago';
} else if (diffrence.inDays < 7) {
return '${diffrence.inDays} days ago';
} else {
return DateFormat.yMMMd()
.format(DateTime.fromMillisecondsSinceEpoch(pubDate));
}
}
MediaItem toMediaItem() {
return MediaItem(
id: mediaId,
title: title,
artist: feedTitle,
album: feedTitle,
artUri: 'file://$imagePath');
}
2020-02-09 13:29:09 +01:00
}