-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用Provider管理全局视频状态,保证上个视频开始播放时自动停止下个视频
- Loading branch information
Showing
12 changed files
with
239 additions
and
128 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:video_player/video_player.dart'; | ||
|
||
class VideoControllerProvider with ChangeNotifier{ | ||
VideoPlayerController controller; | ||
|
||
setController(VideoPlayerController controller){ | ||
/* if (controller != null) { // 把上一个停掉 | ||
controller.pause(); | ||
controller.dispose(); | ||
} */ | ||
this.controller = controller; | ||
notifyListeners(); | ||
} | ||
|
||
VideoPlayerController getController(){ | ||
return this.controller; | ||
} | ||
|
||
// 判断参数是否是当前controller,如果是就把全局controller置空。 | ||
bool clearController(VideoPlayerController itemController){ | ||
bool isCurrentController = itemController!= null && itemController == this.controller; | ||
if (isCurrentController) { | ||
this.controller = null; | ||
} | ||
return isCurrentController; | ||
} | ||
|
||
} |
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
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,34 @@ | ||
import 'dart:ui'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
/// 毛玻璃背景 | ||
class BlurOvalWidget extends StatelessWidget { | ||
final Widget child; | ||
final double padding; | ||
final Color color; | ||
final double sigma; | ||
|
||
BlurOvalWidget( | ||
{this.child, | ||
this.padding: 0.0, | ||
this.sigma: 10.0, | ||
this.color: Colors.white10}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ClipOval( | ||
child: BackdropFilter( | ||
filter: ImageFilter.blur( | ||
sigmaX: 8, | ||
sigmaY: 8, | ||
), | ||
child: Container( | ||
color: color, | ||
padding: EdgeInsets.all(padding), | ||
child: child, | ||
), | ||
), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.