Explorar el Código

修改时间为duration类型

hwh97 hace 6 años
padre
commit
c39c8af056
Se han modificado 3 ficheros con 28 adiciones y 13 borrados
  1. 8 8
      example/lib/main.dart
  2. 18 3
      lib/src/cartoon_material_controls.dart
  3. 2 2
      lib/src/more_video.dart

+ 8 - 8
example/lib/main.dart

@@ -60,14 +60,14 @@ class _ChewieDemoState extends State<ChewieDemo> {
         .then((_){
       setState(() {
         lists.addAll([
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  1200, true),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", 1200, false),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  1200, false),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", 1200, false),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  1200, false),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", 1200, false),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  1200, false),
-          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", 1200, false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  Duration(seconds: 1200), true),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", Duration(seconds: 1200), false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  Duration(seconds: 1200), false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", Duration(seconds: 1200), false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  Duration(seconds: 1200), false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", Duration(seconds: 1200), false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4",  Duration(seconds: 1200), false),
+          MoreVideo("http://www.i2edu.cn/images/pic04.png", "https://v-cdn.zjol.com.cn/276985.mp4", Duration(seconds: 1200), false),
         ]);
       });
       _i2materialControls = CartoonMaterialControls(

+ 18 - 3
lib/src/cartoon_material_controls.dart

@@ -485,9 +485,24 @@ class CartoonMaterialControlsState extends State<CartoonMaterialControls> {
                                   border: widget.moreVideo[index].isSelect ? Border.all(color: Color(0xFFEF765E), width: 3) : null,
                                 ),
                                 margin: EdgeInsets.only(left: 10, right: 10, bottom: 10),
-                                child: ClipRRect(
-                                  borderRadius: BorderRadius.circular(15),
-                                  child: Image.network(widget.moreVideo[index].imageUrl, fit: BoxFit.fill,),
+                                child: Stack(
+                                  children: <Widget>[
+                                    ClipRRect(
+                                      borderRadius: BorderRadius.circular(15),
+                                      child: Image.network(widget.moreVideo[index].imageUrl, fit: BoxFit.fill,),
+                                    ),
+                                    Align(
+                                      alignment: Alignment.bottomRight,
+                                      child: Container(
+                                        decoration: BoxDecoration(
+                                          color: Colors.black26,
+                                          borderRadius: BorderRadius.circular(20),
+                                        ),
+                                        padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 2),
+                                        child: Text(formatDuration(widget.moreVideo[index].duration), style: TextStyle(color: Colors.white, fontSize: 11.0,),),
+                                      ),
+                                    ),
+                                  ],
                                 ),
                               ),
                               onTap: () {

+ 2 - 2
lib/src/more_video.dart

@@ -2,8 +2,8 @@
 class MoreVideo {
   String imageUrl;
   String videoUrl;
-  int timing;
+  Duration duration;
   bool isSelect;
 
-  MoreVideo(this.imageUrl, this.videoUrl, this.timing, this.isSelect);
+  MoreVideo(this.imageUrl, this.videoUrl, this.duration, this.isSelect);
 }