Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit b49575a

Browse files
committed
Document how to use pigeon and update to the latest version.
This mainly splits out the test logic from the messages.dart file.
1 parent 576f04a commit b49575a

File tree

12 files changed

+487
-368
lines changed

12 files changed

+487
-368
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
## Updating pigeon-generated files
2+
3+
If you update files in the pigeons/ directory, run the following
4+
command in this directory:
5+
6+
```bash
7+
flutter pub get
8+
flutter pub run pigeon --input pigeons/messages.dart
9+
(cd ../../../; ./script/incremental_build.sh format --travis --clang-format=clang-format-7)
10+
```
11+
12+
If you update pigeon itself, first update the pubspec.yaml by adding
13+
the following to the `dependency_overrides` section, assuming you have
14+
checked out the `flutter/packages` repo in a sibling directory to the
15+
`plugins` repo:
16+
17+
```bash
18+
pigeon:
19+
path:
20+
../../../../packages/packages/pigeon/
21+
```
22+
23+
Then, run the commands above. When you run `pub get` it should warn
24+
you that you're using an override.
25+
26+
In either case, the configuration will be obtained automatically from
27+
the `pigeons/messages.dart` file (see `configurePigeon` at the bottom
28+
of that file).

packages/video_player/video_player/android/src/main/java/io/flutter/plugins/videoplayer/Messages.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.7), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.15), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33

44
package io.flutter.plugins.videoplayer;
@@ -11,7 +11,6 @@
1111
/** Generated class from Pigeon. */
1212
@SuppressWarnings("unused")
1313
public class Messages {
14-
1514
/** Generated class from Pigeon that represents data sent in messages. */
1615
public static class TextureMessage {
1716
private Long textureId;
@@ -597,7 +596,7 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) {
597596
private static HashMap wrapError(Exception exception) {
598597
HashMap<String, Object> errorMap = new HashMap<>();
599598
errorMap.put("message", exception.toString());
600-
errorMap.put("code", null);
599+
errorMap.put("code", exception.getClass().getSimpleName());
601600
errorMap.put("details", null);
602601
return errorMap;
603602
}

packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
#import <Flutter/Flutter.h>
66

7-
@interface FLTVideoPlayerPlugin : NSObject <FlutterPlugin>
7+
@interface FLTVideoPlayerPlugin : NSObject<FlutterPlugin>
88
@end

packages/video_player/video_player/ios/Classes/FLTVideoPlayerPlugin.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ - (void)onDisplayLink:(CADisplayLink*)link {
3535
}
3636
@end
3737

38-
@interface FLTVideoPlayer : NSObject <FlutterTexture, FlutterStreamHandler>
38+
@interface FLTVideoPlayer : NSObject<FlutterTexture, FlutterStreamHandler>
3939
@property(readonly, nonatomic) AVPlayer* player;
4040
@property(readonly, nonatomic) AVPlayerItemVideoOutput* videoOutput;
4141
@property(readonly, nonatomic) CADisplayLink* displayLink;
@@ -156,8 +156,8 @@ - (void)createVideoOutputAndDisplayLink:(FLTFrameUpdater*)frameUpdater {
156156
};
157157
_videoOutput = [[AVPlayerItemVideoOutput alloc] initWithPixelBufferAttributes:pixBuffAttributes];
158158

159-
_displayLink = [CADisplayLink displayLinkWithTarget:frameUpdater
160-
selector:@selector(onDisplayLink:)];
159+
_displayLink =
160+
[CADisplayLink displayLinkWithTarget:frameUpdater selector:@selector(onDisplayLink:)];
161161
[_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
162162
_displayLink.paused = YES;
163163
}
@@ -205,8 +205,8 @@ - (instancetype)initWithPlayerItem:(AVPlayerItem*)item frameUpdater:(FLTFrameUpd
205205
AVAssetTrack* videoTrack = tracks[0];
206206
void (^trackCompletionHandler)(void) = ^{
207207
if (self->_disposed) return;
208-
if ([videoTrack statusOfValueForKey:@"preferredTransform"
209-
error:nil] == AVKeyValueStatusLoaded) {
208+
if ([videoTrack statusOfValueForKey:@"preferredTransform" error:nil] ==
209+
AVKeyValueStatusLoaded) {
210210
// Rotate the video by using a videoComposition and the preferredTransform
211211
self->_preferredTransform = [self fixTransform:videoTrack];
212212
// Note:
@@ -445,7 +445,7 @@ - (void)dispose {
445445

446446
@end
447447

448-
@interface FLTVideoPlayerPlugin () <FLTVideoPlayerApi>
448+
@interface FLTVideoPlayerPlugin ()<FLTVideoPlayerApi>
449449
@property(readonly, weak, nonatomic) NSObject<FlutterTextureRegistry>* registry;
450450
@property(readonly, weak, nonatomic) NSObject<FlutterBinaryMessenger>* messenger;
451451
@property(readonly, strong, nonatomic) NSMutableDictionary* players;

packages/video_player/video_player/ios/Classes/messages.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.7), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.15), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
#import <Foundation/Foundation.h>
44
@protocol FlutterBinaryMessenger;

packages/video_player/video_player/ios/Classes/messages.m

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Autogenerated from Pigeon (v0.1.7), do not edit directly.
1+
// Autogenerated from Pigeon (v0.1.15), do not edit directly.
22
// See also: https://pub.dev/packages/pigeon
33
#import "messages.h"
44
#import <Flutter/Flutter.h>
@@ -59,9 +59,9 @@ + (FLTTextureMessage *)fromMap:(NSDictionary *)dict {
5959
return result;
6060
}
6161
- (NSDictionary *)toMap {
62-
return [NSDictionary
63-
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
64-
@"textureId", nil];
62+
return
63+
[NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]),
64+
@"textureId", nil];
6565
}
6666
@end
6767

@@ -112,10 +112,9 @@ + (FLTLoopingMessage *)fromMap:(NSDictionary *)dict {
112112
}
113113
- (NSDictionary *)toMap {
114114
return [NSDictionary
115-
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
116-
@"textureId",
117-
(self.isLooping != nil ? self.isLooping : [NSNull null]),
118-
@"isLooping", nil];
115+
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
116+
(self.isLooping ? self.isLooping : [NSNull null]), @"isLooping",
117+
nil];
119118
}
120119
@end
121120

@@ -134,9 +133,8 @@ + (FLTVolumeMessage *)fromMap:(NSDictionary *)dict {
134133
}
135134
- (NSDictionary *)toMap {
136135
return [NSDictionary
137-
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
138-
@"textureId", (self.volume != nil ? self.volume : [NSNull null]),
139-
@"volume", nil];
136+
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
137+
(self.volume ? self.volume : [NSNull null]), @"volume", nil];
140138
}
141139
@end
142140

@@ -155,9 +153,8 @@ + (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict {
155153
}
156154
- (NSDictionary *)toMap {
157155
return [NSDictionary
158-
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
159-
@"textureId", (self.speed != nil ? self.speed : [NSNull null]),
160-
@"speed", nil];
156+
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
157+
(self.speed ? self.speed : [NSNull null]), @"speed", nil];
161158
}
162159
@end
163160

@@ -176,10 +173,9 @@ + (FLTPositionMessage *)fromMap:(NSDictionary *)dict {
176173
}
177174
- (NSDictionary *)toMap {
178175
return [NSDictionary
179-
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
180-
@"textureId",
181-
(self.position != nil ? self.position : [NSNull null]),
182-
@"position", nil];
176+
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
177+
(self.position ? self.position : [NSNull null]), @"position",
178+
nil];
183179
}
184180
@end
185181

@@ -194,7 +190,7 @@ + (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict {
194190
}
195191
- (NSDictionary *)toMap {
196192
return [NSDictionary
197-
dictionaryWithObjectsAndKeys:(self.mixWithOthers != nil ? self.mixWithOthers : [NSNull null]),
193+
dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]),
198194
@"mixWithOthers", nil];
199195
}
200196
@end

packages/video_player/video_player/pigeons/messages.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ abstract class VideoPlayerApi {
5252

5353
void configurePigeon(PigeonOptions opts) {
5454
opts.dartOut = '../video_player_platform_interface/lib/messages.dart';
55+
opts.dartTestOut = '../video_player_platform_interface/lib/test.dart';
5556
opts.objcHeaderOut = 'ios/Classes/messages.h';
5657
opts.objcSourceOut = 'ios/Classes/messages.m';
5758
opts.objcOptions.prefix = 'FLT';

packages/video_player/video_player/pubspec.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: video_player
22
description: Flutter plugin for displaying inline video with other Flutter
33
widgets on Android, iOS, and web.
4-
version: 1.0.1
4+
version: 1.0.2
55
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
66

77
flutter:
@@ -28,13 +28,21 @@ dependencies:
2828

2929
flutter:
3030
sdk: flutter
31-
32-
dev_dependencies:
3331
flutter_test:
3432
sdk: flutter
33+
34+
dev_dependencies:
3535
pedantic: ^1.8.0
3636
pigeon: 0.1.7
3737

3838
environment:
3939
sdk: ">=2.8.0 <3.0.0"
4040
flutter: ">=1.12.13+hotfix.5 <2.0.0"
41+
42+
dependency_overrides:
43+
video_player_platform_interface:
44+
path:
45+
../video_player_platform_interface
46+
video_player_web:
47+
path:
48+
../video_player_web

packages/video_player/video_player/test/video_player_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:flutter/widgets.dart';
1414
import 'package:flutter_test/flutter_test.dart';
1515
import 'package:video_player/video_player.dart';
1616
import 'package:video_player_platform_interface/messages.dart';
17+
import 'package:video_player_platform_interface/test.dart';
1718
import 'package:video_player_platform_interface/video_player_platform_interface.dart';
1819

1920
class FakeController extends ValueNotifier<VideoPlayerValue>

0 commit comments

Comments
 (0)