Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
Adding description in video details
Browse files Browse the repository at this point in the history
  • Loading branch information
ge59dil committed Jan 28, 2024
1 parent a9ac536 commit d30193d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/models/download/download_state_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ class VideoDetails {
final String filePath;
final String name;
final int duration; // Duration in seconds or your preferred unit
final String description;

const VideoDetails({
required this.filePath,
required this.name,
required this.duration,
required this.description,
});

VideoDetails copyWith({
Expand All @@ -38,6 +40,7 @@ class VideoDetails {
filePath: filePath ?? this.filePath,
name: name ?? this.name,
duration: duration ?? this.duration,
description: description,
);
}

Expand Down
5 changes: 4 additions & 1 deletion lib/view_models/download_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
filePath: videoDetailsMap['filePath'],
name: videoDetailsMap['name'],
duration: videoDetailsMap['duration'],
description: videoDetailsMap['description'],
);
return MapEntry(int.parse(key), videoDetails);
}).cast<int, VideoDetails>(); // Ensure the map has the correct type
Expand All @@ -41,7 +42,7 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
}

Future<String> downloadVideo(String videoUrl, int streamId, String fileName,
String streamName, int streamDuration,) async {
String streamName, int streamDuration, String description,) async {
try {
final directory = await getApplicationDocumentsDirectory();
final filePath = '${directory.path}/$fileName';
Expand All @@ -57,6 +58,7 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
'filePath': filePath,
'name': streamName,
'duration': streamDuration,
'description': description,
};

// Convert video details map to JSON string
Expand All @@ -79,6 +81,7 @@ class DownloadViewModel extends StateNotifier<DownloadState> {
filePath: videoDetailsMap['filePath'],
name: videoDetailsMap['name'],
duration: videoDetailsMap['duration'],
description: videoDetailsMap['description'],
);
return MapEntry(key, videoDetails);
}).cast<int, VideoDetails>();
Expand Down
2 changes: 1 addition & 1 deletion lib/views/video_view/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ class VideoPlayerPageState extends ConsumerState<VideoPlayerPage> {

ref
.read(downloadViewModelProvider.notifier)
.downloadVideo(downloadUrl, stream.id, fileName,stream.name,stream.duration)
.downloadVideo(downloadUrl, stream.id, fileName,stream.name,stream.duration,stream.description,)
.then((localPath) {
if (localPath.isNotEmpty) {
// Download successful
Expand Down

0 comments on commit d30193d

Please sign in to comment.