@@ -19,10 +19,45 @@ class _SingleTabState extends State<SingleTab> {
1919
2020 final _key = GlobalKey <VlcPlayerWithControlsState >();
2121
22- VlcPlayerController _controller;
22+ // ignore: avoid-late-keyword
23+ late final VlcPlayerController _controller;
24+
2325 //
24- List <VideoData > listVideos;
25- int selectedVideoIndex;
26+ List <VideoData > listVideos = [
27+ const VideoData (
28+ name: 'Network Video 1' ,
29+ path:
30+ 'http://samples.mplayerhq.hu/MPEG-4/embedded_subs/1Video_2Audio_2SUBs_timed_text_streams_.mp4' ,
31+ type: VideoType .network,
32+ ),
33+ //
34+ const VideoData (
35+ name: 'Network Video 2' ,
36+ path: 'https://media.w3.org/2010/05/sintel/trailer.mp4' ,
37+ type: VideoType .network,
38+ ),
39+ //
40+ const VideoData (
41+ name: 'HLS Streaming Video 1' ,
42+ path:
43+ 'http://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel.ism/.m3u8' ,
44+ type: VideoType .network,
45+ ),
46+ //
47+ const VideoData (
48+ name: 'File Video 1' ,
49+ path: 'System File Example' ,
50+ type: VideoType .file,
51+ ),
52+ //
53+ const VideoData (
54+ name: 'Asset Video 1' ,
55+ path: 'assets/sample.mp4' ,
56+ type: VideoType .asset,
57+ ),
58+ ];
59+
60+ int selectedVideoIndex = 0 ;
2661
2762 Future <File > _loadVideoToFs () async {
2863 final videoData = await rootBundle.load ('assets/sample.mp4' );
@@ -34,49 +69,10 @@ class _SingleTabState extends State<SingleTab> {
3469 return temp;
3570 }
3671
37- void fillVideos () {
38- listVideos = [
39- VideoData (
40- name: 'Network Video 1' ,
41- path:
42- 'http://samples.mplayerhq.hu/MPEG-4/embedded_subs/1Video_2Audio_2SUBs_timed_text_streams_.mp4' ,
43- type: VideoType .network,
44- ),
45- //
46- VideoData (
47- name: 'Network Video 2' ,
48- path: 'https://media.w3.org/2010/05/sintel/trailer.mp4' ,
49- type: VideoType .network,
50- ),
51- //
52- VideoData (
53- name: 'HLS Streaming Video 1' ,
54- path:
55- 'http://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel.ism/.m3u8' ,
56- type: VideoType .network,
57- ),
58- //
59- VideoData (
60- name: 'File Video 1' ,
61- path: 'System File Example' ,
62- type: VideoType .file,
63- ),
64- //
65- VideoData (
66- name: 'Asset Video 1' ,
67- path: 'assets/sample.mp4' ,
68- type: VideoType .asset,
69- ),
70- ];
71- }
72-
7372 @override
7473 void initState () {
7574 super .initState ();
7675
77- //
78- fillVideos ();
79- selectedVideoIndex = 0 ;
8076 //
8177 final initVideo = listVideos[selectedVideoIndex];
8278 switch (initVideo.type) {
@@ -104,27 +100,24 @@ class _SingleTabState extends State<SingleTab> {
104100 ]),
105101 ),
106102 );
107- break ;
108103 case VideoType .file:
109104 final file = File (initVideo.path);
110105 _controller = VlcPlayerController .file (
111106 file,
112107 );
113- break ;
114108 case VideoType .asset:
115109 _controller = VlcPlayerController .asset (
116110 initVideo.path,
117111 options: VlcPlayerOptions (),
118112 );
119- break ;
120113 case VideoType .recorded:
121114 break ;
122115 }
123116 _controller.addOnInitListener (() async {
124117 await _controller.startRendererScanning ();
125118 });
126119 _controller.addOnRendererEventListener ((type, id, name) {
127- print ('OnRendererEventListener $type $id $name ' );
120+ debugPrint ('OnRendererEventListener $type $id $name ' );
128121 });
129122 }
130123
@@ -167,16 +160,12 @@ class _SingleTabState extends State<SingleTab> {
167160 switch (video.type) {
168161 case VideoType .network:
169162 iconData = Icons .cloud;
170- break ;
171163 case VideoType .file:
172164 iconData = Icons .insert_drive_file;
173- break ;
174165 case VideoType .asset:
175166 iconData = Icons .all_inbox;
176- break ;
177167 case VideoType .recorded:
178168 iconData = Icons .videocam;
179- break ;
180169 }
181170
182171 return ListTile (
@@ -212,7 +201,6 @@ class _SingleTabState extends State<SingleTab> {
212201 video.path,
213202 hwAcc: HwAcc .full,
214203 );
215- break ;
216204 case VideoType .file:
217205 if (! mounted) break ;
218206 ScaffoldMessenger .of (context).showSnackBar (
@@ -240,14 +228,11 @@ class _SingleTabState extends State<SingleTab> {
240228 ),
241229 );
242230 }
243- break ;
244231 case VideoType .asset:
245232 await _controller.setMediaFromAsset (video.path);
246- break ;
247233 case VideoType .recorded:
248234 final recordedFile = File (video.path);
249235 await _controller.setMediaFromFile (recordedFile);
250- break ;
251236 }
252237 setState (() {
253238 selectedVideoIndex = index;
0 commit comments