https://github.com/rxlabz/flutter_video_launcher
A video launcher plugin for Flutter
https://github.com/rxlabz/flutter_video_launcher
android dartlang flutter objective-c plugin
Last synced: over 1 year ago
JSON representation
A video launcher plugin for Flutter
- Host: GitHub
- URL: https://github.com/rxlabz/flutter_video_launcher
- Owner: rxlabz
- License: bsd-3-clause
- Created: 2017-05-15T14:41:13.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-01T02:41:14.000Z (almost 7 years ago)
- Last Synced: 2025-04-09T16:21:39.310Z (over 1 year ago)
- Topics: android, dartlang, flutter, objective-c, plugin
- Language: Objective-C
- Homepage: https://pub.dartlang.org/packages/video_launcher
- Size: 4.91 MB
- Stars: 26
- Watchers: 3
- Forks: 11
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# VideoLauncher
## Example
```bash
cd flutter_video_launcher/example
flutter packages get
flutter run
```

## Usage
To use this plugin, add video_launcher as a dependency in your pubspec.yaml file.
After importing 'package:video_launcher/video_launcher.dart' the directories can be queried as follows
## Remote video
To launch a video :
```dart
Future _launch(String url) async {
if (await canLaunchVideo(url)) {
await launchVideo(url);
} else {
throw 'Could not launch $url';
}
}
```
## Local video
To play a local video file :
```dart
Future _launch(String url) async {
if (await canLaunchVideo(url, isLocal:true)) {
await launchVideo(url, isLocal:true);
} else {
throw 'Could not launch $url';
}
}
```
## Embedded asset
To play video embedded assets, you can copy them to the app storage folder, and the play them "locally"
```dart
void _loadOrLaunchLocalAsset() =>
localAssetPath != null ? _launchLocalAsset() : copyLocalAsset();
Future copyLocalAsset() async {
final dir = await getApplicationDocumentsDirectory();
final file = new File("${dir.path}/video_asset.mp4");
final videoData = await rootBundle.load("assets/video.mp4");
final bytes = videoData.buffer.asUint8List();
file.writeAsBytes(bytes, flush: true);
setState(() {
localAssetPath = file.path;
_launchLocalAsset();
});
}
void _launchLocalAsset() =>
setState(() => _launched = _launchVideo(localAssetPath, isLocal: true));
```
Please see the example app of this plugin for a full example.
## :warning: iOS App Transport Security
By default iOS forbids loading from non-https url. To cancel this restriction edit your .plist and add :
```xml
NSAppTransportSecurity
NSAllowsArbitraryLoads
```
cf. [Configuring App Transport Security Exceptions in iOS](https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/)
## Troubleshooting
If you get a MissingPluginException, try to `flutter build apk` on Android, or `flutter build ios`
## Getting Started
For help getting started with Flutter, view our online
[documentation](http://flutter.io/).