vdocipher_flutter 1.0.0-beta.3
vdocipher_flutter: ^1.0.0-beta.3 copied to clipboard
A VdoCipher plugin for flutter apps. This Plugin will help to serve content on supported platform app with Hollywood grade security to prevent video piracy.
vdocipher_flutter #
VdoCipher plugin for flutter apps.
This project is a Flutter plugin package, that will enable video playback functionality by delegating to respective native libraries based on the platform.
Note: #
- Please contact us at support@vdocipher.com before using it in your application
- IOS is not supported. Only Android support available. IOS support will be added in future.
Getting started #
Run this command with Flutter:
$ flutter pub add vdocipher_flutter
This will add a line like this to your package's pubspec.yaml (and run an implicit dart pub get
):
dependencies:
vdocipher_flutter: ^1.0.0-beta.3
Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.
Import it
Now in your Dart code, you can use:
import 'package:vdocipher_flutter/vdocipher_flutter.dart';
Example #
samples.dart #
import 'package:vdocipher_flutter/vdocipher_flutter.dart';
const EmbedInfo SAMPLE_1 = EmbedInfo.streaming(
otp: '20160313versASE313BlEe9YKEaDuju5J0XcX2Z03Hrvm5rzKScvuyojMSBZBxfZ',
playbackInfo: 'eyJ2aWRlb0lkIjoiM2YyOWI1NDM0YTVjNjE1Y2RhMThiMTZhNjIzMmZkNzUifQ==',
embedInfoOptions: EmbedInfoOptions(
autoplay: true
)
);
const EmbedInfo SAMPLE_2 = EmbedInfo.streaming(
otp: '20160313versASE313CBS0f0mkwrNqTswuCYx7Lo41GpQ3r06wbx2WgOUASrQIgH',
playbackInfo: 'eyJ2aWRlb0lkIjoiYTllYWUwOTZjZDg4NGRiYmEzNTE1M2VlNDJhNTA0YTgifQ=='
);
vdoplayback_view.dart #
import 'package:flutter/material.dart';
import 'package:vdocipher_flutter/vdocipher_flutter.dart';
import 'package:vdocipher_flutter_example/samples.dart';
class VdoPlaybackView extends StatefulWidget {
@override
_VdoPlaybackViewState createState() => _VdoPlaybackViewState();
}
class _VdoPlaybackViewState extends State<VdoPlaybackView> {
VdoPlayerController? _controller;
final double aspectRatio = 16/9;
ValueNotifier<bool> _isFullScreen = ValueNotifier(false);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Flexible(child: Container(
child: VdoPlayer(
embedInfo: SAMPLE_1,
onPlayerCreated: (controller) => _onPlayerCreated(controller),
onFullscreenChange: _onFullscreenChange,
onError: _onVdoError,
),
width: MediaQuery.of(context).size.width,
height: _isFullScreen.value ? MediaQuery.of(context).size.height : _getHeightForWidth(MediaQuery.of(context).size.width),
)),
ValueListenableBuilder(
valueListenable: _isFullScreen,
builder: (context, dynamic value, child) {
return value ? SizedBox.shrink() : _nonFullScreenContent();
}),
])
);
}
_onVdoError(VdoError vdoError) {
print("Oops, the system encountered a problem: " + vdoError.message);
}
_onPlayerCreated(VdoPlayerController? controller) {
setState(() {
_controller = controller;
});
}
_onFullscreenChange(isFullscreen) {
setState(() {
_isFullScreen.value = isFullscreen;
});
}
_nonFullScreenContent() {
return Column(
children: [
Text('Sample Playback', style: TextStyle(fontSize: 20.0),)
]);
}
double _getHeightForWidth(double width) {
return width / aspectRatio;
}
}
VdoPlayer #
Property | Type | Description |
---|---|---|
embedInfo | EmbedInfo | Embed info object |
onPlayerCreated(controller) | Function(VdoController) | Callback function returns VdoController object |
onError(error) | Function(VdoError) | Callback function returns VdoError object |
EmbedInfo #
Property | Type | Default / required | Description |
---|---|---|---|
otp | String | required | a valid OTP |
playbackInfo | String | required | A valid playbackinfo; |
embedInfoOptions | EmbedInfoOptions | null |
Embed Info options |
skipDuration | Duration | 10 seconds | Forward/Backward skip duration |
playbackSpeedOptions | List<double> |
[0.75, 1.0, 1.25, 1.5, 1.75, 2.0] |
List of playback speed options between 0.25x to 2.25x |
EmbedInfoOptions #
Property | Type | Description |
---|---|---|
safetyNetApiKey | String | A valid SafetyNetApiKey |
preferredCaptionsLanguage | String | Preferred caption language |
startPosition | Duration | Video start position |
endPosition | Duration | Video end position |
resumePosition | Duration | Vdeo resume position |
maxVideoBitrateKbps | int | Maximum video bitrate KBPS |
bufferingGoalMs | int | Buffering goal in MS |
techOverride | List<String> |
Tech override list |
disableAnalytics | bool (Default false) | Disable analytics |
autoplay | bool (Default true) | Start autoplay |
forceLowestBitrate | bool (Default false) | Force lowest bitrate |
forceHighestSupportedBitrate | bool (Default false) | Force highest supported Bitrat |
VdoController #
Property | Return Type | Description |
---|---|---|
isPlaying | bool | Video playing |
isBuffering | bool | Video buffering |
isLoading | bool | Video loading |
isEnded | bool | Video fully watched |
isFullScreen | ValueNotifier<bool> |
Video is in full screen or portrait mode |
enterFullScreen(bool isFull) | void | Set full screen mode |
load(EmbedInfo embedInfo) | Future<LoadResult> |
Load video with embed info |
play() | Future<void> |
Play video |
pause() | Future<void> |
Pause video |
stop() | Future<void> |
Stop video |
getDuration() | Future<Duration> |
Get video duration |
getPosition() | Future<Duration> |
Get current video played position |
seek(Duration target) | Future<void> |
Seek video to target duration |
setPlaybackSpeed(double speed) | Future<void> |
Set playback speed |
setCaptionLanguage(String language) | Future<bool> |
Set Caption Language |
VdoError #
Property | Return Type | Description |
---|---|---|
code | int | Error code |
message | string | Error message |
httpStatusCode | int | HTTP Status Code |