@@ -2,9 +2,11 @@ library flutter_html_video;
22
33import 'package:chewie/chewie.dart' ;
44import 'package:flutter/material.dart' ;
5+ import 'package:flutter/services.dart' ;
56import 'package:flutter_html/flutter_html.dart' ;
67import 'package:video_player/video_player.dart' ;
78import 'package:html/dom.dart' as dom;
9+ import 'dart:io' ;
810
911typedef VideoControllerCallback = void Function (
1012 dom.Element ? , ChewieController , VideoPlayerController );
@@ -24,11 +26,15 @@ CustomRenderMatcher videoMatcher() => (context) {
2426class VideoWidget extends StatefulWidget {
2527 final RenderContext context;
2628 final VideoControllerCallback ? callback;
29+ final List <DeviceOrientation >? deviceOrientationsOnEnterFullScreen;
30+ final List <DeviceOrientation > deviceOrientationsAfterFullScreen;
2731
2832 const VideoWidget ({
2933 Key ? key,
3034 required this .context,
3135 this .callback,
36+ this .deviceOrientationsOnEnterFullScreen,
37+ this .deviceOrientationsAfterFullScreen = DeviceOrientation .values,
3238 }) : super (key: key);
3339
3440 @override
@@ -54,7 +60,20 @@ class _VideoWidgetState extends State<VideoWidget> {
5460 if (sources.isNotEmpty && sources.first != null ) {
5561 _width = givenWidth ?? (givenHeight ?? 150 ) * 2 ;
5662 _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+ }
5877 _chewieController = ChewieController (
5978 videoPlayerController: _videoController! ,
6079 placeholder:
@@ -67,6 +86,10 @@ class _VideoWidgetState extends State<VideoWidget> {
6786 autoInitialize: true ,
6887 aspectRatio:
6988 _width == null || _height == null ? null : _width! / _height! ,
89+ deviceOrientationsOnEnterFullScreen:
90+ widget.deviceOrientationsOnEnterFullScreen,
91+ deviceOrientationsAfterFullScreen:
92+ widget.deviceOrientationsAfterFullScreen,
7093 );
7194 widget.callback? .call (
7295 widget.context.tree.element, _chewieController! , _videoController! );
0 commit comments