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

Commit

Permalink
Document how to use pigeon and update to the latest version.
Browse files Browse the repository at this point in the history
This mainly splits out the test logic from the messages.dart file.
  • Loading branch information
Hixie committed Nov 20, 2020
1 parent 576f04a commit b49575a
Show file tree
Hide file tree
Showing 12 changed files with 487 additions and 368 deletions.
28 changes: 28 additions & 0 deletions packages/video_player/video_player/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Updating pigeon-generated files

If you update files in the pigeons/ directory, run the following
command in this directory:

```bash
flutter pub get
flutter pub run pigeon --input pigeons/messages.dart
(cd ../../../; ./script/incremental_build.sh format --travis --clang-format=clang-format-7)
```

If you update pigeon itself, first update the pubspec.yaml by adding
the following to the `dependency_overrides` section, assuming you have
checked out the `flutter/packages` repo in a sibling directory to the
`plugins` repo:

```bash
pigeon:
path:
../../../../packages/packages/pigeon/
```

Then, run the commands above. When you run `pub get` it should warn
you that you're using an override.

In either case, the configuration will be obtained automatically from
the `pigeons/messages.dart` file (see `configurePigeon` at the bottom
of that file).
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.7), do not edit directly.
// Autogenerated from Pigeon (v0.1.15), do not edit directly.
// See also: https://pub.dev/packages/pigeon

package io.flutter.plugins.videoplayer;
Expand All @@ -11,7 +11,6 @@
/** Generated class from Pigeon. */
@SuppressWarnings("unused")
public class Messages {

/** Generated class from Pigeon that represents data sent in messages. */
public static class TextureMessage {
private Long textureId;
Expand Down Expand Up @@ -597,7 +596,7 @@ static void setup(BinaryMessenger binaryMessenger, VideoPlayerApi api) {
private static HashMap wrapError(Exception exception) {
HashMap<String, Object> errorMap = new HashMap<>();
errorMap.put("message", exception.toString());
errorMap.put("code", null);
errorMap.put("code", exception.getClass().getSimpleName());
errorMap.put("details", null);
return errorMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

#import <Flutter/Flutter.h>

@interface FLTVideoPlayerPlugin : NSObject <FlutterPlugin>
@interface FLTVideoPlayerPlugin : NSObject<FlutterPlugin>
@end
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ - (void)onDisplayLink:(CADisplayLink*)link {
}
@end

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

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

@end

@interface FLTVideoPlayerPlugin () <FLTVideoPlayerApi>
@interface FLTVideoPlayerPlugin ()<FLTVideoPlayerApi>
@property(readonly, weak, nonatomic) NSObject<FlutterTextureRegistry>* registry;
@property(readonly, weak, nonatomic) NSObject<FlutterBinaryMessenger>* messenger;
@property(readonly, strong, nonatomic) NSMutableDictionary* players;
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/ios/Classes/messages.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.7), do not edit directly.
// Autogenerated from Pigeon (v0.1.15), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import <Foundation/Foundation.h>
@protocol FlutterBinaryMessenger;
Expand Down
34 changes: 15 additions & 19 deletions packages/video_player/video_player/ios/Classes/messages.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Autogenerated from Pigeon (v0.1.7), do not edit directly.
// Autogenerated from Pigeon (v0.1.15), do not edit directly.
// See also: https://pub.dev/packages/pigeon
#import "messages.h"
#import <Flutter/Flutter.h>
Expand Down Expand Up @@ -59,9 +59,9 @@ + (FLTTextureMessage *)fromMap:(NSDictionary *)dict {
return result;
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
@"textureId", nil];
return
[NSDictionary dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]),
@"textureId", nil];
}
@end

Expand Down Expand Up @@ -112,10 +112,9 @@ + (FLTLoopingMessage *)fromMap:(NSDictionary *)dict {
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
@"textureId",
(self.isLooping != nil ? self.isLooping : [NSNull null]),
@"isLooping", nil];
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
(self.isLooping ? self.isLooping : [NSNull null]), @"isLooping",
nil];
}
@end

Expand All @@ -134,9 +133,8 @@ + (FLTVolumeMessage *)fromMap:(NSDictionary *)dict {
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
@"textureId", (self.volume != nil ? self.volume : [NSNull null]),
@"volume", nil];
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
(self.volume ? self.volume : [NSNull null]), @"volume", nil];
}
@end

Expand All @@ -155,9 +153,8 @@ + (FLTPlaybackSpeedMessage *)fromMap:(NSDictionary *)dict {
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
@"textureId", (self.speed != nil ? self.speed : [NSNull null]),
@"speed", nil];
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
(self.speed ? self.speed : [NSNull null]), @"speed", nil];
}
@end

Expand All @@ -176,10 +173,9 @@ + (FLTPositionMessage *)fromMap:(NSDictionary *)dict {
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.textureId != nil ? self.textureId : [NSNull null]),
@"textureId",
(self.position != nil ? self.position : [NSNull null]),
@"position", nil];
dictionaryWithObjectsAndKeys:(self.textureId ? self.textureId : [NSNull null]), @"textureId",
(self.position ? self.position : [NSNull null]), @"position",
nil];
}
@end

Expand All @@ -194,7 +190,7 @@ + (FLTMixWithOthersMessage *)fromMap:(NSDictionary *)dict {
}
- (NSDictionary *)toMap {
return [NSDictionary
dictionaryWithObjectsAndKeys:(self.mixWithOthers != nil ? self.mixWithOthers : [NSNull null]),
dictionaryWithObjectsAndKeys:(self.mixWithOthers ? self.mixWithOthers : [NSNull null]),
@"mixWithOthers", nil];
}
@end
Expand Down
1 change: 1 addition & 0 deletions packages/video_player/video_player/pigeons/messages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ abstract class VideoPlayerApi {

void configurePigeon(PigeonOptions opts) {
opts.dartOut = '../video_player_platform_interface/lib/messages.dart';
opts.dartTestOut = '../video_player_platform_interface/lib/test.dart';
opts.objcHeaderOut = 'ios/Classes/messages.h';
opts.objcSourceOut = 'ios/Classes/messages.m';
opts.objcOptions.prefix = 'FLT';
Expand Down
14 changes: 11 additions & 3 deletions packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: video_player
description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
version: 1.0.1
version: 1.0.2
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player

flutter:
Expand All @@ -28,13 +28,21 @@ dependencies:

flutter:
sdk: flutter

dev_dependencies:
flutter_test:
sdk: flutter

dev_dependencies:
pedantic: ^1.8.0
pigeon: 0.1.7

environment:
sdk: ">=2.8.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5 <2.0.0"

dependency_overrides:
video_player_platform_interface:
path:
../video_player_platform_interface
video_player_web:
path:
../video_player_web
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:video_player/video_player.dart';
import 'package:video_player_platform_interface/messages.dart';
import 'package:video_player_platform_interface/test.dart';
import 'package:video_player_platform_interface/video_player_platform_interface.dart';

class FakeController extends ValueNotifier<VideoPlayerValue>
Expand Down
Loading

0 comments on commit b49575a

Please sign in to comment.