Skip to content

Commit efc0980

Browse files
Merge pull request #434 from romaingyh/master
Update to Dart 3 and Flutter 3.13
2 parents 845b157 + 80539b7 commit efc0980

20 files changed

+190
-224
lines changed

flutter_vlc_player/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ rootProject.allprojects {
2222
apply plugin: 'com.android.library'
2323

2424
android {
25-
compileSdkVersion 33
25+
compileSdk 33
2626

2727
defaultConfig {
2828
minSdkVersion 19

flutter_vlc_player/example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ apply plugin: 'com.android.application'
2525
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
2626

2727
android {
28-
compileSdkVersion 31
28+
compileSdkVersion 33
2929

3030
lintOptions {
3131
disable 'InvalidPackage'

flutter_vlc_player/example/android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath 'com.android.tools.build:gradle:4.1.3'
8+
classpath 'com.android.tools.build:gradle:7.4.2'
99
}
1010
}
1111

@@ -26,6 +26,6 @@ subprojects {
2626

2727

2828

29-
task clean(type: Delete) {
29+
tasks.register("clean", Delete) {
3030
delete rootProject.buildDir
3131
}

flutter_vlc_player/example/android/gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip

flutter_vlc_player/example/lib/controls_overlay.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'package:flutter/material.dart';
2-
32
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
43

54
class ControlsOverlay extends StatelessWidget {
@@ -14,7 +13,10 @@ class ControlsOverlay extends StatelessWidget {
1413

1514
final VlcPlayerController controller;
1615

17-
const ControlsOverlay({Key key, this.controller}) : super(key: key);
16+
const ControlsOverlay({
17+
required this.controller,
18+
super.key,
19+
});
1820

1921
@override
2022
Widget build(BuildContext context) {
@@ -45,7 +47,6 @@ class ControlsOverlay extends StatelessWidget {
4547
color: Colors.black45,
4648
child: FittedBox(
4749
child: Row(
48-
crossAxisAlignment: CrossAxisAlignment.center,
4950
mainAxisAlignment: MainAxisAlignment.spaceAround,
5051
children: [
5152
IconButton(
@@ -118,9 +119,7 @@ class ControlsOverlay extends StatelessWidget {
118119
}
119120

120121
/// Returns a callback which seeks the video relative to current playing time.
121-
Future<void> _seekRelative(Duration seekStep) async {
122-
if (controller.value.duration != null) {
123-
await controller.seekTo(controller.value.position + seekStep);
124-
}
122+
Future<void> _seekRelative(Duration seekStep) {
123+
return controller.seekTo(controller.value.position + seekStep);
125124
}
126125
}

flutter_vlc_player/example/lib/multiple_tab.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
3-
43
import 'package:flutter_vlc_player_example/vlc_player_with_controls.dart';
54

65
class MultipleTab extends StatefulWidget {
@@ -12,19 +11,19 @@ class _MultipleTabState extends State<MultipleTab> {
1211
static const _heightWithControls = 400.0;
1312
static const _heightWithoutControls = 300.0;
1413

15-
List<VlcPlayerController> controllers;
14+
List<VlcPlayerController> controllers = <VlcPlayerController>[];
15+
1616
List<String> urls = [
1717
'https://www.tomandjerryonline.com/Videos/Ford%20Mondeo%20-%20Tom%20and%20Jerry.mov',
1818
'https://www.tomandjerryonline.com/Videos/TomAndJerryTales_HQ.wmv',
19-
'https://www.tomandjerryonline.com/Videos/tjpb1.mov'
19+
'https://www.tomandjerryonline.com/Videos/tjpb1.mov',
2020
];
2121

2222
bool showPlayerControls = true;
2323

2424
@override
2525
void initState() {
2626
super.initState();
27-
controllers = <VlcPlayerController>[];
2827
for (var i = 0; i < urls.length; i++) {
2928
final controller = VlcPlayerController.network(
3029
urls[i],

flutter_vlc_player/example/lib/single_tab.dart

Lines changed: 39 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

flutter_vlc_player/example/lib/video_data.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ class VideoData {
33
final String path;
44
final VideoType type;
55

6-
VideoData({
7-
this.name,
8-
this.path,
9-
this.type,
6+
const VideoData({
7+
required this.name,
8+
required this.path,
9+
required this.type,
1010
});
1111
}
1212

0 commit comments

Comments
 (0)