You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For migration to version 3, the project is based in swift. Your existing project will need to migratate
13
+
### Version 4.0 Upgrade For Existing Apps
14
+
To upgrade to version 4.0 (or v3.0), first you need to migrate the existing project to swift.
10
15
11
16
Delete existing ios folder from root of flutter project.
12
17
Run this command flutter create -i swift .
13
18
14
19
This command will create only ios directory with swift support. See https://stackoverflow.com/questions/52244346/how-to-enable-swift-support-for-existing-project-in-flutter
15
20
16
-
Change your project to use 9.0
17
-
# Uncomment this line to define a global platform for your project
For iOS, you need to opt into the Flutter embedded views preview.
@@ -44,8 +77,21 @@ Make sure that following line in `<project root>/ios/Podfile` uncommented:
44
77
> NOTE: While the Flutter `video_player` is not functional on iOS Simulators, this package (`flutter_vlc_player`) **is**
45
78
> fully functional on iOS simulators.
46
79
80
+
To enable vlc cast functionality for external displays (chromecast), you should also add the following:
81
+
82
+
```xml
83
+
<key>NSLocalNetworkUsageDescription</key>
84
+
<string>Used to search for chromecast devices</string>
85
+
<key>NSBonjourServices</key>
86
+
<array>
87
+
<string>_googlecast._tcp</string>
88
+
</array>
89
+
```
90
+
91
+
<hr>
92
+
47
93
### Android
48
-
To load media from an internet source, your app will need the `INTERNET` permission.
94
+
To load media/subitle from an internet source, your app will need the `INTERNET` permission.
49
95
This is done by ensuring your `<project root>/android/app/src/main/AndroidManifest.xml` file contains a `uses-permission`
50
96
declaration for `android.permission.INTERNET`:
51
97
```xml
@@ -54,6 +100,25 @@ declaration for `android.permission.INTERNET`:
54
100
55
101
As Flutter includes this permission by default, the permission is likely already declared in the file.
56
102
103
+
Note that if you got "Cleartext HTTP traffic to * is not permitted"
104
+
you need to add the `android:usesClearTextTraffic="true"` flag in the AndroidManifest.xml file, or define a new "Network Security Configuration" file. For more information, check https://developer.android.com/training/articles/security-config
105
+
106
+
<br>
107
+
108
+
In order to load media/subtitle from internal device storage, you should put the storage permissions as follows:
In some cases you also need to add the `android:requestLegacyExternalStorage="true"` flag to the Application tag in AndroidManifest.xml file.
114
+
115
+
After that you can access the media/subtitle file by
116
+
117
+
"/storage/emulated/0/{FilePath}"
118
+
"/sdcard/{FilePath}"
119
+
120
+
<hr>
121
+
57
122
## Quick Start
58
123
To start using the plugin, copy this code or follow the [example](https://github.com/solid-software/flutter_vlc_player/tree/master/example):
59
124
@@ -116,19 +181,48 @@ Container(
116
181
/// VlcPlayer widget.
117
182
const VlcPlayer({
118
183
Key key,
184
+
119
185
/// The [VlcPlayerController] that handles interaction with the platform code.
120
186
@required this.controller,
187
+
121
188
/// The aspect ratio used to display the video.
122
189
/// This MUST be provided, however it could simply be (parentWidth / parentHeight) - where parentWidth and
123
190
/// parentHeight are the width and height of the parent perhaps as defined by a LayoutBuilder.
124
191
@required this.aspectRatio,
192
+
125
193
/// This is the initial URL for the content. This also must be provided but [VlcPlayerController] implements
126
194
/// [VlcPlayerController.setStreamUrl] method so this can be changed at any time.
127
195
@required this.url,
196
+
197
+
/// Set hardware acceleration for player. Default is Automatic.
198
+
this.hwAcc,
199
+
200
+
/// Adds options to vlc. For more [https://wiki.videolan.org/VLC_command-line_help] If nothing is provided,
201
+
/// vlc will run without any options set.
202
+
this.options,
203
+
204
+
/// Set true if the provided url is local file
205
+
this.isLocalMedia,
206
+
207
+
/// The video should be played automatically.
208
+
this.autoplay,
209
+
210
+
/// Set the external subtitle to load with video
211
+
this.subtitle,
212
+
213
+
/// Set true if the provided subtitle is local file
214
+
this.isLocalSubtitle,
215
+
216
+
/// Set true if the provided subtitle is selected by default
217
+
this.isSubtitleSelected,
218
+
219
+
/// Loop the playback forever
220
+
this.loop,
221
+
128
222
/// Before the platform view has initialized, this placeholder will be rendered instead of the video player.
129
223
/// This can simply be a [CircularProgressIndicator] (see the example.)
130
224
this.placeholder,
131
-
});
225
+
});
132
226
```
133
227
134
228
```dart
@@ -137,7 +231,11 @@ VlcPlayerController({
137
231
/// This is a callback that will be executed once the platform view has been initialized.
138
232
/// If you want the media to play as soon as the platform view has initialized, you could just call
139
233
/// [VlcPlayerController.play] in this callback. (see the example)
140
-
VoidCallback onInit
234
+
VoidCallback onInit,
235
+
236
+
/// This is a callback that will be executed every time a new cast device detected/removed
237
+
/// It should be defined as "void Function(CastStatus, String, String)", where the CastStatus is an enum { DEVICE_ADDED, DEVICE_DELETED } and the next two String arguments are name and displayName of cast device, respectively.
238
+
CastCallback onCastHandler
141
239
}){
142
240
143
241
/*** PROPERTIES (Getters) ***/
@@ -155,6 +253,8 @@ VlcPlayerController({
155
253
/// - PlayingState.PLAYING
156
254
/// - PlayingState.BUFFERING
157
255
/// - PlayingState.STOPPED
256
+
/// - PlayingState.PAUSED
257
+
/// - PlayingState.ERROR
158
258
/// - null (When the player is uninitialized)
159
259
PlayingState playingState;
160
260
@@ -168,8 +268,8 @@ VlcPlayerController({
168
268
int duration = Duration.zero;
169
269
170
270
/// This is the dimensions of the content (height and width).
171
-
/// (SAFE) This value is always safe to use - it is set to Size.zero when the player is uninitialized.
172
-
Size size = Size.zero;
271
+
/// (SAFE) This value is always safe to use - it is set to VlcMediaSize.zero when the player is uninitialized.
272
+
VlcMediaSize size = VlcMediaSize.zero;
173
273
174
274
/// This is the aspect ratio of the content as returned by VLC once the content has been loaded.
175
275
/// (Not to be confused with the aspect ratio provided to the [VlcPlayer] widget, which is simply used for an
@@ -180,19 +280,55 @@ VlcPlayerController({
180
280
/// at which VLC is playing the content has changed.)
181
281
double playbackSpeed;
182
282
283
+
/// Returns the number of available audio tracks embedded in media except the original audio.
284
+
int audioTracksCount;
285
+
286
+
/// Returns the active audio track index. "-1" means audio is disabled.
287
+
int activeAudioTrack;
288
+
289
+
/// Returns the number of available subtitle tracks embedded in media.
290
+
int spuTracksCount;
291
+
292
+
/// Returns the active subitlte track index. "-1" means subitle is disabled.
293
+
int activeSpuTrack;
294
+
183
295
/*** METHODS ***/
184
-
/// [url] - the URL of the stream to start playing.
185
296
/// This stops playback and changes the URL. Once the new URL has been loaded, the playback state will revert to
186
297
/// its state before the method was called. (i.e. if setStreamUrl is called whilst media is playing, once the new
187
298
/// URL has been loaded, the new stream will begin playing.)
188
-
Future<void> setStreamUrl(String url);
299
+
/// [url] - the URL of the stream to start playing.
300
+
/// [isLocalMedia] - Set true if the media url is on local storage.
301
+
/// [subtitle] - Set subtitle url if you wanna add subtitle on media loading.
302
+
/// [isLocalSubtitle] - Set true if subtitle is on local storage
303
+
/// [isSubtitleSelected] - Set true if you wanna force the added subtitle to start display on media.
0 commit comments