Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Flutterで動画を再生する

 Flutterで動画を再生する

3187acdb47cb44678ad716c3228bf91b?s=128

Kentaro Kawakami

February 24, 2021
Tweet

Transcript

  1. FlutterͰಈըΛ࠶ੜ͢Δ Flutter × Kotlin Multiplatform by CyberAgent #2 ઒্ ݈ଠ࿠

    2021/2/24
  2. About Me ઒্ ݈ଠ࿠ FRESH LIVEɺCLͰiOSΞϓϦͷ։ൃ ΛܦͯFlutterͰ։ൃதɻFlutterྺ͸ 6ϲ݄͘Β͍ ,FFFFFO ,OTDIXBS[F

    Cyberagent, Inc.
  3. ໨࣍ • ύοέʔδͷ঺հ • video_playerʹ͍ͭͯ • ࣮૷Λ௥ͬͯΈΔ • ػೳΛ௥Ճ͢Δ •

    ·ͱΊ
  4. ໨࣍ • ύοέʔδͷ঺հ • video_playerʹ͍ͭͯ • ࣮૷Λ௥ͬͯΈΔ • ػೳΛ௥Ճ͢Δ •

    ·ͱΊ
  5. ύοέʔδͷ঺հ • video_player • pub.dev • GitHub • flutter͕ग़͍ͯ͠Δ •

    iOS/Android/WebʹରԠ • iOS͸Objective-CɺAndroid͸Java
  6. ໨࣍ • ύοέʔδͷ঺հ • video_playerʹ͍ͭͯ • ࣮૷Λ௥ͬͯΈΔ • ػೳΛ௥Ճ͢Δ •

    ·ͱΊ
  7. ϩʔΧϧϑΝΠϧɾΞηοτͷ࠶ੜ class LocalVideo extends StatefulWidget { @override _LocalVideoState createState() =>

    _LocalVideoState(); } class _LocalVideoState extends State<LocalVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.asset('assets/Butterfly-209.mp4'); // _controller = VideoPlayerController.file(File('file path')); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  8. ϩʔΧϧϑΝΠϧɾΞηοτͷ࠶ੜ class LocalVideo extends StatefulWidget { @override _LocalVideoState createState() =>

    _LocalVideoState(); } class _LocalVideoState extends State<LocalVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.asset('assets/Butterfly-209.mp4'); // _controller = VideoPlayerController.file(File('file path')); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  9. ϩʔΧϧϑΝΠϧɾΞηοτͷ࠶ੜ class LocalVideo extends StatefulWidget { @override _LocalVideoState createState() =>

    _LocalVideoState(); } class _LocalVideoState extends State<LocalVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.asset('assets/Butterfly-209.mp4'); // _controller = VideoPlayerController.file(File('file path')); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  10. ϩʔΧϧϑΝΠϧɾΞηοτͷ࠶ੜ class LocalVideo extends StatefulWidget { @override _LocalVideoState createState() =>

    _LocalVideoState(); } class _LocalVideoState extends State<LocalVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.asset('assets/Butterfly-209.mp4'); // _controller = VideoPlayerController.file(File('file path')); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  11. ϩʔΧϧϑΝΠϧɾΞηοτͷ࠶ੜ class LocalVideo extends StatefulWidget { @override _LocalVideoState createState() =>

    _LocalVideoState(); } class _LocalVideoState extends State<LocalVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.asset('assets/Butterfly-209.mp4'); // _controller = VideoPlayerController.file(File('file path')); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  12. ϩʔΧϧϑΝΠϧɾΞηοτͷ࠶ੜ class LocalVideo extends StatefulWidget { @override _LocalVideoState createState() =>

    _LocalVideoState(); } class _LocalVideoState extends State<LocalVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.asset('assets/Butterfly-209.mp4'); // _controller = VideoPlayerController.file(File('file path')); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  13. ϦϞʔτϑΝΠϧͷ࠶ੜ class RemoteVideo extends StatefulWidget { @override _RemoteVideoState createState() =>

    _RemoteVideoState(); } class _RemoteVideoState extends State<RemoteVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.network('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  14. ϦϞʔτϑΝΠϧͷ࠶ੜ class RemoteVideo extends StatefulWidget { @override _RemoteVideoState createState() =>

    _RemoteVideoState(); } class _RemoteVideoState extends State<RemoteVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.network('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  15. ϦϞʔτϑΝΠϧͷ࠶ੜ class RemoteVideo extends StatefulWidget { @override _RemoteVideoState createState() =>

    _RemoteVideoState(); } class _RemoteVideoState extends State<RemoteVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.network('https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8'); _controller.initialize(); _controller.play(); } @override void dispose() { _controller.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return … VideoPlayer(_controller); … } }
  16. ग़དྷΔ͜ͱ • ࠶ੜʗఀࢭʗγʔΫ • ϧʔϓ࠶ੜ • ϘϦϡʔϜઃఆ • ࠶ੜ଎౓ઃఆ

  17. ʴЋ • ࣈນ • γʔΫόʔ • ϥΠϑαΠΫϧʹ߹Θͤͯ࠶ੜʗఀࢭ

  18. ʴЋ • ࣈນ • γʔΫόʔ • ϥΠϑαΠΫϧʹ߹Θͤͯ࠶ੜʗఀࢭ

  19. ࣈນ class RemoteVideo extends StatefulWidget { … } class _RemoteVideoState

    extends State<RemoteVideo> { late VideoPlayerController _controller; Future<ClosedCaptionFile> _loadCaptions() async { final String fileContents = await DefaultAssetBundle.of(context).loadString('assets/bumble_bee_captions.srt'); return SubRipCaptionFile(fileContents); } @override void initState() { super.initState(); _controller = VideoPlayerController.network( 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', closedCaptionFile: _loadCaptions(), ); _controller.initialize(); _controller.play(); } … @override Widget build(BuildContext context) { return … Stack( children: <Widget>[ VideoPlayer(_controller), ClosedCaption(text: _controller.value.caption.text), ], ); … } }
  20. ࣈນ class RemoteVideo extends StatefulWidget { … } class _RemoteVideoState

    extends State<RemoteVideo> { late VideoPlayerController _controller; Future<ClosedCaptionFile> _loadCaptions() async { final String fileContents = await DefaultAssetBundle.of(context).loadString('assets/bumble_bee_captions.srt'); return SubRipCaptionFile(fileContents); } @override void initState() { super.initState(); _controller = VideoPlayerController.network( 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', closedCaptionFile: _loadCaptions(), ); _controller.initialize(); _controller.play(); } … @override Widget build(BuildContext context) { return … Stack( children: <Widget>[ VideoPlayer(_controller), ClosedCaption(text: _controller.value.caption.text), ], ); … } }
  21. ࣈນ class RemoteVideo extends StatefulWidget { … } class _RemoteVideoState

    extends State<RemoteVideo> { late VideoPlayerController _controller; Future<ClosedCaptionFile> _loadCaptions() async { final String fileContents = await DefaultAssetBundle.of(context).loadString('assets/bumble_bee_captions.srt'); return SubRipCaptionFile(fileContents); } @override void initState() { super.initState(); _controller = VideoPlayerController.network( 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', closedCaptionFile: _loadCaptions(), ); _controller.initialize(); _controller.play(); } … @override Widget build(BuildContext context) { return … Stack( children: <Widget>[ VideoPlayer(_controller), ClosedCaption(text: _controller.value.caption.text), ], ); … } }
  22. ࣈນ class RemoteVideo extends StatefulWidget { … } class _RemoteVideoState

    extends State<RemoteVideo> { late VideoPlayerController _controller; Future<ClosedCaptionFile> _loadCaptions() async { final String fileContents = await DefaultAssetBundle.of(context).loadString('assets/bumble_bee_captions.srt'); return SubRipCaptionFile(fileContents); } @override void initState() { super.initState(); _controller = VideoPlayerController.network( 'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4', closedCaptionFile: _loadCaptions(), ); _controller.initialize(); _controller.play(); } … @override Widget build(BuildContext context) { return … Stack( children: <Widget>[ VideoPlayer(_controller), ClosedCaption(text: _controller.value.caption.text), ], ); … } }
  23. ࣈນ • ϩʔΧϧϑΝΠϧ͔ΒಡΈࠐΉ͚ͩ • ετϦʔϜ͔Βड͚औΔ৔߹͸ผ్࣮૷͕ඞཁ • SRTʹରԠ • WebVTT͸1೥͘Β͍͔͚ͯઈࢍϨϏϡʔத flutter/plugins#2878

  24. ʴЋ • ࣈນ • γʔΫόʔ • ϥΠϑαΠΫϧʹ߹Θͤͯ࠶ੜʗఀࢭ

  25. γʔΫόʔ class RemoteVideo extends StatefulWidget { … } class _RemoteVideoState

    extends State<RemoteVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.network('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'); _controller.initialize(); _controller.play(); } … @override Widget build(BuildContext context) { return … Stack( alignment: Alignment.bottomCenter, children: <Widget>[ VideoPlayer(_controller), VideoProgressIndicator(_controller, allowScrubbing: true), ], ); … } }
  26. γʔΫόʔ class RemoteVideo extends StatefulWidget { … } class _RemoteVideoState

    extends State<RemoteVideo> { late VideoPlayerController _controller; @override void initState() { super.initState(); _controller = VideoPlayerController.network('https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4'); _controller.initialize(); _controller.play(); } … @override Widget build(BuildContext context) { return … Stack( alignment: Alignment.bottomCenter, children: <Widget>[ VideoPlayer(_controller), VideoProgressIndicator(_controller, allowScrubbing: true), ], ); … } }
  27. γʔΫόʔ • ΧελϚΠζੑ௿͍͚ͲαΫοͱ͍͍ײ͡ʹͰ͖Δ

  28. ʴЋ • ࣈນ • γʔΫόʔ • ϥΠϑαΠΫϧʹ߹Θͤͯ࠶ੜʗఀࢭ

  29. ϥΠϑαΠΫϧʹ߹Θͤͯ࠶ੜʗఀࢭ class _VideoAppLifeCycleObserver extends Object with WidgetsBindingObserver { _VideoAppLifeCycleObserver(this._controller); bool

    _wasPlayingBeforePause = false; final VideoPlayerController _controller; void initialize() { WidgetsBinding.instance!.addObserver(this); } @override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.paused: _wasPlayingBeforePause = _controller.value.isPlaying; _controller.pause(); break; case AppLifecycleState.resumed: if (_wasPlayingBeforePause) { _controller.play(); } break; default: } } void dispose() { WidgetsBinding.instance!.removeObserver(this); } }
  30. ϥΠϑαΠΫϧʹ߹Θͤͯ࠶ੜʗఀࢭ class _VideoAppLifeCycleObserver extends Object with WidgetsBindingObserver { _VideoAppLifeCycleObserver(this._controller); bool

    _wasPlayingBeforePause = false; final VideoPlayerController _controller; void initialize() { WidgetsBinding.instance!.addObserver(this); } @override void didChangeAppLifecycleState(AppLifecycleState state) { switch (state) { case AppLifecycleState.paused: _wasPlayingBeforePause = _controller.value.isPlaying; _controller.pause(); break; case AppLifecycleState.resumed: if (_wasPlayingBeforePause) { _controller.play(); } break; default: } } void dispose() { WidgetsBinding.instance!.removeObserver(this); } }
  31. Α͠ͳʹ΍ͬͯ͘Εͦ͏͚ͩͲ…

  32. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  33. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  34. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  35. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  36. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  37. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  38. Cookieͷઃఆ • AVURLAssetੜ੒࣌ʹcookieΛ౉͍ͨ͠৔߹ • issueɾPR͸ͪΐ͍ͪΐ͍ग़ͯΔ flutter/plugins#2882 • react-nativeͰ͸Ϛʔδ͞Ε͍ͯΔ • react-native-video/react-native-video#2014

    • flutter/plugins#897 (comment) • AVURLAsset(url: url, options: [AVURLAssetHTTPCookiesKey: cookies])
  39. ग़དྷͳ͍͜ͱ • ը࣭ઃఆ • ϏοτϨʔτΛઃఆͰ͖ͳ͍ • ࣈນɾ෭Ի੠ • ετϦʔϜʹ৐ͬͯΔࣈນɾԻ੠ͷऔಘɺબ୒͕Ͱ͖ͳ͍ •

    UI • ࣗ෼Ͱ࣮૷͢Δඞཁ͕͋Δ • DRM flutter#24923 • Cookieͷઃఆ • ʢΤϥʔϋϯυϦϯάʣ
  40. ΤϥʔϋϯυϦϯά class VideoPlayerController extends ValueNotifier<VideoPlayerValue> { … } … class

    VideoPlayerValue { … final Duration duration; final Duration position; final Caption caption; final List<DurationRange> buffered; final bool isPlaying; final bool isLooping; final bool isBuffering; final double volume; final double playbackSpeed; final String? errorDescription; final Size size; final bool isInitialized; bool get hasError => errorDescription != null; … }
  41. ΤϥʔϋϯυϦϯά class VideoPlayerController extends ValueNotifier<VideoPlayerValue> { … } … class

    VideoPlayerValue { … final Duration duration; final Duration position; final Caption caption; final List<DurationRange> buffered; final bool isPlaying; final bool isLooping; final bool isBuffering; final double volume; final double playbackSpeed; final String? errorDescription; final Size size; final bool isInitialized; bool get hasError => errorDescription != null; … }
  42. ΤϥʔϋϯυϦϯά class VideoPlayerController extends ValueNotifier<VideoPlayerValue> { … } … class

    VideoPlayerValue { … final Duration duration; final Duration position; final Caption caption; final List<DurationRange> buffered; final bool isPlaying; final bool isLooping; final bool isBuffering; final double volume; final double playbackSpeed; final String? errorDescription; final Size size; final bool isInitialized; bool get hasError => errorDescription != null; … }
  43. ΤϥʔϋϯυϦϯά // iOS _eventSink([FlutterError errorWithCode:@"VideoError" message:@"Video cannot be fast-forwarded beyond

    2.0x" details:nil]); _eventSink([FlutterError errorWithCode:@"VideoError" message:[@"Failed to load video: “ stringByAppendingString:[item.error localizedDescription]] details:nil]); // Android eventSink.error("VideoError", "Video player had error " + error, null);
  44. ΤϥʔϋϯυϦϯά // iOS … AVPlayerItem* item = (AVPlayerItem*)object; switch (item.status)

    { case AVPlayerItemStatusFailed: if (_eventSink != nil) { _eventSink([FlutterError errorWithCode:@"VideoError" message:[@"Failed to load video: " stringByAppendingString:[item.error localizedDescription]] details:nil]); } break; case AVPlayerItemStatusUnknown: break; case AVPlayerItemStatusReadyToPlay: [item addOutput:_videoOutput]; [self sendInitialized]; [self updatePlayingState]; break; } …
  45. ΤϥʔϋϯυϦϯά // iOS … AVPlayerItem* item = (AVPlayerItem*)object; switch (item.status)

    { case AVPlayerItemStatusFailed: if (_eventSink != nil) { _eventSink([FlutterError errorWithCode:@"VideoError" message:[@"Failed to load video: " stringByAppendingString:[item.error localizedDescription]] details:nil]); } break; case AVPlayerItemStatusUnknown: break; case AVPlayerItemStatusReadyToPlay: [item addOutput:_videoOutput]; [self sendInitialized]; [self updatePlayingState]; break; } …
  46. ΤϥʔϋϯυϦϯά // Android exoPlayer.addListener( new EventListener() { … @Override public

    void onPlayerError(final ExoPlaybackException error) { setBuffering(false); if (eventSink != null) { eventSink.error("VideoError", "Video player had error " + error, null); } } });
  47. ΤϥʔϋϯυϦϯά // Android exoPlayer.addListener( new EventListener() { … @Override public

    void onPlayerError(final ExoPlaybackException error) { setBuffering(false); if (eventSink != null) { eventSink.error("VideoError", "Video player had error " + error, null); } } });
  48. ΤϥʔϋϯυϦϯά • ग़དྷͳ͍Θ͚Ͱ͸ͳ͍ • isBuffering౳ݟΕ͹े෼ͳ৔߹΋ • ࡉ͔͘ϋϯυϦϯά͚ͨ͠Ε͹࣮૷͢Δ͔͠ͳͦ͞͏

  49. ໨࣍ • ύοέʔδͷ঺հ • video_playerʹ͍ͭͯ • ࣮૷Λ௥ͬͯΈΔ • ػೳΛ௥Ճ͢Δ •

    ·ͱΊ
  50. جຊతͳ࢓૊Έ • BasicMessageChannelͱEventChannelͷ૊Έ߹Θͤ • BasicMessageChannelɿϓϥοτϑΥʔϜͱDartؒͰ૒ํ޲ʹϝοηʔδ Λૹड৴͢ΔͨΊͷAPI • EventChannelɿϓϥοτϑΥʔϜ͔ΒDartଆʹΠϕϯτ௨஌͢ΔͨΊͷAPI video_player_platform_interface video_player

    EventChannel BasicMessageChannel
  51. EventChannel initialized completed bufferingStart bufferingUpdate bufferingEnd video_player_platform_interface video_player Stream EventChannel

  52. BasicMessageChannel video_player_platform_interface video_player getPosition(_:) send replay Future<Duration> ྫ

  53. BasicMessageChannel video_player_platform_interface video_player getPosition(_:) send replay Future<Duration> ྫ

  54. BasicMessageChannel video_player_platform_interface video_player getPosition(_:) send replay Future<Duration> ྫ

  55. BasicMessageChannel video_player_platform_interface video_player getPosition(_:) send replay Future<Duration> ྫ

  56. BasicMessageChannel video_player_platform_interface video_player getPosition(_:) send replay Future<Duration> ྫ

  57. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } }
  58. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } } class TextureMessage { int? textureId; Object encode() { final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; pigeonMap['textureId'] = textureId; return pigeonMap; } static TextureMessage decode(Object message) { final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; return TextureMessage()..textureId = pigeonMap['textureId'] as int; } }
  59. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } } class TextureMessage { int? textureId; Object encode() { final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; pigeonMap['textureId'] = textureId; return pigeonMap; } static TextureMessage decode(Object message) { final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; return TextureMessage()..textureId = pigeonMap['textureId'] as int; } }
  60. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } } class TextureMessage { int? textureId; Object encode() { final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; pigeonMap['textureId'] = textureId; return pigeonMap; } static TextureMessage decode(Object message) { final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; return TextureMessage()..textureId = pigeonMap['textureId'] as int; } }
  61. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } } class TextureMessage { int? textureId; Object encode() { final Map<Object?, Object?> pigeonMap = <Object?, Object?>{}; pigeonMap['textureId'] = textureId; return pigeonMap; } static TextureMessage decode(Object message) { final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>; return TextureMessage()..textureId = pigeonMap['textureId'] as int; } }
  62. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } }
  63. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } } Channel͸APIຖʹ࡞੒
  64. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } }
  65. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } }
  66. BasicMessageChannel Future<PositionMessage> position(TextureMessage arg) async { final Object encoded =

    arg.encode(); const BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>( 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); final Map<Object?, Object?>? replyMap = await channel.send(encoded) as Map<Object?, Object?>?; if (replyMap == null) { throw PlatformException( code: 'channel-error', message: 'Unable to establish connection on channel.', details: null, ); } else if (replyMap['error'] != null) { final Map<Object?, Object?> error = replyMap['error'] as Map<Object?, Object?>; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, details: error['details'], ); } else { return PositionMessage.decode(replyMap['result']!); } }
  67. ಈըͷඳը • PlatformView

  68. ಈըͷඳը • PlatformView

  69. ಈըͷඳը • PlatformView • Texture Widget • https://api.flutter.dev/flutter/widgets/Texture-class.html • ϓϥοτϑΥʔϜଆ͔ΒtextureIdΛड͚औΓɺϏσΦϑϨʔϜ౸ண

    ࣌౳ʹࣗಈతʹόοΫΤϯυͷࢦࣔʹैͬͯ࠶ඳը͞ΕΔ • ௨ৗɺDartίʔυͷ࣮ߦ͸ؚ·Εͳ͍
  70. ಈըͷඳը • Dart • iOS • Android

  71. ಈըͷඳը • Dart • iOS • Android

  72. Dart // VideoPlayerController @override Widget build(BuildContext context) { return _textureId

    == VideoPlayerController.kUninitializedTextureId ? Container() : _videoPlayerPlatform.buildView(_textureId); } // video_player_platform_interface @override Widget buildView(int textureId) { return Texture(textureId: textureId); }
  73. Dart // VideoPlayerController @override Widget build(BuildContext context) { return _textureId

    == VideoPlayerController.kUninitializedTextureId ? Container() : _videoPlayerPlatform.buildView(_textureId); } // video_player_platform_interface @override Widget buildView(int textureId) { return Texture(textureId: textureId); }
  74. Dart // VideoPlayerController @override Widget build(BuildContext context) { return _textureId

    == VideoPlayerController.kUninitializedTextureId ? Container() : _videoPlayerPlatform.buildView(_textureId); } // video_player_platform_interface @override Widget buildView(int textureId) { return Texture(textureId: textureId); }
  75. ಈըͷඳը • Dart • iOS • Android

  76. iOS @protocol FlutterTexture <NSObject> /** Copy the contents of the

    texture into a `CVPixelBuffer`. */ - (CVPixelBufferRef _Nullable)copyPixelBuffer; /** * Called when the texture is unregistered. * * Called on the raster thread. */ @optional - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture; @end FlutterTexture
  77. iOS @protocol FlutterTexture <NSObject> /** Copy the contents of the

    texture into a `CVPixelBuffer`. */ - (CVPixelBufferRef _Nullable)copyPixelBuffer; /** * Called when the texture is unregistered. * * Called on the raster thread. */ @optional - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture; @end FlutterTexture
  78. iOS @protocol FlutterTexture <NSObject> /** Copy the contents of the

    texture into a `CVPixelBuffer`. */ - (CVPixelBufferRef _Nullable)copyPixelBuffer; /** * Called when the texture is unregistered. * * Called on the raster thread. */ @optional - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture; @end FlutterTexture - (CVPixelBufferRef)copyPixelBuffer { CMTime outputItemTime = [_videoOutput itemTimeForHostTime:CACurrentMediaTime()]; if ([_videoOutput hasNewPixelBufferForItemTime:outputItemTime]) { return [_videoOutput copyPixelBufferForItemTime:outputItemTime itemTimeForDisplay:NULL]; } else { return NULL; } }
  79. iOS @protocol FlutterTexture <NSObject> /** Copy the contents of the

    texture into a `CVPixelBuffer`. */ - (CVPixelBufferRef _Nullable)copyPixelBuffer; /** * Called when the texture is unregistered. * * Called on the raster thread. */ @optional - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture; @end FlutterTexture - (CVPixelBufferRef)copyPixelBuffer { CMTime outputItemTime = [_videoOutput itemTimeForHostTime:CACurrentMediaTime()]; if ([_videoOutput hasNewPixelBufferForItemTime:outputItemTime]) { return [_videoOutput copyPixelBufferForItemTime:outputItemTime itemTimeForDisplay:NULL]; } else { return NULL; } }
  80. iOS @protocol FlutterTexture <NSObject> /** Copy the contents of the

    texture into a `CVPixelBuffer`. */ - (CVPixelBufferRef _Nullable)copyPixelBuffer; /** * Called when the texture is unregistered. * * Called on the raster thread. */ @optional - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture; @end FlutterTexture
  81. iOS @protocol FlutterTexture <NSObject> /** Copy the contents of the

    texture into a `CVPixelBuffer`. */ - (CVPixelBufferRef _Nullable)copyPixelBuffer; /** * Called when the texture is unregistered. * * Called on the raster thread. */ @optional - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture; @end FlutterTexture - (void)onTextureUnregistered:(NSObject<FlutterTexture>*)texture { dispatch_async(dispatch_get_main_queue(), ^{ [self dispose]; }); }
  82. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry
  83. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry
  84. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry … int64_t textureId = [_registry registerTexture:player]; …
  85. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry … int64_t textureId = [_registry registerTexture:player]; … textureId͕ฦΔ
  86. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry
  87. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry • FlutterʹTexture͕ߋ৽͞Εͨͱ఻͑Δ • FlutterTexture.copyPixcelBuffer()͕ݺͼ͞ΕΔ
  88. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry _displayLink = [CADisplayLink displayLinkWithTarget:frameUpdater selector:@selector(onDisplayLink:)]; ""... - (void)onDisplayLink:(CADisplayLink*)link { [_registry textureFrameAvailable:_textureId]; }
  89. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry _displayLink = [CADisplayLink displayLinkWithTarget:frameUpdater selector:@selector(onDisplayLink:)]; ""... - (void)onDisplayLink:(CADisplayLink*)link { [_registry textureFrameAvailable:_textureId]; }
  90. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry _displayLink = [CADisplayLink displayLinkWithTarget:frameUpdater selector:@selector(onDisplayLink:)]; ""... - (void)onDisplayLink:(CADisplayLink*)link { [_registry textureFrameAvailable:_textureId]; }
  91. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry
  92. iOS @protocol FlutterTextureRegistry <NSObject> /** * Registers a `FlutterTexture` for

    usage in Flutter and returns an id that can be used to reference * that texture when calling into Flutter with channels. Textures must be registered on the * platform thread. */ - (int64_t)registerTexture:(NSObject<FlutterTexture>*)texture; /** * Notifies Flutter that the content of the previously registered texture has been updated. * * This will trigger a call to `-[FlutterTexture copyPixelBuffer]` on the raster thread. */ - (void)textureFrameAvailable:(int64_t)textureId; /** * Unregisters a `FlutterTexture` that has previously regeistered with `registerTexture:`. Textures * must be unregistered on the the platform thread. * * @param textureId The result that was previously returned from `registerTexture:`. */ - (void)unregisterTexture:(int64_t)textureId; @end FlutterTextureRegistry - (void)dispose:(FLTTextureMessage*)input error:(FlutterError**)error { … [_registry unregisterTexture:input.textureId.intValue];
  93. ಈըͷඳը • Dart • iOS • Android

  94. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry
  95. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry
  96. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry ... TextureRegistry.SurfaceTextureEntry handle = flutterState.textureRegistry.createSurfaceTexture(); ...
  97. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry
  98. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry ... surface = new Surface(textureEntry.surfaceTexture()); exoPlayer.setVideoSurface(surface); ...
  99. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry
  100. Android public interface TextureRegistry { /** * Creates and registers

    a SurfaceTexture managed by the Flutter engine. * * @return A SurfaceTextureEntry. */ SurfaceTextureEntry createSurfaceTexture(); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ long id(); /** Deregisters and releases this SurfaceTexture. */ void release(); } } TextureRegistry textureId͕ฦΔ
  101. ໨࣍ • ύοέʔδͷ঺հ • video_playerʹ͍ͭͯ • ࣮૷Λ௥ͬͯΈΔ • ػೳΛ௥Ճ͢Δ •

    ·ͱΊ
  102. pigeon • pub.dev • GitHub • ϓϥοτϑΥʔϜͱDartͷ઀ଓ෦෼Λࣗಈੜ੒ͯ͘͠ΕΔ

  103. pigeon/messages.dart class LimitBitrateMessage { int textureId; int limitBitrate; } ...

    abstract class VideoPlayerApi { void initialize(); TextureMessage create(CreateMessage msg); void dispose(TextureMessage msg); void setLooping(LoopingMessage msg); void setVolume(VolumeMessage msg); void setPlaybackSpeed(PlaybackSpeedMessage msg); void play(TextureMessage msg); PositionMessage position(TextureMessage msg); void seekTo(PositionMessage msg); void pause(TextureMessage msg); void setMixWithOthers(MixWithOthersMessage msg); void setLimitBitrate(LimitBitrateMessage msg); }
  104. pigeon/messages.dart class LimitBitrateMessage { int textureId; int limitBitrate; } ...

    abstract class VideoPlayerApi { void initialize(); TextureMessage create(CreateMessage msg); void dispose(TextureMessage msg); void setLooping(LoopingMessage msg); void setVolume(VolumeMessage msg); void setPlaybackSpeed(PlaybackSpeedMessage msg); void play(TextureMessage msg); PositionMessage position(TextureMessage msg); void seekTo(PositionMessage msg); void pause(TextureMessage msg); void setMixWithOthers(MixWithOthersMessage msg); void setLimitBitrate(LimitBitrateMessage msg); }
  105. pigeon/messages.dart class LimitBitrateMessage { int textureId; int limitBitrate; } ...

    abstract class VideoPlayerApi { void initialize(); TextureMessage create(CreateMessage msg); void dispose(TextureMessage msg); void setLooping(LoopingMessage msg); void setVolume(VolumeMessage msg); void setPlaybackSpeed(PlaybackSpeedMessage msg); void play(TextureMessage msg); PositionMessage position(TextureMessage msg); void seekTo(PositionMessage msg); void pause(TextureMessage msg); void setMixWithOthers(MixWithOthersMessage msg); void setLimitBitrate(LimitBitrateMessage msg); }
  106. ϑΝΠϧͷੜ੒ $flutter pub run pigeon --input pigeons/messages.dart —dart_null_safety $(cd ../../../;

    ./script/incremental_build.sh format --travis --clang-format=clang-format-7)
  107. ϑΝΠϧͷੜ੒ $flutter pub run pigeon --input pigeons/messages.dart —dart_null_safety $(cd ../../../;

    ./script/incremental_build.sh format --travis --clang-format=clang-format-7)
  108. ϑΝΠϧͷੜ੒ $flutter pub run pigeon --input pigeons/messages.dart —dart_null_safety $(cd ../../../;

    ./script/incremental_build.sh format --travis --clang-format=clang-format-7)
  109. ϑΝΠϧͷੜ੒ $flutter pub run pigeon --input pigeons/messages.dart —dart_null_safety $(cd ../../../;

    ./script/incremental_build.sh format --travis --clang-format=clang-format-7) flutter/plugin ಠࣗͷϑΥʔϚοτ
  110. ࣮૷͢Δ • iOS͸Objective-CɺAndroid͸JavaͰͦΕͧΕ࣮૷͢Δ

  111. ໨࣍ • ύοέʔδͷ঺հ • video_playerʹ͍ͭͯ • ࣮૷Λ௥ͬͯΈΔ • ػೳΛ௥Ճ͢Δ •

    ·ͱΊ
  112. ·ͱΊ • ΨνΨνͳཁ݅͡Όͳ͚Ε͹αΫοͱಋೖͰ͖ͦ͏ • Objective-CͱJava • ExoPlayerͷexampleॆ࣮ͯͨ͠

  113. ͋Γ͕ͱ͏͍͟͝·ͨ͠