1
import 'package:vkdart/util.dart';
2
import 'package:vkdart/vkontakte.dart';
6
/// See https://dev.vk.com/ru/reference/objects/video
7
class VideoAttachmentModel extends CustomAttachmentModel
8
with AttachmentLikesMixin, AttachmentRepostsMixin {
9
// ignore: public_member_api_docs
10
VideoAttachmentModel(super.payload) : super(attachType: 'video');
12
/// Title of the video.
13
String? get title => payload['title'];
15
/// Video description text.
16
String? get description => payload['description'];
18
/// The duration of the video in seconds.
19
int? get duration => payload['duration'];
22
/// See https://dev.vk.com/ru/reference/objects/video#image
23
List<VideoCoverImageModel> get image => (payload['image'] as List)
24
.map((e) => VideoCoverImageModel((e as Map).cast<String, dynamic>()))
27
/// First frame image.
28
/// See https://vk.com/dev/objects/video#first_frame
29
List<VideoFirstFrameImageModel> get firstFrame => (payload['first_frame']
31
.map((e) => VideoFirstFrameImageModel((e as Map).cast<String, dynamic>()))
34
/// The date the video was created in Unixtime format.
35
int? get createdAt => payload['date'];
37
/// The date the video was added by the user or group in Unixtime format.
38
int? get addedAt => payload['adding_date'];
40
/// Number of video views.
41
int? get viewsCount => payload['views'];
43
/// If the video is external, the number of views on VKontakte.
44
int? get localViews => payload['local_views'];
46
/// Number of comments on the video. The field is not returned if comments are not available.
47
int? get commentsCount => payload['comments'];
49
/// URL of a page with a player that can be used to play the video in the browser.
50
/// Flash and HTML5 are supported, the player is always scaled to fit the window.
51
String? get player => payload['player'];
53
/// Platform name (for videos added from external sites).
54
String? get platformName => payload['platform'];
56
/// Can a user add a video to himself?
57
bool? get isCanAdd => checkBoolInProperty('can_add');
59
/// The field is returned if the video is private (for example, it was uploaded to a private message), always contains 1.
60
bool? get isPrivate => checkBoolInProperty('is_private');
62
/// The field is returned if the video is in the process of processing, always contains 1.
63
bool? get isProcessing => checkBoolInProperty('processing');
65
/// true if the item has been bookmarked by the current user.
66
bool? get isFavorite => payload['is_favorite'];
68
/// Can a user comment on a video?
69
bool? get isCanComment => checkBoolInProperty('can_comment');
71
/// Can the user edit the video?
72
bool? get isCanEdit => checkBoolInProperty('can_edit');
74
/// Can a user add a video to their "Like" list.
75
bool? get isCanLike => checkBoolInProperty('can_like');
77
/// Can a user repost a video?
78
bool? get isCanRepost => checkBoolInProperty('can_repost');
80
/// Can a user subscribe to the author of a video?
81
bool? get isCanSubscribe => checkBoolInProperty('can_subscribe');
83
/// Whether the user can add a video to favorites.
84
bool? get isCanAddToFaves => checkBoolInProperty('can_add_to_faves');
86
/// Can a user attach an action button to a video.
87
bool? get isCanAttachLink => checkBoolInProperty('can_attach_link');
90
int? get width => payload['width'];
93
int? get height => payload['height'];
95
/// ID of the user who uploaded the video, if it was uploaded to the group by one of the participants.
96
int? get userId => payload['user_id'];
98
/// Does the video convert?
99
bool? get isConverting => checkBoolInProperty('converting');
101
/// Whether the video has been added to the user's albums.
102
bool? get isAdded => checkBoolInProperty('added');
104
/// Whether the user is subscribed to the author of the video.
105
bool? get isSubscribed => checkBoolInProperty('is_subscribed');
107
/// Field returned if the video is looped, always contains 1
108
bool? get isRepeat => checkBoolInProperty('repeat');
111
/// Can take values: video, music_video, movie
112
String? get videoType => payload['type'];
114
/// Donation balance in live broadcast.
115
int? get balance => payload['balance'];
117
/// Live broadcast status.
118
/// Can take the following values: waiting, started, finished, failed, upcoming.
119
String? get liveStatus => payload['live_status'];
121
/// The field returned if the video is a live broadcast always contains 1. Note that in this case the duration field contains the value 0.
122
bool? get isBroadcast => checkBoolInProperty('live');
124
/// The field indicates that the broadcast will begin soon. For live =1.
125
bool? get isUpcoming => checkBoolInProperty('upcoming');
127
/// Number of viewers of the live broadcast.
128
int? get spectatorsCount => payload['spectators'];
131
/// Model Video Cover Image.
133
/// See https://dev.vk.com/ru/reference/objects/video#image
134
final class VideoCoverImageModel {
135
// ignore: public_member_api_docs
136
VideoCoverImageModel(this.videoCoverImageObject);
139
final Map<String, dynamic> videoCoverImageObject;
142
String get url => videoCoverImageObject['url'];
144
/// Cover image width.
145
int get width => videoCoverImageObject['width'];
147
/// Cover image height.
148
int get height => videoCoverImageObject['height'];
150
/// The field returned if the image is padded, always contains 1.
151
bool? get withPadding => checkBoolUtil(videoCoverImageObject['with_padding']);
154
/// Model Video First Frame Image.
156
/// See https://dev.vk.com/ru/reference/objects/video#first_frame
157
final class VideoFirstFrameImageModel {
158
// ignore: public_member_api_docs
159
VideoFirstFrameImageModel(this.firstFrameObject);
162
final Map<String, dynamic> firstFrameObject;
164
/// First frame image url.
165
String get url => firstFrameObject['url'];
167
/// First frame image width.
168
int get width => firstFrameObject['width'];
170
/// First frame image height.
171
int get height => firstFrameObject['height'];