This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +51
-4
lines changed
packages/video_player/video_player_web Expand file tree Collapse file tree 4 files changed +51
-4
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.1.1
2
+
3
+ * Support videos from assets.
4
+
1
5
## 0.1.0+1
2
6
3
7
* Remove the deprecated ` author: ` field from pubspec.yaml
Original file line number Diff line number Diff line change @@ -42,8 +42,28 @@ class VideoPlayerPlugin extends VideoPlayerPlatform {
42
42
final int textureId = _textureCounter;
43
43
_textureCounter++ ;
44
44
45
+ Uri uri;
46
+ switch (dataSource.sourceType) {
47
+ case DataSourceType .network:
48
+ uri = Uri .parse (dataSource.uri);
49
+ break ;
50
+ case DataSourceType .asset:
51
+ String assetUrl = dataSource.asset;
52
+ if (dataSource.package != null && dataSource.package.isNotEmpty) {
53
+ assetUrl = 'packages/${dataSource .package }/$assetUrl ' ;
54
+ }
55
+ // 'webOnlyAssetManager' is only in the web version of dart:ui
56
+ // ignore: undefined_prefixed_name
57
+ assetUrl = ui.webOnlyAssetManager.getAssetUrl (assetUrl);
58
+ uri = Uri .parse (assetUrl);
59
+ break ;
60
+ case DataSourceType .file:
61
+ return Future .error (UnimplementedError (
62
+ 'web implementation of video_player cannot play local files' ));
63
+ }
64
+
45
65
final _VideoPlayer player = _VideoPlayer (
46
- uri: Uri . parse (dataSource. uri) ,
66
+ uri: uri,
47
67
textureId: textureId,
48
68
);
49
69
Original file line number Diff line number Diff line change 1
1
name : video_player_web
2
2
description : Web platform implementation of video_player
3
3
homepage : https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_web
4
- version : 0.1.0+ 1
4
+ version : 0.1.1
5
5
6
6
flutter :
7
7
plugin :
@@ -26,4 +26,4 @@ dev_dependencies:
26
26
27
27
environment :
28
28
sdk : " >=2.0.0-dev.28.0 <3.0.0"
29
- flutter : " >=1.10.0 <2.0.0"
29
+ flutter : " >=1.12.8 <2.0.0"
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ void main() {
33
33
expect (VideoPlayerPlatform .instance.init (), completes);
34
34
});
35
35
36
- test ('can create' , () {
36
+ test ('can create from network ' , () {
37
37
expect (
38
38
VideoPlayerPlatform .instance.create (
39
39
DataSource (
@@ -44,6 +44,29 @@ void main() {
44
44
completion (isNonZero));
45
45
});
46
46
47
+ test ('can create from asset' , () {
48
+ expect (
49
+ VideoPlayerPlatform .instance.create (
50
+ DataSource (
51
+ sourceType: DataSourceType .asset,
52
+ asset: 'videos/bee.mp4' ,
53
+ package: 'bee_vids' ,
54
+ ),
55
+ ),
56
+ completion (isNonZero));
57
+ });
58
+
59
+ test ('cannot create from file' , () {
60
+ expect (
61
+ VideoPlayerPlatform .instance.create (
62
+ DataSource (
63
+ sourceType: DataSourceType .file,
64
+ uri: '/videos/bee.mp4' ,
65
+ ),
66
+ ),
67
+ throwsUnimplementedError);
68
+ });
69
+
47
70
test ('can dispose' , () {
48
71
expect (VideoPlayerPlatform .instance.dispose (textureId), completes);
49
72
});
You can’t perform that action at this time.
0 commit comments