forked from flutter/plugins
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[video_player] code excerpts in README (flutter#6296)
* 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
1 parent
baab165
commit 89fe2a2
Showing
7 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/video_player/video_player/example/build.excerpt.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters