vkdart

Форк
0
172 строки · 5.9 Кб
1
import 'package:vkdart/util.dart';
2
import 'package:vkdart/vkontakte.dart';
3

4
/// Model Video
5
///
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');
11

12
  /// Title of the video.
13
  String? get title => payload['title'];
14

15
  /// Video description text.
16
  String? get description => payload['description'];
17

18
  /// The duration of the video in seconds.
19
  int? get duration => payload['duration'];
20

21
  /// Cover image.
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>()))
25
      .toList();
26

27
  /// First frame image.
28
  /// See https://vk.com/dev/objects/video#first_frame
29
  List<VideoFirstFrameImageModel> get firstFrame => (payload['first_frame']
30
          as List)
31
      .map((e) => VideoFirstFrameImageModel((e as Map).cast<String, dynamic>()))
32
      .toList();
33

34
  /// The date the video was created in Unixtime format.
35
  int? get createdAt => payload['date'];
36

37
  /// The date the video was added by the user or group in Unixtime format.
38
  int? get addedAt => payload['adding_date'];
39

40
  /// Number of video views.
41
  int? get viewsCount => payload['views'];
42

43
  ///  If the video is external, the number of views on VKontakte.
44
  int? get localViews => payload['local_views'];
45

46
  /// Number of comments on the video. The field is not returned if comments are not available.
47
  int? get commentsCount => payload['comments'];
48

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'];
52

53
  /// Platform name (for videos added from external sites).
54
  String? get platformName => payload['platform'];
55

56
  /// Can a user add a video to himself?
57
  bool? get isCanAdd => checkBoolInProperty('can_add');
58

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');
61

62
  /// The field is returned if the video is in the process of processing, always contains 1.
63
  bool? get isProcessing => checkBoolInProperty('processing');
64

65
  /// true if the item has been bookmarked by the current user.
66
  bool? get isFavorite => payload['is_favorite'];
67

68
  /// Can a user comment on a video?
69
  bool? get isCanComment => checkBoolInProperty('can_comment');
70

71
  /// Can the user edit the video?
72
  bool? get isCanEdit => checkBoolInProperty('can_edit');
73

74
  /// Can a user add a video to their "Like" list.
75
  bool? get isCanLike => checkBoolInProperty('can_like');
76

77
  /// Can a user repost a video?
78
  bool? get isCanRepost => checkBoolInProperty('can_repost');
79

80
  /// Can a user subscribe to the author of a video?
81
  bool? get isCanSubscribe => checkBoolInProperty('can_subscribe');
82

83
  /// Whether the user can add a video to favorites.
84
  bool? get isCanAddToFaves => checkBoolInProperty('can_add_to_faves');
85

86
  /// Can a user attach an action button to a video.
87
  bool? get isCanAttachLink => checkBoolInProperty('can_attach_link');
88

89
  /// Video width.
90
  int? get width => payload['width'];
91

92
  /// Video height.
93
  int? get height => payload['height'];
94

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'];
97

98
  /// Does the video convert?
99
  bool? get isConverting => checkBoolInProperty('converting');
100

101
  /// Whether the video has been added to the user's albums.
102
  bool? get isAdded => checkBoolInProperty('added');
103

104
  /// Whether the user is subscribed to the author of the video.
105
  bool? get isSubscribed => checkBoolInProperty('is_subscribed');
106

107
  /// Field returned if the video is looped, always contains 1
108
  bool? get isRepeat => checkBoolInProperty('repeat');
109

110
  /// Video type.
111
  /// Can take values: video, music_video, movie
112
  String? get videoType => payload['type'];
113

114
  /// Donation balance in live broadcast.
115
  int? get balance => payload['balance'];
116

117
  /// Live broadcast status.
118
  /// Can take the following values: waiting, started, finished, failed, upcoming.
119
  String? get liveStatus => payload['live_status'];
120

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');
123

124
  /// The field indicates that the broadcast will begin soon. For live =1.
125
  bool? get isUpcoming => checkBoolInProperty('upcoming');
126

127
  /// Number of viewers of the live broadcast.
128
  int? get spectatorsCount => payload['spectators'];
129
}
130

131
/// Model Video Cover Image.
132
///
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);
137

138
  /// Payload.
139
  final Map<String, dynamic> videoCoverImageObject;
140

141
  /// Cover image url.
142
  String get url => videoCoverImageObject['url'];
143

144
  /// Cover image width.
145
  int get width => videoCoverImageObject['width'];
146

147
  /// Cover image height.
148
  int get height => videoCoverImageObject['height'];
149

150
  /// The field returned if the image is padded, always contains 1.
151
  bool? get withPadding => checkBoolUtil(videoCoverImageObject['with_padding']);
152
}
153

154
/// Model Video First Frame Image.
155
///
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);
160

161
  /// Payload.
162
  final Map<String, dynamic> firstFrameObject;
163

164
  /// First frame image url.
165
  String get url => firstFrameObject['url'];
166

167
  /// First frame image width.
168
  int get width => firstFrameObject['width'];
169

170
  /// First frame image height.
171
  int get height => firstFrameObject['height'];
172
}
173

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.