@@ -2,9 +2,11 @@ library flutter_html_video;
2
2
3
3
import 'package:chewie/chewie.dart' ;
4
4
import 'package:flutter/material.dart' ;
5
+ import 'package:flutter/services.dart' ;
5
6
import 'package:flutter_html/flutter_html.dart' ;
6
7
import 'package:video_player/video_player.dart' ;
7
8
import 'package:html/dom.dart' as dom;
9
+ import 'dart:io' ;
8
10
9
11
typedef VideoControllerCallback = void Function (
10
12
dom.Element ? , ChewieController , VideoPlayerController );
@@ -24,11 +26,15 @@ CustomRenderMatcher videoMatcher() => (context) {
24
26
class VideoWidget extends StatefulWidget {
25
27
final RenderContext context;
26
28
final VideoControllerCallback ? callback;
29
+ final List <DeviceOrientation >? deviceOrientationsOnEnterFullScreen;
30
+ final List <DeviceOrientation > deviceOrientationsAfterFullScreen;
27
31
28
32
const VideoWidget ({
29
33
Key ? key,
30
34
required this .context,
31
35
this .callback,
36
+ this .deviceOrientationsOnEnterFullScreen,
37
+ this .deviceOrientationsAfterFullScreen = DeviceOrientation .values,
32
38
}) : super (key: key);
33
39
34
40
@override
@@ -54,7 +60,20 @@ class _VideoWidgetState extends State<VideoWidget> {
54
60
if (sources.isNotEmpty && sources.first != null ) {
55
61
_width = givenWidth ?? (givenHeight ?? 150 ) * 2 ;
56
62
_height = givenHeight ?? (givenWidth ?? 300 ) / 2 ;
57
- _videoController = VideoPlayerController .network (sources.first! );
63
+ Uri sourceUri = Uri .parse (sources.first! );
64
+ switch (sourceUri.scheme) {
65
+ case 'asset' :
66
+ _videoController = VideoPlayerController .asset (sourceUri.path);
67
+ break ;
68
+ case 'file' :
69
+ _videoController =
70
+ VideoPlayerController .file (File .fromUri (sourceUri));
71
+ break ;
72
+ default :
73
+ _videoController =
74
+ VideoPlayerController .network (sourceUri.toString ());
75
+ break ;
76
+ }
58
77
_chewieController = ChewieController (
59
78
videoPlayerController: _videoController! ,
60
79
placeholder:
@@ -67,6 +86,10 @@ class _VideoWidgetState extends State<VideoWidget> {
67
86
autoInitialize: true ,
68
87
aspectRatio:
69
88
_width == null || _height == null ? null : _width! / _height! ,
89
+ deviceOrientationsOnEnterFullScreen:
90
+ widget.deviceOrientationsOnEnterFullScreen,
91
+ deviceOrientationsAfterFullScreen:
92
+ widget.deviceOrientationsAfterFullScreen,
70
93
);
71
94
widget.callback? .call (
72
95
widget.context.tree.element, _chewieController! , _videoController! );
0 commit comments