Skip to content

Commit

Permalink
[video_player] code excerpts in README (flutter#6296)
Browse files Browse the repository at this point in the history
* update README to pull code excerpts from basic

* update version to 2.4.6

* new line

* fix dart issues

* update to match snippet

* re-remove video_player from exclusion list

* add .

* sync readme to snippet

* Roll Flutter from 663bb66 to 723609b (29 revisions) (flutter#6297)

* Roll Flutter from 723609b to 9d78b2f (6 revisions) (flutter#6298)

Co-authored-by: engine-flutter-autoroll <engine-flutter-autoroll@skia.org>
  • Loading branch information
tarrinneal and engine-flutter-autoroll authored Aug 22, 2022
1 parent baab165 commit 89fe2a2
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 2.4.7

* Updates README via code excerpts.
* Fixes violations of new analysis option use_named_constants.

## 2.4.6
Expand Down
12 changes: 9 additions & 3 deletions packages/video_player/video_player/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?code-excerpt path-base="excerpts/packages/video_player_example"?>

# Video Player plugin for Flutter

[![pub package](https://img.shields.io/pub/v/video_player.svg)](https://pub.dev/packages/video_player)
Expand Down Expand Up @@ -50,19 +52,23 @@ The `VideoPlayerOptions.mixWithOthers` option can't be implemented in web, at le

## Example

<?code-excerpt "basic.dart (basic-example)"?>
```dart
import 'package:video_player/video_player.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
void main() => runApp(VideoApp());
void main() => runApp(const VideoApp());
/// Stateful widget to fetch and then display video content.
class VideoApp extends StatefulWidget {
const VideoApp({Key? key}) : super(key: key);
@override
_VideoAppState createState() => _VideoAppState();
}
class _VideoAppState extends State<VideoApp> {
VideoPlayerController _controller;
late VideoPlayerController _controller;
@override
void initState() {
Expand Down
20 changes: 20 additions & 0 deletions packages/video_player/video_player/example/build.excerpt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
targets:
$default:
sources:
include:
- lib/**
- android/app/src/main/**
# Some default includes that aren't really used here but will prevent
# false-negative warnings:
- $package$
- lib/$lib$
exclude:
- '**/.*/**'
- '**/build/**'
- 'android/app/src/main/res/**'
builders:
code_excerpter|code_excerpter:
enabled: true
generate_for:
- '**/*.dart'
- android/**/*.xml
73 changes: 73 additions & 0 deletions packages/video_player/video_player/example/lib/basic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is used to extract code samples for the README.md file.
// Run update-excerpts if you modify this file.

// ignore_for_file: library_private_types_in_public_api, public_member_api_docs

// #docregion basic-example
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

void main() => runApp(const VideoApp());

/// Stateful widget to fetch and then display video content.
class VideoApp extends StatefulWidget {
const VideoApp({Key? key}) : super(key: key);

@override
_VideoAppState createState() => _VideoAppState();
}

class _VideoAppState extends State<VideoApp> {
late VideoPlayerController _controller;

@override
void initState() {
super.initState();
_controller = VideoPlayerController.network(
'https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4')
..initialize().then((_) {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});
}

@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Demo',
home: Scaffold(
body: Center(
child: _controller.value.isInitialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
),
);
}

@override
void dispose() {
super.dispose();
_controller.dispose();
}
}
// #enddocregion basic-example
1 change: 1 addition & 0 deletions packages/video_player/video_player/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencies:
path: ../

dev_dependencies:
build_runner: ^2.1.10
flutter_driver:
sdk: flutter
flutter_test:
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
repository: https://github.com/flutter/plugins/tree/main/packages/video_player/video_player
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.4.6
version: 2.4.7

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down
1 change: 0 additions & 1 deletion script/configs/temp_exclude_excerpt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
- plugin_platform_interface
- quick_actions/quick_actions
- shared_preferences/shared_preferences
- video_player/video_player
- webview_flutter/webview_flutter
- webview_flutter_android
- webview_flutter_web

0 comments on commit 89fe2a2

Please sign in to comment.