当前位置:网站首页>Essentials of fleet video playback and fleet videoplayer video playback components
Essentials of fleet video playback and fleet videoplayer video playback components
2022-06-23 02:21:00 【Susceptible to cold】
1 Add dependency
# Video playback video_player: ^1.0.1
2 Preparation before playing video
2.1 Network access
stay ios In the catalog info.plist In the manifest file iOS Set up http Network access :
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
As shown in the figure below
stay android In the catalog AndroidManifest.xml Configure network request permissions and... In the manifest file http Access rights of
<!-- Network request permission -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- External file storage permissions -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>networkSecurityConfig The configuration is http Access right
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>3 Video playback
The loading and playback of video resources are controlled through VideoPlayerController To operate the
3.1 Loading of video resources
VideoPlayerController _playerController ;
@override
void initState() {
super.initState();
// Network link
//VideoPlayerController.network(url);
//VideoPlayerController.file(File(url));
// Local link
_videoPlayerController =
VideoPlayerController.asset("asset Resource path ");
// Call initialization method
_videoPlayerController.initialize()
// Callback after asynchronous execution
..whenComplete(() {
// Refresh the page
setState(() {});
});
}3.2 Video playback components
AspectRatio( // Set the size of the video Aspect ratio . The aspect ratio is expressed as the aspect ratio . for example ,16:9 The value of the aspect ratio is 16.0/9.0 aspectRatio: _videoPlayerController.value.aspectRatio, // Play video components child: VideoPlayer(_videoPlayerController), ), )
3.3 Video playback related control
// Get the information about the current video playing
VideoPlayerValue videoPlayerValue = _videoPlayerController.value;
// Initialization complete
bool initialized = videoPlayerValue.initialized;
// Is it playing
bool isPlaying = videoPlayerValue.isPlaying;
// The width to height ratio of the currently playing video
double aspectRatio = videoPlayerValue.aspectRatio;
// Whether the current video is cached
bool isBuffer = videoPlayerValue.isBuffering;
// Is the current video looping
bool isLoop = videoPlayerValue.isLooping;
// The total length of video currently playing
Duration totalDuration = videoPlayerValue.duration;
// Where the video is currently playing
Duration currentDuration = videoPlayerValue.position;
if (initialized) {
// Video initialized
if (isPlaying) {
// Playing --- Pause
_videoPlayerController.pause();
} else {
// Pause ---- Play
_videoPlayerController.play();
}
setState(() {});
} else {
// uninitialized
_videoPlayerController.initialize().then((_) {
// videoPlayerController.play();
// setState(() {});
});
}边栏推荐
- "Initial C language" (Part 1)
- //1.10 initial value of variable
- Dynamic address book in C language (add, delete, modify, check (duplicate), delete, sort and export)
- JS advanced part
- 2022-1-14
- Reptile lesson 1
- 5g core network and core network evolution
- SetTimeout and setinterval execution time
- Microservice Optimization: internal communication of microservices using grpc
- //1.16 getchar function
猜你喜欢

Interviewer: what is the difference between SSH and SSM frameworks? How to choose??

Performance testing -- Interpretation and practice of 16 enterprise level project framework

1. Mx6u bare metal program (2) - Lighting master (imitating 32 register version)

Circuit analysis (circuit principle)

5g core network and core network evolution

Custom shapes for ugui skill learning

Branch and loop statements (including goto statements) -part1

4. functions and inline functions with default values for formal parameters

pd. read_ CSV and np Differences between loadtext

Classical questions of function recursion
随机推荐
Three ways to get class
What is a smart farm?
Bc116 xiaolele changed to digital
WM view of commodity master data in SAP retail preliminary level
1. Mx6u bare metal program (2) - Lighting master (imitating 32 register version)
You must know the type and method of urllib
Exploit format string vulnerability in CDE
Lying in the trough, write it yourself if you can't grab it. Use code to realize a Bing Dwen Dwen. It's so beautiful
Information theory and coding
Digital integrated circuit design process
Mongodb aggregate query implements multi table associated query, type conversion, and returns specified parameters.
Operator part
pd. read_ CSV and np Differences between loadtext
5. explain function overloading
Using mock data in vite projects -vite plugin mock
Xgboost principle
//1.7 use of escape characters
Solution to the problem of easycvr switching MySQL database traffic statistics cannot be displayed
Use of apicloud AVM framework list component list view and flex layout tutorial
Exercise analysis summary